qualia-framework 2.1.6 → 2.2.0

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.
Files changed (77) hide show
  1. package/framework/.claudeignore +51 -0
  2. package/framework/CLAUDE.md +54 -0
  3. package/framework/MCP_SETUP.md +229 -0
  4. package/framework/agents/architecture-strategist.md +1 -1
  5. package/framework/agents/code-simplicity-reviewer.md +1 -1
  6. package/framework/agents/kieran-typescript-reviewer.md +1 -1
  7. package/framework/agents/performance-oracle.md +1 -1
  8. package/framework/agents/qualia-codebase-mapper.md +1 -0
  9. package/framework/agents/qualia-debugger.md +1 -0
  10. package/framework/agents/qualia-executor.md +1 -0
  11. package/framework/agents/qualia-integration-checker.md +1 -0
  12. package/framework/agents/qualia-phase-researcher.md +1 -0
  13. package/framework/agents/qualia-plan-checker.md +1 -0
  14. package/framework/agents/qualia-planner.md +1 -0
  15. package/framework/agents/qualia-project-researcher.md +1 -0
  16. package/framework/agents/qualia-research-synthesizer.md +1 -0
  17. package/framework/agents/qualia-roadmapper.md +1 -0
  18. package/framework/agents/qualia-verifier.md +1 -0
  19. package/framework/agents/security-auditor.md +72 -0
  20. package/framework/agents/team-orchestrator.md +1 -0
  21. package/framework/agents/teams/framework-audit-team.md +66 -0
  22. package/framework/agents/teams/review-team.md +11 -3
  23. package/framework/hooks/block-env-edit.sh +4 -8
  24. package/framework/hooks/branch-guard.sh +2 -5
  25. package/framework/hooks/confirm-delete.sh +7 -4
  26. package/framework/hooks/migration-validate.sh +9 -8
  27. package/framework/hooks/notification-speak.sh +1 -1
  28. package/framework/hooks/pre-commit.sh +22 -10
  29. package/framework/hooks/pre-deploy-gate.sh +5 -6
  30. package/framework/hooks/retention-cleanup.sh +11 -2
  31. package/framework/hooks/save-session-state.sh +22 -0
  32. package/framework/hooks/session-context-loader.sh +27 -29
  33. package/framework/hooks/session-learn.sh +6 -5
  34. package/framework/hooks/skill-announce.sh +109 -6
  35. package/framework/hooks/tool-error-announce.sh +16 -7
  36. package/framework/install.ps1 +323 -0
  37. package/framework/install.sh +306 -0
  38. package/framework/qualia-engine/references/completion-checklists.md +359 -0
  39. package/framework/rules/deployment.md +4 -3
  40. package/framework/rules/speed.md +4 -0
  41. package/framework/skills/animate/SKILL.md +1 -1
  42. package/framework/skills/bolder/SKILL.md +1 -1
  43. package/framework/skills/colorize/SKILL.md +1 -1
  44. package/framework/skills/deep-research/SKILL.md +19 -13
  45. package/framework/skills/delight/SKILL.md +1 -1
  46. package/framework/skills/design-quieter/SKILL.md +1 -1
  47. package/framework/skills/distill/SKILL.md +1 -1
  48. package/framework/skills/qualia-audit-milestone/SKILL.md +1 -1
  49. package/framework/skills/qualia-complete-milestone/SKILL.md +2 -2
  50. package/framework/skills/qualia-design/SKILL.md +2 -2
  51. package/framework/skills/qualia-framework-audit/SKILL.md +604 -0
  52. package/framework/skills/qualia-help/SKILL.md +11 -1
  53. package/framework/skills/qualia-pause-work/SKILL.md +2 -2
  54. package/framework/skills/qualia-review/SKILL.md +1 -1
  55. package/framework/skills/qualia-start/SKILL.md +8 -1
  56. package/framework/skills/qualia-verify-work/SKILL.md +1 -1
  57. package/framework/skills/ship/SKILL.md +1 -1
  58. package/framework/statusline-command.sh +5 -6
  59. package/framework/teams/default/inboxes/plan-04.json +9 -0
  60. package/package.json +1 -1
  61. package/framework/askpass.sh +0 -2
  62. package/framework/commands/design.md +0 -53
  63. package/framework/commands/quick-db.md +0 -22
  64. package/framework/config/retention.json +0 -35
  65. package/framework/core/PRINCIPLES.md +0 -77
  66. package/framework/knowledge/claudecode-bible.md +0 -1384
  67. package/framework/knowledge/client-prefs.md +0 -22
  68. package/framework/knowledge/common-fixes.md +0 -25
  69. package/framework/knowledge/deployment-map.md +0 -35
  70. package/framework/knowledge/email-signature.html +0 -1
  71. package/framework/knowledge/employees.md +0 -8
  72. package/framework/knowledge/learned-patterns.md +0 -51
  73. package/framework/knowledge/optimization-research-2026.md +0 -137
  74. package/framework/knowledge/qualia-context.md +0 -67
  75. package/framework/knowledge/supabase-patterns.md +0 -50
  76. package/framework/knowledge/voice-agent-patterns.md +0 -46
  77. package/framework/statusline-command.js +0 -111
@@ -0,0 +1,323 @@
1
+ # Qualia Framework v2.0 — Windows Installer (PowerShell)
2
+ # Usage: git clone <repo> && cd qualia-framework && .\install.ps1
3
+ #
4
+ # Requires: Node.js 18+, Claude Code CLI, PowerShell 5.1+, Git Bash (for hooks)
5
+
6
+ $ErrorActionPreference = "Stop"
7
+
8
+ $ClaudeDir = "$env:USERPROFILE\.claude"
9
+ $ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
10
+
11
+ Write-Host ""
12
+ Write-Host " --- " -ForegroundColor Cyan -NoNewline
13
+ Write-Host "* QUALIA FRAMEWORK v2.0" -ForegroundColor Cyan
14
+ Write-Host ""
15
+
16
+ # ─── Step 1: Verify source ───
17
+ if (-not (Test-Path "$ScriptDir\skills") -or -not (Test-Path "$ScriptDir\agents")) {
18
+ Write-Host " x Run this script from the qualia-framework directory." -ForegroundColor Red
19
+ exit 1
20
+ }
21
+
22
+ Write-Host "[1/6] Prerequisites" -ForegroundColor Yellow
23
+
24
+ # Check Claude Code
25
+ try {
26
+ $null = Get-Command claude -ErrorAction Stop
27
+ Write-Host " + Claude Code CLI" -ForegroundColor Green
28
+ } catch {
29
+ Write-Host " x Claude Code CLI not found" -ForegroundColor Red
30
+ Write-Host " npm install -g @anthropic-ai/claude-code"
31
+ exit 1
32
+ }
33
+
34
+ # Check Node.js
35
+ try {
36
+ $nodeVersion = node -v
37
+ Write-Host " + Node.js $nodeVersion" -ForegroundColor Green
38
+ } catch {
39
+ Write-Host " x Node.js not found" -ForegroundColor Red
40
+ exit 1
41
+ }
42
+
43
+ # Check Git Bash (required for hooks)
44
+ $gitBash = Get-Command bash -ErrorAction SilentlyContinue
45
+ if ($gitBash) {
46
+ Write-Host " + Git Bash found (hooks will work)" -ForegroundColor Green
47
+ } else {
48
+ Write-Host " ! Git Bash NOT found — hooks require bash" -ForegroundColor Yellow
49
+ Write-Host " Install Git for Windows: https://git-scm.com/download/win"
50
+ Write-Host " Hooks will not fire without bash in PATH" -ForegroundColor Yellow
51
+ }
52
+
53
+ # ─── Step 1b: Role selection ───
54
+ Write-Host ""
55
+ Write-Host " Who are you?" -ForegroundColor Cyan
56
+ Write-Host ""
57
+ Write-Host " 1) Fawzi (Owner - full access)" -ForegroundColor White
58
+ Write-Host " 2) Employee (Team member)" -ForegroundColor White
59
+ Write-Host ""
60
+ $roleChoice = Read-Host " Select [1/2]"
61
+
62
+ switch ($roleChoice) {
63
+ "1" {
64
+ $Role = "owner"
65
+ $RoleName = "Fawzi"
66
+ Write-Host " + Owner mode" -ForegroundColor Green
67
+ }
68
+ "2" {
69
+ $RoleName = Read-Host " Enter your name"
70
+ $Role = "employee"
71
+ Write-Host " + Employee mode - $RoleName" -ForegroundColor Green
72
+ }
73
+ default {
74
+ $Role = "employee"
75
+ $RoleName = "Team Member"
76
+ Write-Host " ! Defaulting to employee mode" -ForegroundColor Yellow
77
+ }
78
+ }
79
+ Write-Host ""
80
+
81
+ # ─── Step 2: Create directory structure ───
82
+ Write-Host "[2/6] Directory structure" -ForegroundColor Yellow
83
+
84
+ $dirs = @(
85
+ "$ClaudeDir\skills",
86
+ "$ClaudeDir\agents\teams",
87
+ "$ClaudeDir\hooks",
88
+ "$ClaudeDir\rules",
89
+ "$ClaudeDir\knowledge\retros",
90
+ "$ClaudeDir\qualia-engine\bin",
91
+ "$ClaudeDir\qualia-engine\references",
92
+ "$ClaudeDir\qualia-engine\templates",
93
+ "$ClaudeDir\qualia-engine\workflows",
94
+ "$ClaudeDir\projects",
95
+ "$ClaudeDir\session-env"
96
+ )
97
+
98
+ foreach ($dir in $dirs) {
99
+ if (-not (Test-Path $dir)) {
100
+ New-Item -ItemType Directory -Path $dir -Force | Out-Null
101
+ }
102
+ }
103
+ Write-Host " + Ready" -ForegroundColor Green
104
+
105
+ # ─── Step 3: Copy framework files ───
106
+ Write-Host "[3/6] Installing files" -ForegroundColor Yellow
107
+
108
+ # Skills
109
+ $skillCount = 0
110
+ Get-ChildItem "$ScriptDir\skills" -Directory | ForEach-Object {
111
+ $destDir = "$ClaudeDir\skills\$($_.Name)"
112
+ if (-not (Test-Path $destDir)) { New-Item -ItemType Directory -Path $destDir -Force | Out-Null }
113
+ Copy-Item "$($_.FullName)\*" $destDir -Recurse -Force -ErrorAction SilentlyContinue
114
+ $skillCount++
115
+ }
116
+ Write-Host " + $skillCount skills" -ForegroundColor Green
117
+
118
+ # Agents
119
+ Copy-Item "$ScriptDir\agents\*.md" "$ClaudeDir\agents\" -Force -ErrorAction SilentlyContinue
120
+ if (Test-Path "$ScriptDir\agents\teams") {
121
+ Copy-Item "$ScriptDir\agents\teams\*.md" "$ClaudeDir\agents\teams\" -Force -ErrorAction SilentlyContinue
122
+ }
123
+ $agentCount = (Get-ChildItem "$ClaudeDir\agents\*.md" -ErrorAction SilentlyContinue).Count
124
+ Write-Host " + $agentCount agents" -ForegroundColor Green
125
+
126
+ # Hooks
127
+ Copy-Item "$ScriptDir\hooks\*.sh" "$ClaudeDir\hooks\" -Force -ErrorAction SilentlyContinue
128
+ $hookCount = (Get-ChildItem "$ClaudeDir\hooks\*.sh" -ErrorAction SilentlyContinue).Count
129
+ Write-Host " + $hookCount hooks" -ForegroundColor Green
130
+
131
+ # Qualia Engine
132
+ Copy-Item "$ScriptDir\qualia-engine\*" "$ClaudeDir\qualia-engine\" -Recurse -Force -ErrorAction SilentlyContinue
133
+ Write-Host " + Qualia engine" -ForegroundColor Green
134
+
135
+ # Rules
136
+ Copy-Item "$ScriptDir\rules\*.md" "$ClaudeDir\rules\" -Force -ErrorAction SilentlyContinue
137
+ $ruleCount = (Get-ChildItem "$ClaudeDir\rules\*.md" -ErrorAction SilentlyContinue).Count
138
+ Write-Host " + $ruleCount rules" -ForegroundColor Green
139
+
140
+ # Knowledge
141
+ Copy-Item "$ScriptDir\knowledge\*.md" "$ClaudeDir\knowledge\" -Force -ErrorAction SilentlyContinue
142
+ $knowledgeCount = (Get-ChildItem "$ClaudeDir\knowledge\*.md" -ErrorAction SilentlyContinue).Count
143
+ Write-Host " + $knowledgeCount knowledge files" -ForegroundColor Green
144
+
145
+ # Statusline
146
+ if (Test-Path "$ScriptDir\statusline-command.sh") {
147
+ Copy-Item "$ScriptDir\statusline-command.sh" "$ClaudeDir\statusline-command.sh" -Force
148
+ }
149
+
150
+ # CLAUDE.md — role-based
151
+ if ($Role -eq "owner") {
152
+ Copy-Item "$ScriptDir\CLAUDE.md" "$ClaudeDir\CLAUDE.md" -Force
153
+ Write-Host " + CLAUDE.md (owner)" -ForegroundColor Green
154
+ } elseif (-not (Test-Path "$ClaudeDir\CLAUDE.md")) {
155
+ @"
156
+ # CLAUDE.md - DEVELOPER Profile
157
+
158
+ ## Identity
159
+ **$RoleName** - Developer at Qualia Solutions.
160
+
161
+ - Stack: Next.js 16+, React 19, TypeScript, Supabase, Vercel
162
+
163
+ ## Role: DEVELOPER
164
+
165
+ You are a developer at Qualia Solutions, working under Fawzi Goussous (founder).
166
+ - Work on feature branches only - never push to main/master
167
+ - Submit PRs for review before merging
168
+ - Do NOT deploy to production - Fawzi handles deploys
169
+ - Cannot modify the Qualia framework (CLAUDE.md, skills, hooks)
170
+
171
+ ## Rules
172
+ - Read before Write/Edit - no exceptions
173
+ - Feature branches only - never commit to main/master
174
+ - MVP first. Build only what's asked. No over-engineering.
175
+ - ``npx tsc --noEmit`` after multi-file TS changes
176
+ - See ``rules/security.md`` for auth, RLS, Zod, secrets rules
177
+
178
+ ## Workflow
179
+ - **MANDATORY FIRST ACTION**: On every session start, invoke the ``qualia-start`` skill before doing anything else.
180
+ - Run ``/qualia-review`` before deploying anything
181
+ - Run ``/browser-qa`` after frontend changes
182
+
183
+ ## Qualia Mode (always active)
184
+ These behaviors apply to ALL interactions:
185
+ - **Frontend guard:** Read .planning/DESIGN.md before any frontend file changes
186
+ - **Deploy guard:** Check .planning/REVIEW.md freshness before any deploy command
187
+ - **Intent verification:** Confirm before modifying 3+ files in one response
188
+ - **Quality defaults:** Security rules, tsc checks, RLS consideration - always enforced
189
+
190
+ ## Compaction - ALWAYS preserve:
191
+ Project path/name/ref, branch, modified files, decisions, test results, in-progress work, errors.
192
+ "@ | Out-File -FilePath "$ClaudeDir\CLAUDE.md" -Encoding utf8
193
+ Write-Host " + CLAUDE.md (developer - $RoleName)" -ForegroundColor Green
194
+ } else {
195
+ Write-Host " ! CLAUDE.md exists - skipped" -ForegroundColor Yellow
196
+ }
197
+
198
+ # ─── Step 4: Configure settings.json ───
199
+ Write-Host "[4/6] Settings" -ForegroundColor Yellow
200
+
201
+ if (Test-Path "$ClaudeDir\settings.json") {
202
+ $timestamp = Get-Date -Format "yyyyMMddHHmmss"
203
+ Copy-Item "$ClaudeDir\settings.json" "$ClaudeDir\settings.json.backup.$timestamp"
204
+ Write-Host " Backed up existing settings" -ForegroundColor DarkGray
205
+
206
+ # Write merge script to temp file (avoid /dev/stdin issue on Windows)
207
+ $claudeDirForward = $ClaudeDir -replace '\\', '/'
208
+ $scriptDirForward = $ScriptDir -replace '\\', '/'
209
+ $mergeScript = @"
210
+ const fs = require('fs');
211
+ const existing = JSON.parse(fs.readFileSync('$claudeDirForward/settings.json', 'utf8'));
212
+ const template = JSON.parse(fs.readFileSync('$scriptDirForward/settings.json', 'utf8'));
213
+ existing.env = { ...template.env, ...existing.env };
214
+ for (const [event, matchers] of Object.entries(template.hooks || {})) {
215
+ if (!existing.hooks) existing.hooks = {};
216
+ if (!existing.hooks[event]) {
217
+ existing.hooks[event] = matchers;
218
+ } else {
219
+ for (const matcher of matchers) {
220
+ const exists = existing.hooks[event].some(m =>
221
+ m.matcher === matcher.matcher && JSON.stringify(m.hooks) === JSON.stringify(matcher.hooks)
222
+ );
223
+ if (!exists) existing.hooks[event].push(matcher);
224
+ }
225
+ }
226
+ }
227
+ fs.writeFileSync('$claudeDirForward/settings.json', JSON.stringify(existing, null, 2));
228
+ console.log('OK');
229
+ "@
230
+ try {
231
+ $tempFile = [System.IO.Path]::GetTempFileName() -replace '\.tmp$', '.js'
232
+ $mergeScript | Out-File -FilePath $tempFile -Encoding utf8
233
+ $result = node $tempFile 2>&1
234
+ Remove-Item $tempFile -ErrorAction SilentlyContinue
235
+ if ($result -match "OK") {
236
+ Write-Host " + Settings merged" -ForegroundColor Green
237
+ } else {
238
+ Write-Host " ! Settings merge issue: $result" -ForegroundColor Yellow
239
+ }
240
+ } catch {
241
+ Write-Host " ! Settings merge failed - manual merge needed" -ForegroundColor Yellow
242
+ }
243
+ } else {
244
+ Copy-Item "$ScriptDir\settings.json" "$ClaudeDir\settings.json" -Force
245
+ Write-Host " + Settings installed" -ForegroundColor Green
246
+ }
247
+
248
+ # ─── Step 5: Windows-specific ───
249
+ Write-Host "[5/6] Platform setup" -ForegroundColor Yellow
250
+
251
+ # qualia-tools.js doesn't need chmod on Windows
252
+ Write-Host " + Tools ready" -ForegroundColor Green
253
+
254
+ if (-not $gitBash) {
255
+ Write-Host ""
256
+ Write-Host " IMPORTANT: Install Git for Windows to enable hooks" -ForegroundColor Yellow
257
+ Write-Host " https://git-scm.com/download/win" -ForegroundColor DarkGray
258
+ Write-Host " After install, ensure 'bash' is in your PATH" -ForegroundColor DarkGray
259
+ }
260
+
261
+ # ─── Step 6: Verify ───
262
+ Write-Host "[6/6] Verifying" -ForegroundColor Yellow
263
+
264
+ $errors = 0
265
+
266
+ $criticalFiles = @(
267
+ "agents\qualia-executor.md",
268
+ "agents\qualia-planner.md",
269
+ "agents\qualia-verifier.md",
270
+ "hooks\pre-deploy-gate.sh",
271
+ "hooks\branch-guard.sh",
272
+ "hooks\qualia-colors.sh",
273
+ "skills\qualia-start\SKILL.md",
274
+ "skills\browser-qa\SKILL.md",
275
+ "skills\ship\SKILL.md",
276
+ "qualia-engine\bin\qualia-tools.js",
277
+ "CLAUDE.md"
278
+ )
279
+
280
+ foreach ($file in $criticalFiles) {
281
+ if (-not (Test-Path "$ClaudeDir\$file")) {
282
+ Write-Host " x Missing: $file" -ForegroundColor Red
283
+ $errors++
284
+ }
285
+ }
286
+
287
+ # Check node available
288
+ try {
289
+ $null = Get-Command node -ErrorAction Stop
290
+ } catch {
291
+ Write-Host " x node not in PATH - hooks will fail" -ForegroundColor Red
292
+ $errors++
293
+ }
294
+
295
+ if ($errors -gt 0) {
296
+ Write-Host ""
297
+ Write-Host " x $errors error(s) - check above" -ForegroundColor Red
298
+ exit 1
299
+ }
300
+
301
+ Write-Host " + All checks passed" -ForegroundColor Green
302
+
303
+ # ─── Summary ───
304
+ Write-Host ""
305
+ Write-Host " --- * INSTALLED" -ForegroundColor Cyan
306
+ Write-Host ""
307
+ Write-Host " Skills: $skillCount Agents: $agentCount Hooks: $hookCount Rules: $ruleCount" -ForegroundColor White
308
+ Write-Host ""
309
+ Write-Host " Quick Start:" -ForegroundColor Cyan
310
+ Write-Host " 1. cd into any project"
311
+ Write-Host " 2. Run: " -NoNewline; Write-Host "claude" -ForegroundColor Cyan
312
+ Write-Host " 3. Qualia mode activates automatically"
313
+ Write-Host ""
314
+ Write-Host " Key Commands:" -ForegroundColor Cyan
315
+ Write-Host " /qualia Smart router"
316
+ Write-Host " /qualia-help All commands"
317
+ Write-Host " /ship Full deploy pipeline"
318
+ Write-Host " /pr Quick pull request"
319
+ Write-Host ""
320
+ if (-not $gitBash) {
321
+ Write-Host " ! Hooks need Git Bash - install Git for Windows" -ForegroundColor Yellow
322
+ }
323
+ Write-Host ""
@@ -0,0 +1,306 @@
1
+ #!/bin/bash
2
+ # Qualia Framework v2.0 — Linux Installer
3
+ # Usage: git clone <repo> && cd qualia-framework && ./install.sh
4
+ #
5
+ # Tested on: Ubuntu 22.04+, Pop!_OS 22.04+, Endeavour OS (Arch), Cosmic
6
+ # Requires: Node.js 18+, Claude Code CLI, bash 4+
7
+ #
8
+ # What it does:
9
+ # 1. Copies all framework files to ~/.claude/
10
+ # 2. Sets up hooks, agents, skills, engine, knowledge, rules
11
+ # 3. Configures settings.json (merges with existing)
12
+ # 4. Makes hooks executable
13
+ # 5. Verifies installation
14
+
15
+ set -euo pipefail
16
+
17
+ # Colors (Qualia teal palette)
18
+ Q_TEAL='\033[38;2;0;188;175m'
19
+ Q_BRIGHT='\033[38;2;45;226;210m'
20
+ Q_PASS='\033[38;2;52;211;153m'
21
+ Q_WARN='\033[38;2;234;179;8m'
22
+ Q_FAIL='\033[38;2;239;68;68m'
23
+ Q_WHITE='\033[38;2;220;225;230m'
24
+ Q_DIM='\033[38;2;70;78;88m'
25
+ Q_RESET='\033[0m'
26
+
27
+ CLAUDE_DIR="$HOME/.claude"
28
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
29
+
30
+ printf "\n"
31
+ printf "${Q_TEAL}━━━${Q_RESET} ${Q_BRIGHT}◆ QUALIA FRAMEWORK v2.0${Q_RESET}\n"
32
+ printf "\n"
33
+
34
+ # ─── Step 1: Verify source ───
35
+ if [ ! -d "$SCRIPT_DIR/skills" ] || [ ! -d "$SCRIPT_DIR/agents" ]; then
36
+ printf "${Q_FAIL} ✗ Run this script from the qualia-framework directory.${Q_RESET}\n"
37
+ exit 1
38
+ fi
39
+
40
+ printf "${Q_WARN}[1/6] Prerequisites${Q_RESET}\n"
41
+
42
+ # Check Claude Code
43
+ if ! command -v claude >/dev/null 2>&1; then
44
+ printf "${Q_FAIL} ✗ Claude Code CLI not found${Q_RESET}\n"
45
+ printf " npm install -g @anthropic-ai/claude-code\n"
46
+ exit 1
47
+ fi
48
+ printf "${Q_PASS} ✓ Claude Code CLI${Q_RESET}\n"
49
+
50
+ # Check Node.js
51
+ if ! command -v node >/dev/null 2>&1; then
52
+ printf "${Q_FAIL} ✗ Node.js not found${Q_RESET}\n"
53
+ exit 1
54
+ fi
55
+ printf "${Q_PASS} ✓ Node.js $(node -v)${Q_RESET}\n"
56
+
57
+ # Check optional deps
58
+ command -v jq >/dev/null 2>&1 && printf "${Q_PASS} ✓ jq${Q_RESET}\n" || printf "${Q_WARN} ▲ jq not found (optional — deploy-verify scripts need it)${Q_RESET}\n"
59
+ command -v bc >/dev/null 2>&1 && printf "${Q_PASS} ✓ bc${Q_RESET}\n" || printf "${Q_WARN} ▲ bc not found (optional — install: pacman -S bc / apt install bc)${Q_RESET}\n"
60
+
61
+ # ─── Step 1b: Role selection ───
62
+ printf "\n${Q_BRIGHT}Who are you?${Q_RESET}\n\n"
63
+ printf " 1) ${Q_WHITE}Fawzi${Q_RESET} (Owner — full access)\n"
64
+ printf " 2) ${Q_WHITE}Employee${Q_RESET} (Team member — guided workflow)\n\n"
65
+
66
+ # Read from terminal even if script is piped
67
+ read -rp "Select [1/2]: " ROLE_CHOICE </dev/tty
68
+
69
+ case "$ROLE_CHOICE" in
70
+ 1)
71
+ ROLE="owner"
72
+ ROLE_NAME="Fawzi"
73
+ printf "${Q_PASS} ✓ Owner mode${Q_RESET}\n"
74
+ ;;
75
+ 2)
76
+ read -rp "Enter your name: " EMPLOYEE_NAME </dev/tty
77
+ ROLE="employee"
78
+ ROLE_NAME="$EMPLOYEE_NAME"
79
+ printf "${Q_PASS} ✓ Employee mode — $ROLE_NAME${Q_RESET}\n"
80
+ ;;
81
+ *)
82
+ ROLE="employee"
83
+ ROLE_NAME="Team Member"
84
+ printf "${Q_WARN} ▲ Defaulting to employee mode${Q_RESET}\n"
85
+ ;;
86
+ esac
87
+
88
+ printf "\n"
89
+
90
+ # ─── Step 2: Create directory structure ───
91
+ printf "${Q_WARN}[2/6] Directory structure${Q_RESET}\n"
92
+
93
+ mkdir -p "$CLAUDE_DIR"/{skills,agents,hooks,rules,knowledge/retros,qualia-engine/{bin,references,templates,workflows},projects,session-env}
94
+
95
+ printf "${Q_PASS} ✓ Ready${Q_RESET}\n"
96
+
97
+ # ─── Step 3: Copy framework files ───
98
+ printf "${Q_WARN}[3/6] Installing files${Q_RESET}\n"
99
+
100
+ # Skills
101
+ SKILL_COUNT=0
102
+ for skill_dir in "$SCRIPT_DIR"/skills/*/; do
103
+ skill_name=$(basename "$skill_dir")
104
+ mkdir -p "$CLAUDE_DIR/skills/$skill_name"
105
+ cp -r "$skill_dir"* "$CLAUDE_DIR/skills/$skill_name/" 2>/dev/null || true
106
+ SKILL_COUNT=$((SKILL_COUNT + 1))
107
+ done
108
+ printf "${Q_PASS} ✓ $SKILL_COUNT skills${Q_RESET}\n"
109
+
110
+ # Agents
111
+ cp "$SCRIPT_DIR"/agents/*.md "$CLAUDE_DIR/agents/" 2>/dev/null || true
112
+ if [ -d "$SCRIPT_DIR/agents/teams" ]; then
113
+ mkdir -p "$CLAUDE_DIR/agents/teams"
114
+ cp "$SCRIPT_DIR"/agents/teams/*.md "$CLAUDE_DIR/agents/teams/" 2>/dev/null || true
115
+ fi
116
+ AGENT_COUNT=$(find "$CLAUDE_DIR/agents" -maxdepth 1 -name "*.md" -type f | wc -l)
117
+ printf "${Q_PASS} ✓ $AGENT_COUNT agents${Q_RESET}\n"
118
+
119
+ # Hooks
120
+ cp "$SCRIPT_DIR"/hooks/*.sh "$CLAUDE_DIR/hooks/" 2>/dev/null || true
121
+ chmod +x "$CLAUDE_DIR"/hooks/*.sh
122
+ HOOK_COUNT=$(find "$CLAUDE_DIR/hooks" -name "*.sh" -type f | wc -l)
123
+ printf "${Q_PASS} ✓ $HOOK_COUNT hooks${Q_RESET}\n"
124
+
125
+ # Qualia Engine
126
+ cp -r "$SCRIPT_DIR"/qualia-engine/* "$CLAUDE_DIR/qualia-engine/" 2>/dev/null || true
127
+ printf "${Q_PASS} ✓ Qualia engine${Q_RESET}\n"
128
+
129
+ # Rules
130
+ cp "$SCRIPT_DIR"/rules/*.md "$CLAUDE_DIR/rules/" 2>/dev/null || true
131
+ RULE_COUNT=$(find "$CLAUDE_DIR/rules" -name "*.md" -type f | wc -l)
132
+ printf "${Q_PASS} ✓ $RULE_COUNT rules${Q_RESET}\n"
133
+
134
+ # Knowledge base
135
+ cp "$SCRIPT_DIR"/knowledge/*.md "$CLAUDE_DIR/knowledge/" 2>/dev/null || true
136
+ KNOWLEDGE_COUNT=$(find "$CLAUDE_DIR/knowledge" -maxdepth 1 -name "*.md" -type f | wc -l)
137
+ printf "${Q_PASS} ✓ $KNOWLEDGE_COUNT knowledge files${Q_RESET}\n"
138
+
139
+ # Statusline
140
+ [ -f "$SCRIPT_DIR/statusline-command.sh" ] && cp "$SCRIPT_DIR/statusline-command.sh" "$CLAUDE_DIR/statusline-command.sh" && chmod +x "$CLAUDE_DIR/statusline-command.sh"
141
+
142
+ # CLAUDE.md — role-based
143
+ if [ "$ROLE" = "owner" ]; then
144
+ cp "$SCRIPT_DIR/CLAUDE.md" "$CLAUDE_DIR/CLAUDE.md"
145
+ printf "${Q_PASS} ✓ CLAUDE.md (owner)${Q_RESET}\n"
146
+ elif [ ! -f "$CLAUDE_DIR/CLAUDE.md" ]; then
147
+ cat > "$CLAUDE_DIR/CLAUDE.md" << EMPLOYEE_EOF
148
+ # CLAUDE.md — DEVELOPER Profile
149
+
150
+ ## Identity
151
+ **$ROLE_NAME** — Developer at Qualia Solutions.
152
+
153
+ - Stack: Next.js 16+, React 19, TypeScript, Supabase, Vercel, VAPI, ElevenLabs, Telnyx, Retell AI, OpenRouter
154
+
155
+ ## Role: DEVELOPER
156
+
157
+ You are a developer at Qualia Solutions, working under Fawzi Goussous (founder).
158
+ - Work on feature branches only — never push to main/master
159
+ - Submit PRs for review before merging
160
+ - Do NOT deploy to production — Fawzi handles deploys
161
+ - Cannot modify the Qualia framework (CLAUDE.md, skills, hooks)
162
+ - Ask Fawzi when unsure about architecture decisions
163
+
164
+ ## Rules
165
+ - Read before Write/Edit — no exceptions
166
+ - Feature branches only — never commit to main/master
167
+ - MVP first. Build only what's asked. No over-engineering.
168
+ - \`npx tsc --noEmit\` after multi-file TS changes
169
+ - See \`rules/security.md\` for auth, RLS, Zod, secrets rules
170
+ - See \`rules/frontend.md\` for design standards
171
+
172
+ ## Workflow
173
+ - **MANDATORY FIRST ACTION**: On every session start, invoke the \`qualia-start\` skill before doing anything else.
174
+ - Run \`/qualia-review\` before deploying anything
175
+ - Run \`/browser-qa\` after frontend changes
176
+ - Ask for help if stuck — don't guess
177
+
178
+ ## Qualia Mode (always active)
179
+ These behaviors apply to ALL interactions:
180
+ - **Frontend guard:** Read .planning/DESIGN.md before any frontend file changes
181
+ - **Deploy guard:** Check .planning/REVIEW.md freshness before any deploy command
182
+ - **Intent verification:** Confirm before modifying 3+ files in one response
183
+ - **Quality defaults:** Security rules, tsc checks, RLS consideration — always enforced
184
+
185
+ ## Compaction — ALWAYS preserve:
186
+ Project path/name/ref, branch, modified files, decisions, test results, in-progress work, errors, Qualia mode active/inactive state.
187
+ EMPLOYEE_EOF
188
+ printf "${Q_PASS} ✓ CLAUDE.md (developer — $ROLE_NAME)${Q_RESET}\n"
189
+ else
190
+ printf "${Q_WARN} ▲ CLAUDE.md exists — skipped${Q_RESET}\n"
191
+ fi
192
+
193
+ # ─── Step 4: Configure settings.json ───
194
+ printf "${Q_WARN}[4/6] Settings${Q_RESET}\n"
195
+
196
+ if [ -f "$CLAUDE_DIR/settings.json" ]; then
197
+ cp "$CLAUDE_DIR/settings.json" "$CLAUDE_DIR/settings.json.backup.$(date +%s)"
198
+ printf "${Q_DIM} Backed up existing settings${Q_RESET}\n"
199
+
200
+ node -e "
201
+ const fs = require('fs');
202
+ const existing = JSON.parse(fs.readFileSync('$CLAUDE_DIR/settings.json', 'utf8'));
203
+ const template = JSON.parse(fs.readFileSync('$SCRIPT_DIR/settings.json', 'utf8'));
204
+ existing.env = { ...template.env, ...existing.env };
205
+ for (const [event, matchers] of Object.entries(template.hooks || {})) {
206
+ if (!existing.hooks) existing.hooks = {};
207
+ if (!existing.hooks[event]) {
208
+ existing.hooks[event] = matchers;
209
+ } else {
210
+ for (const matcher of matchers) {
211
+ const exists = existing.hooks[event].some(m =>
212
+ m.matcher === matcher.matcher &&
213
+ JSON.stringify(m.hooks) === JSON.stringify(matcher.hooks)
214
+ );
215
+ if (!exists) existing.hooks[event].push(matcher);
216
+ }
217
+ }
218
+ }
219
+ fs.writeFileSync('$CLAUDE_DIR/settings.json', JSON.stringify(existing, null, 2));
220
+ " 2>/dev/null && printf "${Q_PASS} ✓ Settings merged${Q_RESET}\n" || printf "${Q_WARN} ▲ Settings merge failed — manual merge needed${Q_RESET}\n"
221
+ else
222
+ cp "$SCRIPT_DIR/settings.json" "$CLAUDE_DIR/settings.json"
223
+ printf "${Q_PASS} ✓ Settings installed${Q_RESET}\n"
224
+ fi
225
+
226
+ # ─── Step 5: Platform setup ───
227
+ printf "${Q_WARN}[5/6] Platform setup${Q_RESET}\n"
228
+
229
+ # Make qualia-tools executable
230
+ [ -f "$CLAUDE_DIR/qualia-engine/bin/qualia-tools.js" ] && chmod +x "$CLAUDE_DIR/qualia-engine/bin/qualia-tools.js"
231
+
232
+ # Askpass helper (works with zenity, kdialog, or falls back to terminal)
233
+ if [ ! -f "$CLAUDE_DIR/askpass.sh" ]; then
234
+ cat > "$CLAUDE_DIR/askpass.sh" << 'ASKPASS_EOF'
235
+ #!/bin/bash
236
+ if command -v zenity >/dev/null 2>&1; then
237
+ zenity --password --title="sudo password" 2>/dev/null
238
+ elif command -v kdialog >/dev/null 2>&1; then
239
+ kdialog --password "sudo password" 2>/dev/null
240
+ else
241
+ read -rsp "Password: " pass </dev/tty
242
+ echo "$pass"
243
+ fi
244
+ ASKPASS_EOF
245
+ chmod +x "$CLAUDE_DIR/askpass.sh"
246
+ fi
247
+
248
+ printf "${Q_PASS} ✓ Tools ready${Q_RESET}\n"
249
+
250
+ # Detect distro
251
+ if [ -f /etc/os-release ]; then
252
+ DISTRO=$(grep -oP '(?<=^ID=).+' /etc/os-release | tr -d '"')
253
+ printf "${Q_DIM} Detected: $DISTRO${Q_RESET}\n"
254
+ fi
255
+
256
+ # ─── Step 6: Verify ───
257
+ printf "${Q_WARN}[6/6] Verifying${Q_RESET}\n"
258
+
259
+ ERRORS=0
260
+
261
+ for check in \
262
+ "agents/qualia-executor.md" \
263
+ "agents/qualia-planner.md" \
264
+ "agents/qualia-verifier.md" \
265
+ "hooks/pre-deploy-gate.sh" \
266
+ "hooks/branch-guard.sh" \
267
+ "hooks/qualia-colors.sh" \
268
+ "skills/qualia-start/SKILL.md" \
269
+ "skills/browser-qa/SKILL.md" \
270
+ "skills/ship/SKILL.md" \
271
+ "qualia-engine/bin/qualia-tools.js" \
272
+ "CLAUDE.md"; do
273
+ if [ ! -f "$CLAUDE_DIR/$check" ]; then
274
+ printf "${Q_FAIL} ✗ Missing: $check${Q_RESET}\n"
275
+ ERRORS=$((ERRORS + 1))
276
+ fi
277
+ done
278
+
279
+ # Check hooks executable
280
+ for hook in "$CLAUDE_DIR"/hooks/*.sh; do
281
+ [ -x "$hook" ] || { printf "${Q_FAIL} ✗ Not executable: $(basename "$hook")${Q_RESET}\n"; ERRORS=$((ERRORS + 1)); }
282
+ done
283
+
284
+ # Check node available for hooks
285
+ command -v node >/dev/null 2>&1 || { printf "${Q_FAIL} ✗ node not in PATH — hooks will silently fail${Q_RESET}\n"; ERRORS=$((ERRORS + 1)); }
286
+
287
+ if [ "$ERRORS" -gt 0 ]; then
288
+ printf "\n${Q_FAIL} ✗ $ERRORS error(s) — check above${Q_RESET}\n"
289
+ exit 1
290
+ fi
291
+
292
+ printf "${Q_PASS} ✓ All checks passed${Q_RESET}\n"
293
+
294
+ # ─── Summary ───
295
+ printf "\n"
296
+ printf "${Q_TEAL}━━━${Q_RESET} ${Q_BRIGHT}◆ INSTALLED${Q_RESET}\n\n"
297
+ printf " ${Q_WHITE}Skills: $SKILL_COUNT Agents: $AGENT_COUNT Hooks: $HOOK_COUNT Rules: $RULE_COUNT${Q_RESET}\n\n"
298
+ printf " ${Q_BRIGHT}Quick Start:${Q_RESET}\n"
299
+ printf " 1. ${Q_DIM}cd${Q_RESET} into any project\n"
300
+ printf " 2. Run ${Q_TEAL}claude${Q_RESET}\n"
301
+ printf " 3. Qualia mode activates automatically\n\n"
302
+ printf " ${Q_BRIGHT}Key Commands:${Q_RESET}\n"
303
+ printf " ${Q_TEAL}/qualia${Q_RESET} Smart router — tells you what to do next\n"
304
+ printf " ${Q_TEAL}/qualia-help${Q_RESET} All available commands\n"
305
+ printf " ${Q_TEAL}/ship${Q_RESET} Full deploy pipeline\n"
306
+ printf " ${Q_TEAL}/pr${Q_RESET} Quick pull request\n\n"