@atlashub/smartstack-cli 1.3.0 → 1.4.1

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.
@@ -1,794 +1,794 @@
1
- /* ============================================
2
- CLAUDE TOOLS DOCUMENTATION - APP
3
- ============================================ */
4
-
5
- document.addEventListener('DOMContentLoaded', function() {
6
- initSidebar();
7
- initLanguageSwitch();
8
- initCopyButtons();
9
- initMobileMenu();
10
- initSidebarToc();
11
- initScrollSpy();
12
- initInteractiveDiagram();
13
- initSearch();
14
- initCopyableCommands();
15
- });
16
-
17
- /* ============================================
18
- SIDEBAR
19
- ============================================ */
20
-
21
- function initSidebar() {
22
- const sidebar = document.querySelector('.sidebar');
23
- const toggle = document.querySelector('.sidebar-toggle');
24
-
25
- if (!sidebar || !toggle) return;
26
-
27
- // Load saved state
28
- const isCollapsed = localStorage.getItem('sidebar-collapsed') === 'true';
29
- if (isCollapsed) {
30
- sidebar.classList.add('collapsed');
31
- }
32
-
33
- toggle.addEventListener('click', function() {
34
- sidebar.classList.toggle('collapsed');
35
- localStorage.setItem('sidebar-collapsed', sidebar.classList.contains('collapsed'));
36
- });
37
-
38
- // Set active nav item
39
- const currentPage = window.location.pathname.split('/').pop() || 'index.html';
40
- document.querySelectorAll('.nav-item').forEach(item => {
41
- if (item.getAttribute('href') === currentPage) {
42
- item.classList.add('active');
43
- }
44
- });
45
- }
46
-
47
- /* ============================================
48
- LANGUAGE SWITCH
49
- ============================================ */
50
-
51
- function initLanguageSwitch() {
52
- const langSelect = document.getElementById('lang-select');
53
-
54
- // Load saved language
55
- const savedLang = localStorage.getItem('doc-language') || 'fr';
56
- setLanguage(savedLang);
57
-
58
- // Set dropdown to saved value
59
- if (langSelect) {
60
- langSelect.value = savedLang;
61
- }
62
-
63
- // Setup language button handlers (sidebar footer)
64
- document.querySelectorAll('.lang-btn').forEach(btn => {
65
- btn.addEventListener('click', function() {
66
- const lang = this.dataset.lang;
67
- setLanguage(lang);
68
- localStorage.setItem('doc-language', lang);
69
-
70
- // Update active state
71
- document.querySelectorAll('.lang-btn').forEach(b => b.classList.remove('active'));
72
- this.classList.add('active');
73
- });
74
- });
75
- }
76
-
77
- function setLanguage(lang) {
78
- // Update body class
79
- document.body.classList.remove('lang-fr', 'lang-en');
80
- document.body.classList.add('lang-' + lang);
81
-
82
- // Update dropdown value (if exists)
83
- const langSelect = document.getElementById('lang-select');
84
- if (langSelect) {
85
- langSelect.value = lang;
86
- }
87
-
88
- // Update HTML lang attribute
89
- document.documentElement.lang = lang;
90
-
91
- // Update search placeholder
92
- const searchInput = document.getElementById('search-input');
93
- if (searchInput) {
94
- const placeholder = lang === 'en' ? searchInput.dataset.placeholderEn : searchInput.dataset.placeholderFr;
95
- if (placeholder) {
96
- searchInput.placeholder = placeholder;
97
- }
98
- }
99
- }
100
-
101
- /* ============================================
102
- COPY BUTTONS
103
- ============================================ */
104
-
105
- function initCopyButtons() {
106
- document.querySelectorAll('.copy-btn').forEach(btn => {
107
- btn.addEventListener('click', async function() {
108
- const code = this.closest('.code-block').querySelector('code').textContent;
109
-
110
- try {
111
- await navigator.clipboard.writeText(code);
112
- const originalText = this.textContent;
113
- this.textContent = 'Copied!';
114
- this.style.background = 'var(--success)';
115
-
116
- setTimeout(() => {
117
- this.textContent = originalText;
118
- this.style.background = '';
119
- }, 2000);
120
- } catch (err) {
121
- console.error('Failed to copy:', err);
122
- }
123
- });
124
- });
125
- }
126
-
127
- /* ============================================
128
- MOBILE MENU
129
- ============================================ */
130
-
131
- function initMobileMenu() {
132
- const menuBtn = document.querySelector('.mobile-menu-btn');
133
- const sidebar = document.querySelector('.sidebar');
134
- const overlay = document.querySelector('.overlay');
135
-
136
- if (!menuBtn || !sidebar) return;
137
-
138
- menuBtn.addEventListener('click', function() {
139
- sidebar.classList.toggle('open');
140
- overlay?.classList.toggle('active');
141
- });
142
-
143
- overlay?.addEventListener('click', function() {
144
- sidebar.classList.remove('open');
145
- overlay.classList.remove('active');
146
- });
147
-
148
- // Close on nav item click (mobile)
149
- document.querySelectorAll('.nav-item').forEach(item => {
150
- item.addEventListener('click', function() {
151
- if (window.innerWidth <= 1024) {
152
- sidebar.classList.remove('open');
153
- overlay?.classList.remove('active');
154
- }
155
- });
156
- });
157
- }
158
-
159
- /* ============================================
160
- SIDEBAR TABLE OF CONTENTS
161
- ============================================ */
162
-
163
- function initSidebarToc() {
164
- const sidebarToc = document.querySelector('.sidebar-toc');
165
- const tocToggle = document.querySelector('.toc-toggle');
166
-
167
- if (!sidebarToc) return;
168
-
169
- // Auto-open TOC on current page
170
- sidebarToc.classList.add('open');
171
- if (tocToggle) tocToggle.classList.add('open');
172
-
173
- // Toggle handler
174
- if (tocToggle) {
175
- tocToggle.addEventListener('click', function(e) {
176
- e.preventDefault();
177
- e.stopPropagation();
178
- sidebarToc.classList.toggle('open');
179
- tocToggle.classList.toggle('open');
180
- });
181
- }
182
-
183
- // Smooth scroll for sidebar TOC links
184
- document.querySelectorAll('.sidebar-toc-link').forEach(link => {
185
- link.addEventListener('click', function(e) {
186
- e.preventDefault();
187
- const targetId = this.getAttribute('href');
188
- const target = document.querySelector(targetId);
189
- if (target) {
190
- target.scrollIntoView({ behavior: 'smooth', block: 'start' });
191
- // Update active state immediately
192
- document.querySelectorAll('.sidebar-toc-link').forEach(l => l.classList.remove('active'));
193
- this.classList.add('active');
194
- }
195
- });
196
- });
197
- }
198
-
199
- /* ============================================
200
- SCROLL SPY
201
- ============================================ */
202
-
203
- function initScrollSpy() {
204
- const headings = document.querySelectorAll('h2[id], h3[id]');
205
- const sidebarTocLinks = document.querySelectorAll('.sidebar-toc-link');
206
-
207
- if (!headings.length || !sidebarTocLinks.length) return;
208
-
209
- const observer = new IntersectionObserver(entries => {
210
- entries.forEach(entry => {
211
- if (entry.isIntersecting) {
212
- const id = entry.target.id;
213
- sidebarTocLinks.forEach(link => {
214
- link.classList.toggle('active', link.getAttribute('href') === '#' + id);
215
- });
216
- }
217
- });
218
- }, { rootMargin: '-20% 0px -80% 0px' });
219
-
220
- headings.forEach(heading => observer.observe(heading));
221
- }
222
-
223
- /* ============================================
224
- UTILITIES
225
- ============================================ */
226
-
227
- // Smooth scroll for anchor links
228
- document.querySelectorAll('a[href^="#"]').forEach(anchor => {
229
- anchor.addEventListener('click', function(e) {
230
- e.preventDefault();
231
- const target = document.querySelector(this.getAttribute('href'));
232
- if (target) {
233
- target.scrollIntoView({ behavior: 'smooth', block: 'start' });
234
- }
235
- });
236
- });
237
-
238
- // Add animation class on scroll
239
- const observerOptions = {
240
- threshold: 0.1,
241
- rootMargin: '0px 0px -50px 0px'
242
- };
243
-
244
- const fadeObserver = new IntersectionObserver((entries) => {
245
- entries.forEach(entry => {
246
- if (entry.isIntersecting) {
247
- entry.target.classList.add('fade-in');
248
- fadeObserver.unobserve(entry.target);
249
- }
250
- });
251
- }, observerOptions);
252
-
253
- document.querySelectorAll('.card, .alert, .best-practice').forEach(el => {
254
- fadeObserver.observe(el);
255
- });
256
-
257
- /* ============================================
258
- INTERACTIVE DIAGRAM
259
- ============================================ */
260
-
261
- function initInteractiveDiagram() {
262
- const diagram = document.getElementById('gitflow-diagram');
263
- const tooltip = document.getElementById('diagram-tooltip');
264
-
265
- if (!diagram || !tooltip) return;
266
-
267
- const clickableElements = diagram.querySelectorAll('.clickable-element');
268
- let activeElement = null;
269
-
270
- // Get current language
271
- function getLang() {
272
- return document.body.classList.contains('lang-en') ? 'en' : 'fr';
273
- }
274
-
275
- // Show tooltip for an element
276
- function showTooltip(element, event) {
277
- const lang = getLang();
278
- const title = element.dataset['title' + lang.charAt(0).toUpperCase() + lang.slice(1)] || element.dataset.titleFr;
279
- const desc = element.dataset['desc' + lang.charAt(0).toUpperCase() + lang.slice(1)] || element.dataset.descFr;
280
- const cmd = element.dataset.cmd || '';
281
-
282
- // Set tooltip content
283
- tooltip.querySelector('.tooltip-title').textContent = title;
284
- tooltip.querySelector('.tooltip-desc').textContent = desc;
285
-
286
- const cmdElement = tooltip.querySelector('.tooltip-cmd');
287
- if (cmd) {
288
- cmdElement.textContent = cmd;
289
- cmdElement.style.display = 'inline-block';
290
- } else {
291
- cmdElement.style.display = 'none';
292
- }
293
-
294
- // Position tooltip
295
- const diagramRect = diagram.getBoundingClientRect();
296
- const svgRect = diagram.querySelector('svg').getBoundingClientRect();
297
-
298
- // Calculate position relative to the diagram
299
- let left = event.clientX - diagramRect.left + 15;
300
- let top = event.clientY - diagramRect.top + 15;
301
-
302
- // Make tooltip visible to measure it
303
- tooltip.style.left = left + 'px';
304
- tooltip.style.top = top + 'px';
305
- tooltip.classList.add('visible');
306
-
307
- // Adjust if overflowing right edge
308
- const tooltipRect = tooltip.getBoundingClientRect();
309
- if (tooltipRect.right > diagramRect.right - 10) {
310
- left = event.clientX - diagramRect.left - tooltipRect.width - 15;
311
- tooltip.style.left = left + 'px';
312
- }
313
-
314
- // Adjust if overflowing bottom edge
315
- if (tooltipRect.bottom > window.innerHeight - 10) {
316
- top = event.clientY - diagramRect.top - tooltipRect.height - 15;
317
- tooltip.style.top = top + 'px';
318
- }
319
-
320
- // Mark element as active
321
- if (activeElement) {
322
- activeElement.classList.remove('active');
323
- }
324
- element.classList.add('active');
325
- activeElement = element;
326
- }
327
-
328
- // Hide tooltip
329
- function hideTooltip() {
330
- tooltip.classList.remove('visible');
331
- if (activeElement) {
332
- activeElement.classList.remove('active');
333
- activeElement = null;
334
- }
335
- }
336
-
337
- // Add click handlers to clickable elements
338
- clickableElements.forEach(element => {
339
- element.addEventListener('click', function(e) {
340
- e.stopPropagation();
341
-
342
- // If clicking the same element, toggle off
343
- if (activeElement === this) {
344
- hideTooltip();
345
- } else {
346
- showTooltip(this, e);
347
- }
348
- });
349
- });
350
-
351
- // Close tooltip when clicking outside
352
- document.addEventListener('click', function(e) {
353
- if (!diagram.contains(e.target) || (!e.target.closest('.clickable-element') && !e.target.closest('.diagram-tooltip'))) {
354
- hideTooltip();
355
- }
356
- });
357
-
358
- // Close on escape key
359
- document.addEventListener('keydown', function(e) {
360
- if (e.key === 'Escape') {
361
- hideTooltip();
362
- }
363
- });
364
-
365
- // Update tooltip language when language changes
366
- const langSelect = document.getElementById('lang-select');
367
- if (langSelect) {
368
- langSelect.addEventListener('change', function() {
369
- if (activeElement && tooltip.classList.contains('visible')) {
370
- // Re-show tooltip with new language
371
- const event = { clientX: parseFloat(tooltip.style.left) + diagram.getBoundingClientRect().left,
372
- clientY: parseFloat(tooltip.style.top) + diagram.getBoundingClientRect().top };
373
- setTimeout(() => showTooltip(activeElement, event), 50);
374
- }
375
- });
376
- }
377
- }
378
-
379
- /* ============================================
380
- SEARCH (Full-Text with Static Fallback)
381
- ============================================ */
382
-
383
- function initSearch() {
384
- const searchInput = document.getElementById('search-input');
385
- const searchResults = document.getElementById('search-results');
386
-
387
- if (!searchInput || !searchResults) return;
388
-
389
- // Static search index (works without server, file:// protocol)
390
- const staticIndex = [
391
- // Index - Accueil
392
- { page: 'index.html', icon: '🏠', title: { fr: 'Accueil', en: 'Home' }, section: '', anchor: '',
393
- keywords: 'accueil home documentation claude tools atlashub cli automatisation gitflow apex ef core migration hooks agents commandes installation npm' },
394
-
395
- // Installation
396
- { page: 'installation.html', icon: '📦', title: { fr: 'Installation', en: 'Installation' }, section: '', anchor: '',
397
- keywords: 'installation install npm registry nodejs node prérequis requirements setup configuration package global' },
398
- { page: 'installation.html', icon: '📦', title: { fr: 'Installation', en: 'Installation' }, section: { fr: 'Prérequis', en: 'Prerequisites' }, anchor: 'prerequisites',
399
- keywords: 'prérequis prerequisites nodejs node version 18 npm git' },
400
- { page: 'installation.html', icon: '📦', title: { fr: 'Installation', en: 'Installation' }, section: { fr: 'Installation globale', en: 'Global Installation' }, anchor: 'global-install',
401
- keywords: 'npm install global atlashub claude-tools registry package' },
402
-
403
- // GitFlow
404
- { page: 'gitflow.html', icon: '🔀', title: { fr: 'GitFlow', en: 'GitFlow' }, section: '', anchor: '',
405
- keywords: 'gitflow git workflow branch branche feature release hotfix develop main master merge fusion version semver' },
406
- { page: 'gitflow.html', icon: '🔀', title: { fr: 'GitFlow', en: 'GitFlow' }, section: { fr: 'Branches principales', en: 'Main Branches' }, anchor: 'main-branches',
407
- keywords: 'main master develop development production branches principales' },
408
- { page: 'gitflow.html', icon: '🔀', title: { fr: 'GitFlow', en: 'GitFlow' }, section: { fr: 'Feature branches', en: 'Feature branches' }, anchor: 'feature',
409
- keywords: 'feature branch nouvelle fonctionnalité develop merge création git checkout' },
410
- { page: 'gitflow.html', icon: '🔀', title: { fr: 'GitFlow', en: 'GitFlow' }, section: { fr: 'Release branches', en: 'Release branches' }, anchor: 'release',
411
- keywords: 'release branch version livraison production tag semver minor major patch' },
412
- { page: 'gitflow.html', icon: '🔀', title: { fr: 'GitFlow', en: 'GitFlow' }, section: { fr: 'Hotfix branches', en: 'Hotfix branches' }, anchor: 'hotfix',
413
- keywords: 'hotfix branch correction bug urgent production patch fix' },
414
- { page: 'gitflow.html', icon: '🔀', title: { fr: 'GitFlow', en: 'GitFlow' }, section: { fr: 'Commandes', en: 'Commands' }, anchor: 'commands',
415
- keywords: 'commandes commands gitflow init start finish status plan exec commit abort' },
416
- { page: 'gitflow.html', icon: '🔀', title: { fr: 'GitFlow', en: 'GitFlow' }, section: { fr: 'Versioning SemVer', en: 'SemVer Versioning' }, anchor: 'semver',
417
- keywords: 'semver semantic versioning version major minor patch auto increment package.json' },
418
-
419
- // EF Core
420
- { page: 'efcore.html', icon: '📄', title: { fr: 'EF Core', en: 'EF Core' }, section: '', anchor: '',
421
- keywords: 'ef core entity framework migration database dotnet .net sql model orm microsoft' },
422
- { page: 'efcore.html', icon: '📄', title: { fr: 'EF Core', en: 'EF Core' }, section: { fr: 'Structure des migrations', en: 'Migration Structure' }, anchor: 'structure',
423
- keywords: 'migration structure fichier file timestamp designer snapshot model context dbcontext' },
424
- { page: 'efcore.html', icon: '📄', title: { fr: 'EF Core', en: 'EF Core' }, section: { fr: 'Conflits', en: 'Conflicts' }, anchor: 'conflicts',
425
- keywords: 'conflit conflict merge migration snapshot résolution resolution gitflow' },
426
- { page: 'efcore.html', icon: '📄', title: { fr: 'EF Core', en: 'EF Core' }, section: { fr: 'Bonnes pratiques', en: 'Best Practices' }, anchor: 'best-practices',
427
- keywords: 'bonnes pratiques best practices migration naming convention idempotent script sql' },
428
- { page: 'efcore.html', icon: '📄', title: { fr: 'EF Core', en: 'EF Core' }, section: { fr: 'Commandes', en: 'Commands' }, anchor: 'commands',
429
- keywords: 'commandes commands dotnet ef migrations add remove update database script' },
430
-
431
- // APEX
432
- { page: 'apex.html', icon: '🎯', title: { fr: 'APEX', en: 'APEX' }, section: '', anchor: '',
433
- keywords: 'apex methodology méthodologie analyze plan execute examine implementation implémentation workflow' },
434
- { page: 'apex.html', icon: '🎯', title: { fr: 'APEX', en: 'APEX' }, section: { fr: 'Analyze', en: 'Analyze' }, anchor: 'analyze',
435
- keywords: 'analyze analyse context contexte codebase exploration recherche understanding' },
436
- { page: 'apex.html', icon: '🎯', title: { fr: 'APEX', en: 'APEX' }, section: { fr: 'Plan', en: 'Plan' }, anchor: 'plan',
437
- keywords: 'plan planning planification strategy stratégie architecture design conception' },
438
- { page: 'apex.html', icon: '🎯', title: { fr: 'APEX', en: 'APEX' }, section: { fr: 'Execute', en: 'Execute' }, anchor: 'execute',
439
- keywords: 'execute exécution implementation implémentation code coding développement development' },
440
- { page: 'apex.html', icon: '🎯', title: { fr: 'APEX', en: 'APEX' }, section: { fr: 'Examine', en: 'Examine' }, anchor: 'examine',
441
- keywords: 'examine test testing validation vérification review revue quality qualité' },
442
-
443
- // Business Analyse
444
- { page: 'business-analyse.html', icon: '📊', title: { fr: 'Business Analyse', en: 'Business Analyse' }, section: '', anchor: '',
445
- keywords: 'business analyse analysis specification brd frd requirements exigences babok' },
446
- { page: 'business-analyse.html', icon: '📊', title: { fr: 'Business Analyse', en: 'Business Analyse' }, section: { fr: 'Discovery', en: 'Discovery' }, anchor: 'phase-2',
447
- keywords: 'discover discovery questionnaire questions adaptatives ultrathink elicitation' },
448
- { page: 'business-analyse.html', icon: '📊', title: { fr: 'Business Analyse', en: 'Business Analyse' }, section: { fr: 'Specification', en: 'Specification' }, anchor: 'phase-4',
449
- keywords: 'specify specification frd use cases wireframes gherkin acceptance criteria' },
450
- { page: 'business-analyse.html', icon: '📊', title: { fr: 'Business Analyse', en: 'Business Analyse' }, section: { fr: 'Handoff', en: 'Handoff' }, anchor: 'phase-6',
451
- keywords: 'handoff dev prompt developer implementation autonome autonomous' },
452
-
453
- // Agents
454
- { page: 'agents.html', icon: '🤖', title: { fr: 'Agents', en: 'Agents' }, section: '', anchor: '',
455
- keywords: 'agents subagent task tool automation automatisation ai ia claude specialized spécialisé' },
456
- { page: 'agents.html', icon: '🤖', title: { fr: 'Agents', en: 'Agents' }, section: { fr: 'GitFlow Agents', en: 'GitFlow Agents' }, anchor: 'gitflow-agents',
457
- keywords: 'gitflow agents plan exec commit status abort rollback recovery' },
458
- { page: 'agents.html', icon: '🤖', title: { fr: 'Agents', en: 'Agents' }, section: { fr: 'Explore Agent', en: 'Explore Agent' }, anchor: 'explore',
459
- keywords: 'explore agent codebase search recherche exploration quick thorough' },
460
-
461
- // Commands
462
- { page: 'commands.html', icon: '⚡', title: { fr: 'Commandes', en: 'Commands' }, section: '', anchor: '',
463
- keywords: 'commandes commands slash cli terminal prompt gitflow apex commit review deploy' },
464
- { page: 'commands.html', icon: '⚡', title: { fr: 'Commandes', en: 'Commands' }, section: { fr: 'GitFlow Commands', en: 'GitFlow Commands' }, anchor: 'gitflow-commands',
465
- keywords: 'gitflow commands init start finish status commit plan exec' },
466
- { page: 'commands.html', icon: '⚡', title: { fr: 'Commandes', en: 'Commands' }, section: { fr: 'APEX Commands', en: 'APEX Commands' }, anchor: 'apex-commands',
467
- keywords: 'apex commands analyze plan execute examine quick' },
468
- { page: 'commands.html', icon: '⚡', title: { fr: 'Commandes', en: 'Commands' }, section: { fr: 'Commit', en: 'Commit' }, anchor: 'commit',
469
- keywords: 'commit git message conventional commits push' },
470
- { page: 'commands.html', icon: '⚡', title: { fr: 'Commandes', en: 'Commands' }, section: { fr: 'Deploy', en: 'Deploy' }, anchor: 'deploy',
471
- keywords: 'deploy deployment déploiement build test lint push production' },
472
-
473
- // Hooks
474
- { page: 'hooks.html', icon: '🔗', title: { fr: 'Hooks', en: 'Hooks' }, section: '', anchor: '',
475
- keywords: 'hooks pre-commit post-commit validation automation automatisation script event événement' },
476
- { page: 'hooks.html', icon: '🔗', title: { fr: 'Hooks', en: 'Hooks' }, section: { fr: 'Types de hooks', en: 'Hook Types' }, anchor: 'types',
477
- keywords: 'types hooks PreToolUse PostToolUse Stop SessionStart UserPromptSubmit' },
478
- { page: 'hooks.html', icon: '🔗', title: { fr: 'Hooks', en: 'Hooks' }, section: { fr: 'Configuration', en: 'Configuration' }, anchor: 'configuration',
479
- keywords: 'configuration hooks settings.json matcher command timeout' }
480
- ];
481
-
482
- let searchIndex = null;
483
- let activeIndex = -1;
484
-
485
- function getLang() {
486
- return document.body.classList.contains('lang-en') ? 'en' : 'fr';
487
- }
488
-
489
- // Build search index from static data
490
- function buildIndex() {
491
- const lang = getLang();
492
-
493
- return staticIndex.map(item => {
494
- const pageTitle = typeof item.title === 'object' ? item.title[lang] : item.title;
495
- const sectionTitle = typeof item.section === 'object' ? item.section[lang] : item.section;
496
-
497
- return {
498
- page: item.page,
499
- pageTitle: pageTitle,
500
- icon: item.icon,
501
- sectionTitle: sectionTitle || '',
502
- content: (pageTitle + ' ' + sectionTitle + ' ' + item.keywords).toLowerCase(),
503
- contentRaw: item.keywords,
504
- anchor: item.anchor,
505
- url: item.anchor ? `${item.page}#${item.anchor}` : item.page
506
- };
507
- });
508
- }
509
-
510
- // Search through index
511
- function search(query) {
512
- if (!query || query.length < 2) return [];
513
-
514
- // Build index if not ready
515
- if (!searchIndex) {
516
- searchIndex = buildIndex();
517
- }
518
-
519
- const normalizedQuery = query.toLowerCase().trim();
520
- const words = normalizedQuery.split(/\s+/).filter(w => w.length >= 2);
521
- const results = [];
522
- const seenPages = new Set();
523
-
524
- searchIndex.forEach(item => {
525
- // Check if any word matches
526
- const anyWordMatch = words.some(word => item.content.includes(word));
527
- if (!anyWordMatch) return;
528
-
529
- // Calculate relevance score
530
- let score = 0;
531
- words.forEach(word => {
532
- if (item.content.includes(word)) {
533
- // Title match is worth more
534
- if (item.pageTitle.toLowerCase().includes(word)) score += 10;
535
- if (item.sectionTitle.toLowerCase().includes(word)) score += 5;
536
- // Count occurrences in content
537
- const matches = (item.content.match(new RegExp(word, 'g')) || []).length;
538
- score += matches;
539
- }
540
- });
541
-
542
- // Generate excerpt from keywords
543
- let excerpt = item.contentRaw;
544
- if (excerpt.length > 80) {
545
- // Find first matching word position
546
- const firstWord = words.find(w => item.contentRaw.toLowerCase().includes(w));
547
- if (firstWord) {
548
- const idx = item.contentRaw.toLowerCase().indexOf(firstWord);
549
- const start = Math.max(0, idx - 20);
550
- const end = Math.min(item.contentRaw.length, idx + 60);
551
- excerpt = (start > 0 ? '...' : '') + item.contentRaw.substring(start, end) + (end < item.contentRaw.length ? '...' : '');
552
- } else {
553
- excerpt = item.contentRaw.substring(0, 80) + '...';
554
- }
555
- }
556
-
557
- // Avoid duplicate pages for same section
558
- const key = item.page + '#' + item.anchor;
559
- if (!seenPages.has(key)) {
560
- seenPages.add(key);
561
- results.push({
562
- ...item,
563
- score,
564
- excerpt
565
- });
566
- }
567
- });
568
-
569
- // Sort by score and limit results
570
- return results
571
- .sort((a, b) => b.score - a.score)
572
- .slice(0, 10);
573
- }
574
-
575
- // Escape regex special chars
576
- function escapeRegex(str) {
577
- return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
578
- }
579
-
580
- // Highlight matches in text
581
- function highlightMatch(text, query) {
582
- const words = query.toLowerCase().split(/\s+/).filter(w => w.length >= 2);
583
- let result = text;
584
- words.forEach(word => {
585
- const regex = new RegExp(`(${escapeRegex(word)})`, 'gi');
586
- result = result.replace(regex, '<mark>$1</mark>');
587
- });
588
- return result;
589
- }
590
-
591
- function renderResults(results, query) {
592
- const lang = getLang();
593
-
594
- if (results.length === 0) {
595
- const emptyMsg = lang === 'fr' ? 'Aucun résultat trouvé' : 'No results found';
596
- searchResults.innerHTML = `<div class="search-results-empty">${emptyMsg}</div>`;
597
- } else {
598
- searchResults.innerHTML = results.map((item, index) => `
599
- <a href="${item.url}" class="search-result-item${index === activeIndex ? ' active' : ''}" data-index="${index}">
600
- <div class="search-result-icon">${item.icon}</div>
601
- <div class="search-result-content">
602
- <div class="search-result-title">${highlightMatch(item.pageTitle, query)}${item.sectionTitle ? ' <span class="search-result-section">› ' + highlightMatch(item.sectionTitle, query) + '</span>' : ''}</div>
603
- <div class="search-result-excerpt">${highlightMatch(item.excerpt, query)}</div>
604
- <div class="search-result-path">${item.url}</div>
605
- </div>
606
- </a>
607
- `).join('');
608
- }
609
-
610
- searchResults.classList.add('visible');
611
- }
612
-
613
- function hideResults() {
614
- searchResults.classList.remove('visible');
615
- activeIndex = -1;
616
- }
617
-
618
- // Input handler with debounce
619
- let debounceTimer;
620
- searchInput.addEventListener('input', function() {
621
- clearTimeout(debounceTimer);
622
- const query = this.value.trim();
623
-
624
- if (query.length >= 2) {
625
- debounceTimer = setTimeout(() => {
626
- const results = search(query);
627
- activeIndex = -1;
628
- renderResults(results, query);
629
- }, 150);
630
- } else {
631
- hideResults();
632
- }
633
- });
634
-
635
- // Keyboard navigation
636
- searchInput.addEventListener('keydown', function(e) {
637
- const items = searchResults.querySelectorAll('.search-result-item');
638
-
639
- if (e.key === 'ArrowDown') {
640
- e.preventDefault();
641
- activeIndex = Math.min(activeIndex + 1, items.length - 1);
642
- updateActiveItem(items);
643
- } else if (e.key === 'ArrowUp') {
644
- e.preventDefault();
645
- activeIndex = Math.max(activeIndex - 1, 0);
646
- updateActiveItem(items);
647
- } else if (e.key === 'Enter') {
648
- e.preventDefault();
649
- if (activeIndex >= 0 && items[activeIndex]) {
650
- window.location.href = items[activeIndex].getAttribute('href');
651
- }
652
- } else if (e.key === 'Escape') {
653
- hideResults();
654
- searchInput.blur();
655
- }
656
- });
657
-
658
- function updateActiveItem(items) {
659
- items.forEach((item, index) => {
660
- item.classList.toggle('active', index === activeIndex);
661
- });
662
-
663
- if (items[activeIndex]) {
664
- items[activeIndex].scrollIntoView({ block: 'nearest' });
665
- }
666
- }
667
-
668
- // Focus handler
669
- searchInput.addEventListener('focus', function() {
670
- if (this.value.length >= 2) {
671
- const results = search(this.value);
672
- renderResults(results, this.value);
673
- }
674
- });
675
-
676
- // Click outside to close
677
- document.addEventListener('click', function(e) {
678
- if (!e.target.closest('.header-search')) {
679
- hideResults();
680
- }
681
- });
682
-
683
- // Keyboard shortcut (Ctrl/Cmd + K)
684
- document.addEventListener('keydown', function(e) {
685
- if ((e.ctrlKey || e.metaKey) && e.key === 'k') {
686
- e.preventDefault();
687
- searchInput.focus();
688
- searchInput.select();
689
- }
690
- });
691
- }
692
-
693
- /* ============================================
694
- COPYABLE COMMANDS (SVG Diagram)
695
- ============================================ */
696
-
697
- function initCopyableCommands() {
698
- const copyableElements = document.querySelectorAll('.cmd-copyable');
699
-
700
- if (copyableElements.length === 0) return;
701
-
702
- // Get current language
703
- function getLang() {
704
- return document.body.classList.contains('lang-en') ? 'en' : 'fr';
705
- }
706
-
707
- // Create floating tooltip for feedback
708
- const tooltip = document.createElement('div');
709
- tooltip.className = 'copy-tooltip';
710
- tooltip.style.cssText = `
711
- position: fixed;
712
- background: #22c55e;
713
- color: white;
714
- padding: 0.5rem 1rem;
715
- border-radius: 6px;
716
- font-size: 0.85rem;
717
- font-weight: 500;
718
- z-index: 10000;
719
- pointer-events: none;
720
- opacity: 0;
721
- transition: opacity 0.2s ease;
722
- box-shadow: 0 4px 12px rgba(0,0,0,0.3);
723
- `;
724
- document.body.appendChild(tooltip);
725
-
726
- copyableElements.forEach(element => {
727
- // Add hover effect
728
- element.addEventListener('mouseenter', function() {
729
- const rect = this.querySelector('rect');
730
- if (rect) {
731
- rect.style.filter = 'brightness(1.2)';
732
- rect.style.transition = 'filter 0.2s ease';
733
- }
734
- });
735
-
736
- element.addEventListener('mouseleave', function() {
737
- const rect = this.querySelector('rect');
738
- if (rect) {
739
- rect.style.filter = '';
740
- }
741
- });
742
-
743
- // Add click handler
744
- element.addEventListener('click', function(e) {
745
- e.stopPropagation();
746
-
747
- const cmd = this.dataset.cmd;
748
- if (!cmd) return;
749
-
750
- // Copy to clipboard
751
- navigator.clipboard.writeText(cmd).then(() => {
752
- // Show tooltip
753
- const lang = getLang();
754
- tooltip.textContent = lang === 'fr' ? '✓ Copié !' : '✓ Copied!';
755
-
756
- // Position tooltip near cursor
757
- tooltip.style.left = e.clientX + 10 + 'px';
758
- tooltip.style.top = e.clientY - 30 + 'px';
759
- tooltip.style.opacity = '1';
760
-
761
- // Flash effect on element
762
- const rect = this.querySelector('rect');
763
- if (rect) {
764
- const originalStroke = rect.getAttribute('stroke');
765
- rect.setAttribute('stroke', '#22c55e');
766
- rect.style.filter = 'brightness(1.4)';
767
-
768
- setTimeout(() => {
769
- rect.setAttribute('stroke', originalStroke);
770
- rect.style.filter = '';
771
- }, 300);
772
- }
773
-
774
- // Hide tooltip after delay
775
- setTimeout(() => {
776
- tooltip.style.opacity = '0';
777
- }, 1500);
778
- }).catch(err => {
779
- console.error('Failed to copy:', err);
780
- const lang = getLang();
781
- tooltip.textContent = lang === 'fr' ? '✗ Erreur' : '✗ Error';
782
- tooltip.style.background = '#ef4444';
783
- tooltip.style.left = e.clientX + 10 + 'px';
784
- tooltip.style.top = e.clientY - 30 + 'px';
785
- tooltip.style.opacity = '1';
786
-
787
- setTimeout(() => {
788
- tooltip.style.opacity = '0';
789
- tooltip.style.background = '#22c55e';
790
- }, 1500);
791
- });
792
- });
793
- });
794
- }
1
+ /* ============================================
2
+ CLAUDE TOOLS DOCUMENTATION - APP
3
+ ============================================ */
4
+
5
+ document.addEventListener('DOMContentLoaded', function() {
6
+ initSidebar();
7
+ initLanguageSwitch();
8
+ initCopyButtons();
9
+ initMobileMenu();
10
+ initSidebarToc();
11
+ initScrollSpy();
12
+ initInteractiveDiagram();
13
+ initSearch();
14
+ initCopyableCommands();
15
+ });
16
+
17
+ /* ============================================
18
+ SIDEBAR
19
+ ============================================ */
20
+
21
+ function initSidebar() {
22
+ const sidebar = document.querySelector('.sidebar');
23
+ const toggle = document.querySelector('.sidebar-toggle');
24
+
25
+ if (!sidebar || !toggle) return;
26
+
27
+ // Load saved state
28
+ const isCollapsed = localStorage.getItem('sidebar-collapsed') === 'true';
29
+ if (isCollapsed) {
30
+ sidebar.classList.add('collapsed');
31
+ }
32
+
33
+ toggle.addEventListener('click', function() {
34
+ sidebar.classList.toggle('collapsed');
35
+ localStorage.setItem('sidebar-collapsed', sidebar.classList.contains('collapsed'));
36
+ });
37
+
38
+ // Set active nav item
39
+ const currentPage = window.location.pathname.split('/').pop() || 'index.html';
40
+ document.querySelectorAll('.nav-item').forEach(item => {
41
+ if (item.getAttribute('href') === currentPage) {
42
+ item.classList.add('active');
43
+ }
44
+ });
45
+ }
46
+
47
+ /* ============================================
48
+ LANGUAGE SWITCH
49
+ ============================================ */
50
+
51
+ function initLanguageSwitch() {
52
+ const langSelect = document.getElementById('lang-select');
53
+
54
+ // Load saved language
55
+ const savedLang = localStorage.getItem('doc-language') || 'fr';
56
+ setLanguage(savedLang);
57
+
58
+ // Set dropdown to saved value
59
+ if (langSelect) {
60
+ langSelect.value = savedLang;
61
+ }
62
+
63
+ // Setup language button handlers (sidebar footer)
64
+ document.querySelectorAll('.lang-btn').forEach(btn => {
65
+ btn.addEventListener('click', function() {
66
+ const lang = this.dataset.lang;
67
+ setLanguage(lang);
68
+ localStorage.setItem('doc-language', lang);
69
+
70
+ // Update active state
71
+ document.querySelectorAll('.lang-btn').forEach(b => b.classList.remove('active'));
72
+ this.classList.add('active');
73
+ });
74
+ });
75
+ }
76
+
77
+ function setLanguage(lang) {
78
+ // Update body class
79
+ document.body.classList.remove('lang-fr', 'lang-en');
80
+ document.body.classList.add('lang-' + lang);
81
+
82
+ // Update dropdown value (if exists)
83
+ const langSelect = document.getElementById('lang-select');
84
+ if (langSelect) {
85
+ langSelect.value = lang;
86
+ }
87
+
88
+ // Update HTML lang attribute
89
+ document.documentElement.lang = lang;
90
+
91
+ // Update search placeholder
92
+ const searchInput = document.getElementById('search-input');
93
+ if (searchInput) {
94
+ const placeholder = lang === 'en' ? searchInput.dataset.placeholderEn : searchInput.dataset.placeholderFr;
95
+ if (placeholder) {
96
+ searchInput.placeholder = placeholder;
97
+ }
98
+ }
99
+ }
100
+
101
+ /* ============================================
102
+ COPY BUTTONS
103
+ ============================================ */
104
+
105
+ function initCopyButtons() {
106
+ document.querySelectorAll('.copy-btn').forEach(btn => {
107
+ btn.addEventListener('click', async function() {
108
+ const code = this.closest('.code-block').querySelector('code').textContent;
109
+
110
+ try {
111
+ await navigator.clipboard.writeText(code);
112
+ const originalText = this.textContent;
113
+ this.textContent = 'Copied!';
114
+ this.style.background = 'var(--success)';
115
+
116
+ setTimeout(() => {
117
+ this.textContent = originalText;
118
+ this.style.background = '';
119
+ }, 2000);
120
+ } catch (err) {
121
+ console.error('Failed to copy:', err);
122
+ }
123
+ });
124
+ });
125
+ }
126
+
127
+ /* ============================================
128
+ MOBILE MENU
129
+ ============================================ */
130
+
131
+ function initMobileMenu() {
132
+ const menuBtn = document.querySelector('.mobile-menu-btn');
133
+ const sidebar = document.querySelector('.sidebar');
134
+ const overlay = document.querySelector('.overlay');
135
+
136
+ if (!menuBtn || !sidebar) return;
137
+
138
+ menuBtn.addEventListener('click', function() {
139
+ sidebar.classList.toggle('open');
140
+ overlay?.classList.toggle('active');
141
+ });
142
+
143
+ overlay?.addEventListener('click', function() {
144
+ sidebar.classList.remove('open');
145
+ overlay.classList.remove('active');
146
+ });
147
+
148
+ // Close on nav item click (mobile)
149
+ document.querySelectorAll('.nav-item').forEach(item => {
150
+ item.addEventListener('click', function() {
151
+ if (window.innerWidth <= 1024) {
152
+ sidebar.classList.remove('open');
153
+ overlay?.classList.remove('active');
154
+ }
155
+ });
156
+ });
157
+ }
158
+
159
+ /* ============================================
160
+ SIDEBAR TABLE OF CONTENTS
161
+ ============================================ */
162
+
163
+ function initSidebarToc() {
164
+ const sidebarToc = document.querySelector('.sidebar-toc');
165
+ const tocToggle = document.querySelector('.toc-toggle');
166
+
167
+ if (!sidebarToc) return;
168
+
169
+ // Auto-open TOC on current page
170
+ sidebarToc.classList.add('open');
171
+ if (tocToggle) tocToggle.classList.add('open');
172
+
173
+ // Toggle handler
174
+ if (tocToggle) {
175
+ tocToggle.addEventListener('click', function(e) {
176
+ e.preventDefault();
177
+ e.stopPropagation();
178
+ sidebarToc.classList.toggle('open');
179
+ tocToggle.classList.toggle('open');
180
+ });
181
+ }
182
+
183
+ // Smooth scroll for sidebar TOC links
184
+ document.querySelectorAll('.sidebar-toc-link').forEach(link => {
185
+ link.addEventListener('click', function(e) {
186
+ e.preventDefault();
187
+ const targetId = this.getAttribute('href');
188
+ const target = document.querySelector(targetId);
189
+ if (target) {
190
+ target.scrollIntoView({ behavior: 'smooth', block: 'start' });
191
+ // Update active state immediately
192
+ document.querySelectorAll('.sidebar-toc-link').forEach(l => l.classList.remove('active'));
193
+ this.classList.add('active');
194
+ }
195
+ });
196
+ });
197
+ }
198
+
199
+ /* ============================================
200
+ SCROLL SPY
201
+ ============================================ */
202
+
203
+ function initScrollSpy() {
204
+ const headings = document.querySelectorAll('h2[id], h3[id]');
205
+ const sidebarTocLinks = document.querySelectorAll('.sidebar-toc-link');
206
+
207
+ if (!headings.length || !sidebarTocLinks.length) return;
208
+
209
+ const observer = new IntersectionObserver(entries => {
210
+ entries.forEach(entry => {
211
+ if (entry.isIntersecting) {
212
+ const id = entry.target.id;
213
+ sidebarTocLinks.forEach(link => {
214
+ link.classList.toggle('active', link.getAttribute('href') === '#' + id);
215
+ });
216
+ }
217
+ });
218
+ }, { rootMargin: '-20% 0px -80% 0px' });
219
+
220
+ headings.forEach(heading => observer.observe(heading));
221
+ }
222
+
223
+ /* ============================================
224
+ UTILITIES
225
+ ============================================ */
226
+
227
+ // Smooth scroll for anchor links
228
+ document.querySelectorAll('a[href^="#"]').forEach(anchor => {
229
+ anchor.addEventListener('click', function(e) {
230
+ e.preventDefault();
231
+ const target = document.querySelector(this.getAttribute('href'));
232
+ if (target) {
233
+ target.scrollIntoView({ behavior: 'smooth', block: 'start' });
234
+ }
235
+ });
236
+ });
237
+
238
+ // Add animation class on scroll
239
+ const observerOptions = {
240
+ threshold: 0.1,
241
+ rootMargin: '0px 0px -50px 0px'
242
+ };
243
+
244
+ const fadeObserver = new IntersectionObserver((entries) => {
245
+ entries.forEach(entry => {
246
+ if (entry.isIntersecting) {
247
+ entry.target.classList.add('fade-in');
248
+ fadeObserver.unobserve(entry.target);
249
+ }
250
+ });
251
+ }, observerOptions);
252
+
253
+ document.querySelectorAll('.card, .alert, .best-practice').forEach(el => {
254
+ fadeObserver.observe(el);
255
+ });
256
+
257
+ /* ============================================
258
+ INTERACTIVE DIAGRAM
259
+ ============================================ */
260
+
261
+ function initInteractiveDiagram() {
262
+ const diagram = document.getElementById('gitflow-diagram');
263
+ const tooltip = document.getElementById('diagram-tooltip');
264
+
265
+ if (!diagram || !tooltip) return;
266
+
267
+ const clickableElements = diagram.querySelectorAll('.clickable-element');
268
+ let activeElement = null;
269
+
270
+ // Get current language
271
+ function getLang() {
272
+ return document.body.classList.contains('lang-en') ? 'en' : 'fr';
273
+ }
274
+
275
+ // Show tooltip for an element
276
+ function showTooltip(element, event) {
277
+ const lang = getLang();
278
+ const title = element.dataset['title' + lang.charAt(0).toUpperCase() + lang.slice(1)] || element.dataset.titleFr;
279
+ const desc = element.dataset['desc' + lang.charAt(0).toUpperCase() + lang.slice(1)] || element.dataset.descFr;
280
+ const cmd = element.dataset.cmd || '';
281
+
282
+ // Set tooltip content
283
+ tooltip.querySelector('.tooltip-title').textContent = title;
284
+ tooltip.querySelector('.tooltip-desc').textContent = desc;
285
+
286
+ const cmdElement = tooltip.querySelector('.tooltip-cmd');
287
+ if (cmd) {
288
+ cmdElement.textContent = cmd;
289
+ cmdElement.style.display = 'inline-block';
290
+ } else {
291
+ cmdElement.style.display = 'none';
292
+ }
293
+
294
+ // Position tooltip
295
+ const diagramRect = diagram.getBoundingClientRect();
296
+ const svgRect = diagram.querySelector('svg').getBoundingClientRect();
297
+
298
+ // Calculate position relative to the diagram
299
+ let left = event.clientX - diagramRect.left + 15;
300
+ let top = event.clientY - diagramRect.top + 15;
301
+
302
+ // Make tooltip visible to measure it
303
+ tooltip.style.left = left + 'px';
304
+ tooltip.style.top = top + 'px';
305
+ tooltip.classList.add('visible');
306
+
307
+ // Adjust if overflowing right edge
308
+ const tooltipRect = tooltip.getBoundingClientRect();
309
+ if (tooltipRect.right > diagramRect.right - 10) {
310
+ left = event.clientX - diagramRect.left - tooltipRect.width - 15;
311
+ tooltip.style.left = left + 'px';
312
+ }
313
+
314
+ // Adjust if overflowing bottom edge
315
+ if (tooltipRect.bottom > window.innerHeight - 10) {
316
+ top = event.clientY - diagramRect.top - tooltipRect.height - 15;
317
+ tooltip.style.top = top + 'px';
318
+ }
319
+
320
+ // Mark element as active
321
+ if (activeElement) {
322
+ activeElement.classList.remove('active');
323
+ }
324
+ element.classList.add('active');
325
+ activeElement = element;
326
+ }
327
+
328
+ // Hide tooltip
329
+ function hideTooltip() {
330
+ tooltip.classList.remove('visible');
331
+ if (activeElement) {
332
+ activeElement.classList.remove('active');
333
+ activeElement = null;
334
+ }
335
+ }
336
+
337
+ // Add click handlers to clickable elements
338
+ clickableElements.forEach(element => {
339
+ element.addEventListener('click', function(e) {
340
+ e.stopPropagation();
341
+
342
+ // If clicking the same element, toggle off
343
+ if (activeElement === this) {
344
+ hideTooltip();
345
+ } else {
346
+ showTooltip(this, e);
347
+ }
348
+ });
349
+ });
350
+
351
+ // Close tooltip when clicking outside
352
+ document.addEventListener('click', function(e) {
353
+ if (!diagram.contains(e.target) || (!e.target.closest('.clickable-element') && !e.target.closest('.diagram-tooltip'))) {
354
+ hideTooltip();
355
+ }
356
+ });
357
+
358
+ // Close on escape key
359
+ document.addEventListener('keydown', function(e) {
360
+ if (e.key === 'Escape') {
361
+ hideTooltip();
362
+ }
363
+ });
364
+
365
+ // Update tooltip language when language changes
366
+ const langSelect = document.getElementById('lang-select');
367
+ if (langSelect) {
368
+ langSelect.addEventListener('change', function() {
369
+ if (activeElement && tooltip.classList.contains('visible')) {
370
+ // Re-show tooltip with new language
371
+ const event = { clientX: parseFloat(tooltip.style.left) + diagram.getBoundingClientRect().left,
372
+ clientY: parseFloat(tooltip.style.top) + diagram.getBoundingClientRect().top };
373
+ setTimeout(() => showTooltip(activeElement, event), 50);
374
+ }
375
+ });
376
+ }
377
+ }
378
+
379
+ /* ============================================
380
+ SEARCH (Full-Text with Static Fallback)
381
+ ============================================ */
382
+
383
+ function initSearch() {
384
+ const searchInput = document.getElementById('search-input');
385
+ const searchResults = document.getElementById('search-results');
386
+
387
+ if (!searchInput || !searchResults) return;
388
+
389
+ // Static search index (works without server, file:// protocol)
390
+ const staticIndex = [
391
+ // Index - Accueil
392
+ { page: 'index.html', icon: '🏠', title: { fr: 'Accueil', en: 'Home' }, section: '', anchor: '',
393
+ keywords: 'accueil home documentation claude tools atlashub cli automatisation gitflow apex ef core migration hooks agents commandes installation npm' },
394
+
395
+ // Installation
396
+ { page: 'installation.html', icon: '📦', title: { fr: 'Installation', en: 'Installation' }, section: '', anchor: '',
397
+ keywords: 'installation install npm registry nodejs node prérequis requirements setup configuration package global' },
398
+ { page: 'installation.html', icon: '📦', title: { fr: 'Installation', en: 'Installation' }, section: { fr: 'Prérequis', en: 'Prerequisites' }, anchor: 'prerequisites',
399
+ keywords: 'prérequis prerequisites nodejs node version 18 npm git' },
400
+ { page: 'installation.html', icon: '📦', title: { fr: 'Installation', en: 'Installation' }, section: { fr: 'Installation globale', en: 'Global Installation' }, anchor: 'global-install',
401
+ keywords: 'npm install global atlashub claude-tools registry package' },
402
+
403
+ // GitFlow
404
+ { page: 'gitflow.html', icon: '🔀', title: { fr: 'GitFlow', en: 'GitFlow' }, section: '', anchor: '',
405
+ keywords: 'gitflow git workflow branch branche feature release hotfix develop main master merge fusion version semver' },
406
+ { page: 'gitflow.html', icon: '🔀', title: { fr: 'GitFlow', en: 'GitFlow' }, section: { fr: 'Branches principales', en: 'Main Branches' }, anchor: 'main-branches',
407
+ keywords: 'main master develop development production branches principales' },
408
+ { page: 'gitflow.html', icon: '🔀', title: { fr: 'GitFlow', en: 'GitFlow' }, section: { fr: 'Feature branches', en: 'Feature branches' }, anchor: 'feature',
409
+ keywords: 'feature branch nouvelle fonctionnalité develop merge création git checkout' },
410
+ { page: 'gitflow.html', icon: '🔀', title: { fr: 'GitFlow', en: 'GitFlow' }, section: { fr: 'Release branches', en: 'Release branches' }, anchor: 'release',
411
+ keywords: 'release branch version livraison production tag semver minor major patch' },
412
+ { page: 'gitflow.html', icon: '🔀', title: { fr: 'GitFlow', en: 'GitFlow' }, section: { fr: 'Hotfix branches', en: 'Hotfix branches' }, anchor: 'hotfix',
413
+ keywords: 'hotfix branch correction bug urgent production patch fix' },
414
+ { page: 'gitflow.html', icon: '🔀', title: { fr: 'GitFlow', en: 'GitFlow' }, section: { fr: 'Commandes', en: 'Commands' }, anchor: 'commands',
415
+ keywords: 'commandes commands gitflow init start finish status plan exec commit abort' },
416
+ { page: 'gitflow.html', icon: '🔀', title: { fr: 'GitFlow', en: 'GitFlow' }, section: { fr: 'Versioning SemVer', en: 'SemVer Versioning' }, anchor: 'semver',
417
+ keywords: 'semver semantic versioning version major minor patch auto increment package.json' },
418
+
419
+ // EF Core
420
+ { page: 'efcore.html', icon: '📄', title: { fr: 'EF Core', en: 'EF Core' }, section: '', anchor: '',
421
+ keywords: 'ef core entity framework migration database dotnet .net sql model orm microsoft' },
422
+ { page: 'efcore.html', icon: '📄', title: { fr: 'EF Core', en: 'EF Core' }, section: { fr: 'Structure des migrations', en: 'Migration Structure' }, anchor: 'structure',
423
+ keywords: 'migration structure fichier file timestamp designer snapshot model context dbcontext' },
424
+ { page: 'efcore.html', icon: '📄', title: { fr: 'EF Core', en: 'EF Core' }, section: { fr: 'Conflits', en: 'Conflicts' }, anchor: 'conflicts',
425
+ keywords: 'conflit conflict merge migration snapshot résolution resolution gitflow' },
426
+ { page: 'efcore.html', icon: '📄', title: { fr: 'EF Core', en: 'EF Core' }, section: { fr: 'Bonnes pratiques', en: 'Best Practices' }, anchor: 'best-practices',
427
+ keywords: 'bonnes pratiques best practices migration naming convention idempotent script sql' },
428
+ { page: 'efcore.html', icon: '📄', title: { fr: 'EF Core', en: 'EF Core' }, section: { fr: 'Commandes', en: 'Commands' }, anchor: 'commands',
429
+ keywords: 'commandes commands dotnet ef migrations add remove update database script' },
430
+
431
+ // APEX
432
+ { page: 'apex.html', icon: '🎯', title: { fr: 'APEX', en: 'APEX' }, section: '', anchor: '',
433
+ keywords: 'apex methodology méthodologie analyze plan execute examine implementation implémentation workflow' },
434
+ { page: 'apex.html', icon: '🎯', title: { fr: 'APEX', en: 'APEX' }, section: { fr: 'Analyze', en: 'Analyze' }, anchor: 'analyze',
435
+ keywords: 'analyze analyse context contexte codebase exploration recherche understanding' },
436
+ { page: 'apex.html', icon: '🎯', title: { fr: 'APEX', en: 'APEX' }, section: { fr: 'Plan', en: 'Plan' }, anchor: 'plan',
437
+ keywords: 'plan planning planification strategy stratégie architecture design conception' },
438
+ { page: 'apex.html', icon: '🎯', title: { fr: 'APEX', en: 'APEX' }, section: { fr: 'Execute', en: 'Execute' }, anchor: 'execute',
439
+ keywords: 'execute exécution implementation implémentation code coding développement development' },
440
+ { page: 'apex.html', icon: '🎯', title: { fr: 'APEX', en: 'APEX' }, section: { fr: 'Examine', en: 'Examine' }, anchor: 'examine',
441
+ keywords: 'examine test testing validation vérification review revue quality qualité' },
442
+
443
+ // Business Analyse
444
+ { page: 'business-analyse.html', icon: '📊', title: { fr: 'Business Analyse', en: 'Business Analyse' }, section: '', anchor: '',
445
+ keywords: 'business analyse analysis specification brd frd requirements exigences babok' },
446
+ { page: 'business-analyse.html', icon: '📊', title: { fr: 'Business Analyse', en: 'Business Analyse' }, section: { fr: 'Discovery', en: 'Discovery' }, anchor: 'phase-2',
447
+ keywords: 'discover discovery questionnaire questions adaptatives ultrathink elicitation' },
448
+ { page: 'business-analyse.html', icon: '📊', title: { fr: 'Business Analyse', en: 'Business Analyse' }, section: { fr: 'Specification', en: 'Specification' }, anchor: 'phase-4',
449
+ keywords: 'specify specification frd use cases wireframes gherkin acceptance criteria' },
450
+ { page: 'business-analyse.html', icon: '📊', title: { fr: 'Business Analyse', en: 'Business Analyse' }, section: { fr: 'Handoff', en: 'Handoff' }, anchor: 'phase-6',
451
+ keywords: 'handoff dev prompt developer implementation autonome autonomous' },
452
+
453
+ // Agents
454
+ { page: 'agents.html', icon: '🤖', title: { fr: 'Agents', en: 'Agents' }, section: '', anchor: '',
455
+ keywords: 'agents subagent task tool automation automatisation ai ia claude specialized spécialisé' },
456
+ { page: 'agents.html', icon: '🤖', title: { fr: 'Agents', en: 'Agents' }, section: { fr: 'GitFlow Agents', en: 'GitFlow Agents' }, anchor: 'gitflow-agents',
457
+ keywords: 'gitflow agents plan exec commit status abort rollback recovery' },
458
+ { page: 'agents.html', icon: '🤖', title: { fr: 'Agents', en: 'Agents' }, section: { fr: 'Explore Agent', en: 'Explore Agent' }, anchor: 'explore',
459
+ keywords: 'explore agent codebase search recherche exploration quick thorough' },
460
+
461
+ // Commands
462
+ { page: 'commands.html', icon: '⚡', title: { fr: 'Commandes', en: 'Commands' }, section: '', anchor: '',
463
+ keywords: 'commandes commands slash cli terminal prompt gitflow apex commit review deploy' },
464
+ { page: 'commands.html', icon: '⚡', title: { fr: 'Commandes', en: 'Commands' }, section: { fr: 'GitFlow Commands', en: 'GitFlow Commands' }, anchor: 'gitflow-commands',
465
+ keywords: 'gitflow commands init start finish status commit plan exec' },
466
+ { page: 'commands.html', icon: '⚡', title: { fr: 'Commandes', en: 'Commands' }, section: { fr: 'APEX Commands', en: 'APEX Commands' }, anchor: 'apex-commands',
467
+ keywords: 'apex commands analyze plan execute examine quick' },
468
+ { page: 'commands.html', icon: '⚡', title: { fr: 'Commandes', en: 'Commands' }, section: { fr: 'Commit', en: 'Commit' }, anchor: 'commit',
469
+ keywords: 'commit git message conventional commits push' },
470
+ { page: 'commands.html', icon: '⚡', title: { fr: 'Commandes', en: 'Commands' }, section: { fr: 'Deploy', en: 'Deploy' }, anchor: 'deploy',
471
+ keywords: 'deploy deployment déploiement build test lint push production' },
472
+
473
+ // Hooks
474
+ { page: 'hooks.html', icon: '🔗', title: { fr: 'Hooks', en: 'Hooks' }, section: '', anchor: '',
475
+ keywords: 'hooks pre-commit post-commit validation automation automatisation script event événement' },
476
+ { page: 'hooks.html', icon: '🔗', title: { fr: 'Hooks', en: 'Hooks' }, section: { fr: 'Types de hooks', en: 'Hook Types' }, anchor: 'types',
477
+ keywords: 'types hooks PreToolUse PostToolUse Stop SessionStart UserPromptSubmit' },
478
+ { page: 'hooks.html', icon: '🔗', title: { fr: 'Hooks', en: 'Hooks' }, section: { fr: 'Configuration', en: 'Configuration' }, anchor: 'configuration',
479
+ keywords: 'configuration hooks settings.json matcher command timeout' }
480
+ ];
481
+
482
+ let searchIndex = null;
483
+ let activeIndex = -1;
484
+
485
+ function getLang() {
486
+ return document.body.classList.contains('lang-en') ? 'en' : 'fr';
487
+ }
488
+
489
+ // Build search index from static data
490
+ function buildIndex() {
491
+ const lang = getLang();
492
+
493
+ return staticIndex.map(item => {
494
+ const pageTitle = typeof item.title === 'object' ? item.title[lang] : item.title;
495
+ const sectionTitle = typeof item.section === 'object' ? item.section[lang] : item.section;
496
+
497
+ return {
498
+ page: item.page,
499
+ pageTitle: pageTitle,
500
+ icon: item.icon,
501
+ sectionTitle: sectionTitle || '',
502
+ content: (pageTitle + ' ' + sectionTitle + ' ' + item.keywords).toLowerCase(),
503
+ contentRaw: item.keywords,
504
+ anchor: item.anchor,
505
+ url: item.anchor ? `${item.page}#${item.anchor}` : item.page
506
+ };
507
+ });
508
+ }
509
+
510
+ // Search through index
511
+ function search(query) {
512
+ if (!query || query.length < 2) return [];
513
+
514
+ // Build index if not ready
515
+ if (!searchIndex) {
516
+ searchIndex = buildIndex();
517
+ }
518
+
519
+ const normalizedQuery = query.toLowerCase().trim();
520
+ const words = normalizedQuery.split(/\s+/).filter(w => w.length >= 2);
521
+ const results = [];
522
+ const seenPages = new Set();
523
+
524
+ searchIndex.forEach(item => {
525
+ // Check if any word matches
526
+ const anyWordMatch = words.some(word => item.content.includes(word));
527
+ if (!anyWordMatch) return;
528
+
529
+ // Calculate relevance score
530
+ let score = 0;
531
+ words.forEach(word => {
532
+ if (item.content.includes(word)) {
533
+ // Title match is worth more
534
+ if (item.pageTitle.toLowerCase().includes(word)) score += 10;
535
+ if (item.sectionTitle.toLowerCase().includes(word)) score += 5;
536
+ // Count occurrences in content
537
+ const matches = (item.content.match(new RegExp(word, 'g')) || []).length;
538
+ score += matches;
539
+ }
540
+ });
541
+
542
+ // Generate excerpt from keywords
543
+ let excerpt = item.contentRaw;
544
+ if (excerpt.length > 80) {
545
+ // Find first matching word position
546
+ const firstWord = words.find(w => item.contentRaw.toLowerCase().includes(w));
547
+ if (firstWord) {
548
+ const idx = item.contentRaw.toLowerCase().indexOf(firstWord);
549
+ const start = Math.max(0, idx - 20);
550
+ const end = Math.min(item.contentRaw.length, idx + 60);
551
+ excerpt = (start > 0 ? '...' : '') + item.contentRaw.substring(start, end) + (end < item.contentRaw.length ? '...' : '');
552
+ } else {
553
+ excerpt = item.contentRaw.substring(0, 80) + '...';
554
+ }
555
+ }
556
+
557
+ // Avoid duplicate pages for same section
558
+ const key = item.page + '#' + item.anchor;
559
+ if (!seenPages.has(key)) {
560
+ seenPages.add(key);
561
+ results.push({
562
+ ...item,
563
+ score,
564
+ excerpt
565
+ });
566
+ }
567
+ });
568
+
569
+ // Sort by score and limit results
570
+ return results
571
+ .sort((a, b) => b.score - a.score)
572
+ .slice(0, 10);
573
+ }
574
+
575
+ // Escape regex special chars
576
+ function escapeRegex(str) {
577
+ return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
578
+ }
579
+
580
+ // Highlight matches in text
581
+ function highlightMatch(text, query) {
582
+ const words = query.toLowerCase().split(/\s+/).filter(w => w.length >= 2);
583
+ let result = text;
584
+ words.forEach(word => {
585
+ const regex = new RegExp(`(${escapeRegex(word)})`, 'gi');
586
+ result = result.replace(regex, '<mark>$1</mark>');
587
+ });
588
+ return result;
589
+ }
590
+
591
+ function renderResults(results, query) {
592
+ const lang = getLang();
593
+
594
+ if (results.length === 0) {
595
+ const emptyMsg = lang === 'fr' ? 'Aucun résultat trouvé' : 'No results found';
596
+ searchResults.innerHTML = `<div class="search-results-empty">${emptyMsg}</div>`;
597
+ } else {
598
+ searchResults.innerHTML = results.map((item, index) => `
599
+ <a href="${item.url}" class="search-result-item${index === activeIndex ? ' active' : ''}" data-index="${index}">
600
+ <div class="search-result-icon">${item.icon}</div>
601
+ <div class="search-result-content">
602
+ <div class="search-result-title">${highlightMatch(item.pageTitle, query)}${item.sectionTitle ? ' <span class="search-result-section">› ' + highlightMatch(item.sectionTitle, query) + '</span>' : ''}</div>
603
+ <div class="search-result-excerpt">${highlightMatch(item.excerpt, query)}</div>
604
+ <div class="search-result-path">${item.url}</div>
605
+ </div>
606
+ </a>
607
+ `).join('');
608
+ }
609
+
610
+ searchResults.classList.add('visible');
611
+ }
612
+
613
+ function hideResults() {
614
+ searchResults.classList.remove('visible');
615
+ activeIndex = -1;
616
+ }
617
+
618
+ // Input handler with debounce
619
+ let debounceTimer;
620
+ searchInput.addEventListener('input', function() {
621
+ clearTimeout(debounceTimer);
622
+ const query = this.value.trim();
623
+
624
+ if (query.length >= 2) {
625
+ debounceTimer = setTimeout(() => {
626
+ const results = search(query);
627
+ activeIndex = -1;
628
+ renderResults(results, query);
629
+ }, 150);
630
+ } else {
631
+ hideResults();
632
+ }
633
+ });
634
+
635
+ // Keyboard navigation
636
+ searchInput.addEventListener('keydown', function(e) {
637
+ const items = searchResults.querySelectorAll('.search-result-item');
638
+
639
+ if (e.key === 'ArrowDown') {
640
+ e.preventDefault();
641
+ activeIndex = Math.min(activeIndex + 1, items.length - 1);
642
+ updateActiveItem(items);
643
+ } else if (e.key === 'ArrowUp') {
644
+ e.preventDefault();
645
+ activeIndex = Math.max(activeIndex - 1, 0);
646
+ updateActiveItem(items);
647
+ } else if (e.key === 'Enter') {
648
+ e.preventDefault();
649
+ if (activeIndex >= 0 && items[activeIndex]) {
650
+ window.location.href = items[activeIndex].getAttribute('href');
651
+ }
652
+ } else if (e.key === 'Escape') {
653
+ hideResults();
654
+ searchInput.blur();
655
+ }
656
+ });
657
+
658
+ function updateActiveItem(items) {
659
+ items.forEach((item, index) => {
660
+ item.classList.toggle('active', index === activeIndex);
661
+ });
662
+
663
+ if (items[activeIndex]) {
664
+ items[activeIndex].scrollIntoView({ block: 'nearest' });
665
+ }
666
+ }
667
+
668
+ // Focus handler
669
+ searchInput.addEventListener('focus', function() {
670
+ if (this.value.length >= 2) {
671
+ const results = search(this.value);
672
+ renderResults(results, this.value);
673
+ }
674
+ });
675
+
676
+ // Click outside to close
677
+ document.addEventListener('click', function(e) {
678
+ if (!e.target.closest('.header-search')) {
679
+ hideResults();
680
+ }
681
+ });
682
+
683
+ // Keyboard shortcut (Ctrl/Cmd + K)
684
+ document.addEventListener('keydown', function(e) {
685
+ if ((e.ctrlKey || e.metaKey) && e.key === 'k') {
686
+ e.preventDefault();
687
+ searchInput.focus();
688
+ searchInput.select();
689
+ }
690
+ });
691
+ }
692
+
693
+ /* ============================================
694
+ COPYABLE COMMANDS (SVG Diagram)
695
+ ============================================ */
696
+
697
+ function initCopyableCommands() {
698
+ const copyableElements = document.querySelectorAll('.cmd-copyable');
699
+
700
+ if (copyableElements.length === 0) return;
701
+
702
+ // Get current language
703
+ function getLang() {
704
+ return document.body.classList.contains('lang-en') ? 'en' : 'fr';
705
+ }
706
+
707
+ // Create floating tooltip for feedback
708
+ const tooltip = document.createElement('div');
709
+ tooltip.className = 'copy-tooltip';
710
+ tooltip.style.cssText = `
711
+ position: fixed;
712
+ background: #22c55e;
713
+ color: white;
714
+ padding: 0.5rem 1rem;
715
+ border-radius: 6px;
716
+ font-size: 0.85rem;
717
+ font-weight: 500;
718
+ z-index: 10000;
719
+ pointer-events: none;
720
+ opacity: 0;
721
+ transition: opacity 0.2s ease;
722
+ box-shadow: 0 4px 12px rgba(0,0,0,0.3);
723
+ `;
724
+ document.body.appendChild(tooltip);
725
+
726
+ copyableElements.forEach(element => {
727
+ // Add hover effect
728
+ element.addEventListener('mouseenter', function() {
729
+ const rect = this.querySelector('rect');
730
+ if (rect) {
731
+ rect.style.filter = 'brightness(1.2)';
732
+ rect.style.transition = 'filter 0.2s ease';
733
+ }
734
+ });
735
+
736
+ element.addEventListener('mouseleave', function() {
737
+ const rect = this.querySelector('rect');
738
+ if (rect) {
739
+ rect.style.filter = '';
740
+ }
741
+ });
742
+
743
+ // Add click handler
744
+ element.addEventListener('click', function(e) {
745
+ e.stopPropagation();
746
+
747
+ const cmd = this.dataset.cmd;
748
+ if (!cmd) return;
749
+
750
+ // Copy to clipboard
751
+ navigator.clipboard.writeText(cmd).then(() => {
752
+ // Show tooltip
753
+ const lang = getLang();
754
+ tooltip.textContent = lang === 'fr' ? '✓ Copié !' : '✓ Copied!';
755
+
756
+ // Position tooltip near cursor
757
+ tooltip.style.left = e.clientX + 10 + 'px';
758
+ tooltip.style.top = e.clientY - 30 + 'px';
759
+ tooltip.style.opacity = '1';
760
+
761
+ // Flash effect on element
762
+ const rect = this.querySelector('rect');
763
+ if (rect) {
764
+ const originalStroke = rect.getAttribute('stroke');
765
+ rect.setAttribute('stroke', '#22c55e');
766
+ rect.style.filter = 'brightness(1.4)';
767
+
768
+ setTimeout(() => {
769
+ rect.setAttribute('stroke', originalStroke);
770
+ rect.style.filter = '';
771
+ }, 300);
772
+ }
773
+
774
+ // Hide tooltip after delay
775
+ setTimeout(() => {
776
+ tooltip.style.opacity = '0';
777
+ }, 1500);
778
+ }).catch(err => {
779
+ console.error('Failed to copy:', err);
780
+ const lang = getLang();
781
+ tooltip.textContent = lang === 'fr' ? '✗ Erreur' : '✗ Error';
782
+ tooltip.style.background = '#ef4444';
783
+ tooltip.style.left = e.clientX + 10 + 'px';
784
+ tooltip.style.top = e.clientY - 30 + 'px';
785
+ tooltip.style.opacity = '1';
786
+
787
+ setTimeout(() => {
788
+ tooltip.style.opacity = '0';
789
+ tooltip.style.background = '#22c55e';
790
+ }, 1500);
791
+ });
792
+ });
793
+ });
794
+ }