qwen-base 1.0.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 (71) hide show
  1. package/README.md +183 -0
  2. package/bin/install.js +227 -0
  3. package/package.json +42 -0
  4. package/src/commands/audit-claude-md.md +44 -0
  5. package/src/commands/audit-claude.md +45 -0
  6. package/src/commands/audit.md +33 -0
  7. package/src/commands/carl-hygiene.md +33 -0
  8. package/src/commands/groom.md +35 -0
  9. package/src/commands/history.md +27 -0
  10. package/src/commands/orientation/tasks/deep-why.md +132 -0
  11. package/src/commands/orientation/tasks/elevator-pitch.md +115 -0
  12. package/src/commands/orientation/tasks/initiatives.md +98 -0
  13. package/src/commands/orientation/tasks/key-values.md +130 -0
  14. package/src/commands/orientation/tasks/new-orientation.md +162 -0
  15. package/src/commands/orientation/tasks/north-star.md +97 -0
  16. package/src/commands/orientation/tasks/project-mapping.md +103 -0
  17. package/src/commands/orientation/tasks/reorientation.md +96 -0
  18. package/src/commands/orientation/tasks/surface-vision.md +113 -0
  19. package/src/commands/orientation/tasks/task-seeding.md +93 -0
  20. package/src/commands/orientation/templates/operator-json.md +88 -0
  21. package/src/commands/orientation.md +87 -0
  22. package/src/commands/pulse.md +33 -0
  23. package/src/commands/scaffold.md +33 -0
  24. package/src/commands/status.md +28 -0
  25. package/src/commands/surface-convert.md +35 -0
  26. package/src/commands/surface-create.md +34 -0
  27. package/src/commands/surface-list.md +27 -0
  28. package/src/commands/weekly-domain.md +34 -0
  29. package/src/commands/weekly.md +39 -0
  30. package/src/framework/context/base-principles.md +69 -0
  31. package/src/framework/frameworks/audit-strategies.md +53 -0
  32. package/src/framework/frameworks/claude-config-alignment.md +256 -0
  33. package/src/framework/frameworks/claudemd-strategy.md +158 -0
  34. package/src/framework/frameworks/satellite-registration.md +44 -0
  35. package/src/framework/tasks/audit-claude-md.md +171 -0
  36. package/src/framework/tasks/audit-claude.md +330 -0
  37. package/src/framework/tasks/audit.md +64 -0
  38. package/src/framework/tasks/carl-hygiene.md +142 -0
  39. package/src/framework/tasks/groom.md +157 -0
  40. package/src/framework/tasks/history.md +34 -0
  41. package/src/framework/tasks/pulse.md +83 -0
  42. package/src/framework/tasks/scaffold.md +389 -0
  43. package/src/framework/tasks/status.md +35 -0
  44. package/src/framework/tasks/surface-convert.md +143 -0
  45. package/src/framework/tasks/surface-create.md +184 -0
  46. package/src/framework/tasks/surface-list.md +42 -0
  47. package/src/framework/tasks/weekly-domain-create.md +173 -0
  48. package/src/framework/tasks/weekly.md +347 -0
  49. package/src/framework/templates/claudemd-template.md +102 -0
  50. package/src/framework/templates/workspace-json.md +96 -0
  51. package/src/framework/utils/scan-claude-dirs.py +549 -0
  52. package/src/hooks/_template.py +130 -0
  53. package/src/hooks/active-hook.py +178 -0
  54. package/src/hooks/apex-insights.py +169 -0
  55. package/src/hooks/backlog-hook.py +115 -0
  56. package/src/hooks/base-pulse-check.py +216 -0
  57. package/src/hooks/operator.py +53 -0
  58. package/src/hooks/psmm-injector.py +67 -0
  59. package/src/hooks/satellite-detection.py +320 -0
  60. package/src/packages/base-mcp/index.js +119 -0
  61. package/src/packages/base-mcp/package.json +10 -0
  62. package/src/packages/base-mcp/tools/entities.js +228 -0
  63. package/src/packages/base-mcp/tools/operator.js +106 -0
  64. package/src/packages/base-mcp/tools/projects.js +324 -0
  65. package/src/packages/base-mcp/tools/psmm.js +206 -0
  66. package/src/packages/base-mcp/tools/satellite.js +243 -0
  67. package/src/packages/base-mcp/tools/state.js +201 -0
  68. package/src/packages/base-mcp/tools/validate.js +121 -0
  69. package/src/skill/base.md +110 -0
  70. package/src/templates/operator.json +66 -0
  71. package/src/templates/workspace.json +76 -0
@@ -0,0 +1,157 @@
1
+ <purpose>
2
+ Structured weekly maintenance cycle. Walk through each workspace area, review with operator, enforce backlog time-based rules, graduate ready items, and log the groom.
3
+ </purpose>
4
+
5
+ <user-story>
6
+ As an AI builder, I want a guided workspace maintenance session, so that my context documents stay current, my backlog items graduate when ready, and my workspace doesn't drift.
7
+ </user-story>
8
+
9
+ <when-to-use>
10
+ - Weekly (on configured groom day)
11
+ - When pulse reports overdue grooming
12
+ - When user says "base groom", "let's groom", "workspace maintenance"
13
+ - Entry point routes here via /base:groom
14
+ </when-to-use>
15
+
16
+ <steps>
17
+
18
+ <step name="assess_scope" priority="first">
19
+ Determine what needs grooming.
20
+
21
+ 1. Read `.base/workspace.json` manifest
22
+ 2. Use `base_get_state` MCP tool (or read `.base/data/state.json`) for last groom dates per area
23
+ 3. Identify which areas are due for grooming (past their cadence)
24
+ 4. Sort by staleness (most overdue first)
25
+ 5. Present: "Groom session starting. {N} areas due for review: {list}. Estimated time: {N*5} minutes."
26
+
27
+ **Wait for operator confirmation before proceeding.**
28
+ </step>
29
+
30
+ <step name="groom_projects">
31
+ Review projects — the working memory for all active, blocked, and backlog work.
32
+
33
+ **Data source:** `base_list_projects` MCP tool (reads projects.json)
34
+
35
+ 1. Use `base_list_projects` to pull all projects grouped by status
36
+ 2. Present summary: "{N} active, {N} blocked, {N} backlog, last updated {date}"
37
+ 3. For each active/blocked project: "Still active? Status changed? Next action current?"
38
+ 4. For each task (type=task): "Done? Still in progress? Blocked?"
39
+ 5. Archive completed items via `base_archive_project`
40
+ 6. Ask: "Anything new to add?"
41
+ 7. Updates via `base_update_project`
42
+
43
+ **Backlog items (status=backlog) — enforce time-based rules:**
44
+ 1. For each backlog item, check `created_at` or `review_by` against thresholds:
45
+ - High priority: 7 days
46
+ - Medium priority: 14 days
47
+ - Low priority: 30 days
48
+ 2. Items past review-by → surface: "These items need a decision: {list}"
49
+ 3. Items past staleness (2x review-by) → "Auto-archiving: {list} (past {N} days without action)"
50
+ 4. Process operator decisions on each flagged item
51
+
52
+ **Graduation check:**
53
+ 5. For each remaining backlog item, ask: "Ready to work on any of these?"
54
+ 6. If yes — update status from `backlog` to `in_progress` or `todo` via `base_update_project`
55
+ 7. If no — keep with updated review-by date
56
+
57
+ **The graduation question is explicit every groom.** Items don't graduate silently — the operator decides.
58
+
59
+ Voice-friendly: walk through one entry at a time, wait for response.
60
+ </step>
61
+
62
+ <step name="groom_directories">
63
+ Review directory-type areas (projects/, clients/, tools/).
64
+
65
+ For each directory area due for grooming:
66
+ 1. List contents
67
+ 2. Flag anything that looks orphaned or new since last groom
68
+ 3. Ask: "Anything to archive, delete, or reclassify?"
69
+ 4. Execute approved changes
70
+ </step>
71
+
72
+ <step name="groom_satellites">
73
+ Review PAUL satellite project health.
74
+
75
+ 1. Read `.base/workspace.json` — collect all satellite entries where `groom_check: true`
76
+ 2. If no satellites have `groom_check: true` → skip this step silently
77
+ 3. For each eligible satellite:
78
+ a. Read its STATE.md at the path in `satellite.state` (relative to workspace root)
79
+ b. If STATE.md is missing or unreadable → note as "⚠️ {name}: STATE.md not found"
80
+ c. Get last activity timestamp:
81
+ - PRIMARY: read `satellite.last_activity` from workspace.json entry (ISO timestamp written by session-start hook from paul.json)
82
+ - FALLBACK: if `last_activity` not present in workspace.json, parse "Last activity" line from the satellite's STATE.md
83
+ - If neither available → note as "⚠️ {name}: cannot determine last activity"
84
+ d. Parse "Loop Position" section from STATE.md → extract PLAN/APPLY/UNIFY markers (✓ = done, ○ = pending)
85
+ e. Evaluate health criteria:
86
+ - **STUCK LOOP**: Loop shows PLAN ✓ APPLY ○ or PLAN ✓ APPLY ✓ UNIFY ○, AND last activity > 7 days ago
87
+ - **ABANDONED PHASE**: Last activity > 14 days ago AND milestone status is not COMPLETE
88
+ - **MILESTONE DRIFT**: Milestone marked COMPLETE, loop shows ○ ○ ○ (no new milestone started), AND last activity > 14 days ago
89
+ 4. Collect all issues across satellites
90
+ 5. If issues found: surface as:
91
+ ```
92
+ ⚠️ Satellite health issues:
93
+ - {satellite-name}: {issue type} (last active: {date})
94
+ ```
95
+ 6. If no issues: output single line "Satellites: all healthy ({N} checked)"
96
+
97
+ **Report only — do NOT auto-fix.** Operator decides what to do with flagged satellites.
98
+ </step>
99
+
100
+ <step name="groom_system">
101
+ Review system layer areas (hooks, commands, skills, CARL).
102
+
103
+ 1. Quick scan for obvious dead items
104
+ 2. Only flag if something clearly wrong
105
+ 3. Ask: "Any system changes to note?"
106
+ 4. If CARL hygiene is enabled (workspace.json `carl_hygiene.proactive: true`):
107
+ - Use `carl_v2_get_staged` to check for pending proposals in carl.json
108
+ - Use `carl_v2_list_domains` to check rule counts and spot-check `last_reviewed` dates for staleness
109
+ - Surface: "{N} staged proposals, {N} stale rules — run /base:carl-hygiene?"
110
+ </step>
111
+
112
+ <step name="log_groom">
113
+ Record the groom session.
114
+
115
+ 1. Use `base_record_groom` MCP tool to update state.json (sets last_groom, advances next_groom_due)
116
+ 2. Use `base_update_drift` MCP tool to reset drift indicators
117
+ 3. Update area timestamps via `base_update_area` for each groomed area
118
+ 4. Write groom summary to `.base/grooming/{YYYY}-W{NN}.md`:
119
+ ```markdown
120
+ # Groom Summary — Week {NN}, {YYYY}
121
+
122
+ **Date:** {YYYY-MM-DD}
123
+ **Areas Reviewed:** {list}
124
+ **Drift Score:** {before} → 0
125
+
126
+ ## Changes
127
+ - {what changed}
128
+
129
+ ## Graduated from Backlog
130
+ - {item} → project (status: in_progress)
131
+
132
+ ## Archived / Killed
133
+ - {item} (reason)
134
+
135
+ ## Next Groom Due
136
+ {YYYY-MM-DD}
137
+ ```
138
+ 5. Report: "Groom complete. Drift score: 0. Next groom due: {date}."
139
+ </step>
140
+
141
+ </steps>
142
+
143
+ <output>
144
+ Updated workspace state. All due areas reviewed and current. Backlog time-based rules enforced. Ready items graduated. Groom summary logged.
145
+ </output>
146
+
147
+ <acceptance-criteria>
148
+ - [ ] All overdue areas reviewed with operator
149
+ - [ ] Projects updated via base_update_project / base_archive_project
150
+ - [ ] Backlog time-based rules enforced (review-by, staleness)
151
+ - [ ] Graduation question asked explicitly for backlog items
152
+ - [ ] Graduated items updated from backlog → active status
153
+ - [ ] state.json updated via base_record_groom
154
+ - [ ] Groom summary written to grooming/ directory
155
+ - [ ] Drift score reset to 0
156
+ - [ ] Operator confirmed completion of each area
157
+ </acceptance-criteria>
@@ -0,0 +1,34 @@
1
+ <purpose>
2
+ Show workspace evolution over time. Read ROADMAP.md and present the chronological record of major workspace changes.
3
+ </purpose>
4
+
5
+ <user-story>
6
+ As an AI builder, I want to see how my workspace has evolved, so that I can understand the trajectory and make informed decisions about future changes.
7
+ </user-story>
8
+
9
+ <when-to-use>
10
+ - When user wants to review workspace history
11
+ - Entry point routes here via /base:history
12
+ </when-to-use>
13
+
14
+ <steps>
15
+
16
+ <step name="read_history" priority="first">
17
+ Read and present workspace evolution.
18
+
19
+ 1. Read `.base/ROADMAP.md`
20
+ 2. Present chronologically: dates, what changed, why
21
+ 3. Include audit summaries and major groom outcomes
22
+ 4. If ROADMAP.md is empty or missing: "No history yet. Run /base:audit or /base:groom to start building your workspace timeline."
23
+ </step>
24
+
25
+ </steps>
26
+
27
+ <output>
28
+ Chronological workspace evolution timeline from ROADMAP.md.
29
+ </output>
30
+
31
+ <acceptance-criteria>
32
+ - [ ] History presented in clear chronological format
33
+ - [ ] Includes both audits and significant groom outcomes
34
+ </acceptance-criteria>
@@ -0,0 +1,83 @@
1
+ <purpose>
2
+ Daily workspace activation. Read workspace state, calculate drift, present health dashboard, prime the operator for their session.
3
+ </purpose>
4
+
5
+ <user-story>
6
+ As an AI builder, I want a quick workspace health briefing at session start, so that I know what needs attention before I start working.
7
+ </user-story>
8
+
9
+ <when-to-use>
10
+ - Start of every work session
11
+ - When user says "base pulse", "what's the state of things", "workspace status"
12
+ - When the pulse hook detects overdue grooming and injects a prompt
13
+ - Entry point routes here via /base:pulse
14
+ </when-to-use>
15
+
16
+ <steps>
17
+
18
+ <step name="read_state" priority="first">
19
+ Read workspace state from `.base/workspace.json` and `.base/data/state.json`.
20
+
21
+ 1. Read `.base/workspace.json` — the manifest
22
+ 2. Read `.base/data/state.json` — the last known state
23
+ 3. If either file is missing, suggest running `/base:scaffold` first
24
+ 4. Extract: last groom date, groom cadence, area list, satellite list
25
+ </step>
26
+
27
+ <step name="calculate_drift">
28
+ Check each tracked area against filesystem reality.
29
+
30
+ For each area in the manifest:
31
+ 1. Check filesystem timestamps on tracked paths (stat modification dates)
32
+ 2. Compare against last groom date and area-specific cadence
33
+ 3. Calculate days overdue (0 if within cadence)
34
+ 4. Classify: Current (within cadence), Stale (1-2x overdue), Critical (2x+ overdue)
35
+
36
+ For each registered satellite:
37
+ 1. Check if state file exists and is readable
38
+ 2. Extract last modification date
39
+ 3. Report current phase if parseable
40
+
41
+ Calculate total drift score: sum of days-overdue across all areas, with Critical areas weighted 2x.
42
+ </step>
43
+
44
+ <step name="present_dashboard">
45
+ Present the health dashboard to the operator.
46
+
47
+ Format:
48
+ ```
49
+ BASE Pulse — {workspace-name}
50
+ Last Groom: {date} ({N} days ago)
51
+ Drift Score: {score}
52
+
53
+ | Area | Status | Age | Due |
54
+ |------|--------|-----|-----|
55
+ ...
56
+
57
+ Satellites:
58
+ | Project | Phase | Last Active |
59
+ ...
60
+
61
+ {Recommendation based on drift score}
62
+ ```
63
+
64
+ Recommendations:
65
+ - Drift 0: "Workspace is clean. Proceed normally."
66
+ - Drift 1-7: "Minor drift in {areas}. Consider grooming this week."
67
+ - Drift 8-14: "Moderate drift. Run /base:groom soon."
68
+ - Drift 15+: "Critical drift. Workspace context is stale. Run /base:groom now."
69
+ </step>
70
+
71
+ </steps>
72
+
73
+ <output>
74
+ Health dashboard with drift score, area statuses, satellite health, and recommended next action.
75
+ </output>
76
+
77
+ <acceptance-criteria>
78
+ - [ ] All manifest areas checked against filesystem reality
79
+ - [ ] Drift score calculated correctly
80
+ - [ ] Satellites checked for health
81
+ - [ ] Clear recommendation provided based on drift level
82
+ - [ ] Dashboard is concise and scannable (not a wall of text)
83
+ </acceptance-criteria>
@@ -0,0 +1,389 @@
1
+ <purpose>
2
+ Set up BASE in a new or existing workspace. Scan the workspace, ask guided questions, generate the manifest, install hooks, initialize JSON data surfaces, and run operator profile setup. Optional --full mode adds CLAUDE.md audit and guided first groom.
3
+ </purpose>
4
+
5
+ <user-story>
6
+ As an AI builder setting up my workspace, I want a guided scaffolding process that configures workspace management for my specific setup, so that I get maintenance automation without manual configuration.
7
+ </user-story>
8
+
9
+ <when-to-use>
10
+ - First-time BASE installation in any workspace
11
+ - When user says "base scaffold", "set up base", "initialize workspace management"
12
+ - Entry point routes here via /base:scaffold
13
+ - Use --full flag for batteries-included mode with CLAUDE.md audit + first groom
14
+ </when-to-use>
15
+
16
+ <context>
17
+ @templates/workspace-json.md
18
+ </context>
19
+
20
+ <steps>
21
+
22
+ <step name="detect_mode" priority="first">
23
+ Determine scaffold mode.
24
+
25
+ 1. Check if user specified `--full` or mentioned wanting full setup
26
+ 2. If `--full`: CLAUDE.md audit + first groom will be offered after data layer setup
27
+ 3. If standard: data layer + hooks + operator profile
28
+ 4. Announce mode: "Running BASE scaffold ({standard|full} mode)."
29
+ </step>
30
+
31
+ <step name="scan_workspace">
32
+ Scan the workspace and detect what exists.
33
+
34
+ 1. List top-level directories and files
35
+ 2. Detect common patterns:
36
+ - .base/data/ → existing JSON surfaces (v2 data model)
37
+ - ACTIVE.md, BACKLOG.md → legacy working memory (offer migration)
38
+ - projects/ → project tracking
39
+ - apps/ → satellite projects
40
+ - tools/ → tool management
41
+ - .qwen/ → system layer
42
+ - .mcp.json → MCP configuration
43
+ - content/ → content pipeline
44
+ - clients/ → client work
45
+ - obsidian/ → knowledge graph
46
+ - .carl/ → CARL dynamic rules
47
+ 3. Detect satellite projects (directories with .paul/ inside apps/)
48
+ 4. Present findings: "I found: {list of detected areas}"
49
+
50
+ **Wait for confirmation before proceeding.**
51
+ </step>
52
+
53
+ <step name="guided_configuration">
54
+ Walk through each detected area and configure tracking.
55
+
56
+ For each detected area:
57
+ 1. "I found {area}. Want BASE to track this?"
58
+ 2. If yes: "What grooming cadence? (weekly/bi-weekly/monthly)"
59
+ 3. Auto-select audit strategy based on area type
60
+ 4. Allow override of defaults
61
+
62
+ Also ask:
63
+ - "What day do you prefer for weekly grooming?" (default: Friday)
64
+ - "Any directories I should scan for satellite projects?" (default: apps/)
65
+ - "Anything else you want tracked that I didn't detect?"
66
+
67
+ Build workspace.json from responses using `@templates/workspace-json.md` schema.
68
+ </step>
69
+
70
+ <step name="install_data_layer">
71
+ Create .base/ directory and generate JSON data surfaces.
72
+
73
+ 1. Create `.base/` directory structure:
74
+ ```
75
+ .base/
76
+ ├── workspace.json
77
+ ├── operator.json
78
+ ├── data/
79
+ │ ├── projects.json
80
+ │ ├── entities.json
81
+ │ ├── state.json
82
+ │ ├── psmm.json
83
+ │ └── staging.json
84
+ ├── hooks/
85
+ ├── base-mcp/
86
+ ├── grooming/
87
+ ├── schemas/
88
+ └── audits/
89
+ ```
90
+ 2. Write workspace.json from guided configuration (with surfaces and carl_hygiene sections)
91
+ 3. Initialize JSON data surfaces with empty starter content (don't overwrite existing):
92
+ - projects.json — unified active work + backlog tracking
93
+ - entities.json — people, organizations, systems
94
+ - state.json — workspace health, drift, groom tracking
95
+ - psmm.json — per-session meta memory
96
+ - staging.json — proposed changes staging
97
+ 4. Copy operator.json template (don't overwrite existing)
98
+ 5. Register any detected satellite projects in workspace.json
99
+ 6. Report: "BASE data layer installed. {N} areas tracked, {N} satellites registered, {N} data surfaces initialized."
100
+ </step>
101
+
102
+ <step name="install_hooks">
103
+ Install and register BASE hooks.
104
+
105
+ All hooks live in `.base/hooks/`. Session hooks are registered in `.qwen/settings.json`.
106
+
107
+ **UserPromptSubmit hooks** (fire every prompt):
108
+ - active-hook.py — active work surface injection
109
+ - backlog-hook.py — backlog surface injection
110
+ - base-pulse-check.py — drift detection + groom reminders
111
+ - psmm-injector.py — per-session meta memory injection
112
+ - operator.py — operator identity context injection
113
+
114
+ **SessionStart hooks** (fire once when Claude Code starts a session):
115
+ - satellite-detection.py — PAUL project auto-registration and state sync
116
+
117
+ **On-demand hooks** (invoked by commands, not auto-registered):
118
+ - apex-insights.py — workspace analytics (invoked by /apex:insights)
119
+
120
+ ---
121
+
122
+ ### ENVIRONMENT DETECTION (REQUIRED — do this FIRST)
123
+
124
+ Hooks are shell commands that Claude Code executes. The python path AND file paths must work in the context where Claude Code is running. Detect the environment before wiring anything.
125
+
126
+ **Step 1: Identify the platform.**
127
+ Run these commands and read the results:
128
+ ```bash
129
+ uname -a # Linux vs Darwin vs MINGW/MSYS
130
+ cat /proc/version 2>/dev/null # WSL detection (contains "Microsoft" or "WSL")
131
+ echo $TERM_PROGRAM # vscode = VS Code integrated terminal
132
+ ```
133
+
134
+ **Step 2: Classify the environment.**
135
+
136
+ | Environment | Detection | Python Command | File Paths |
137
+ |---|---|---|---|
138
+ | **Native Linux** | `uname` = Linux, no WSL in /proc/version | `which python3` → use result | Native paths work |
139
+ | **Native macOS** | `uname` = Darwin | `which python3` → use result (often /opt/homebrew/bin/python3) | Native paths work |
140
+ | **WSL Terminal** (Claude Code CLI in WSL) | Linux + "Microsoft" in /proc/version + NOT in VS Code | `which python3` → use result (typically /usr/bin/python3) | WSL paths work (/home/user/...) |
141
+ | **VS Code Extension (WSL Remote)** | Linux + WSL + TERM_PROGRAM=vscode | `which python3` → use result | WSL paths work (VS Code server runs inside WSL) |
142
+ | **VS Code Extension (Windows-native)** | platform: win32 in Claude Code, OR `uname` returns MINGW/MSYS | See troubleshooting below | Windows paths required |
143
+ | **Native Windows** | No WSL, Windows paths | `where python` or `py -3` | Windows paths (C:\...) |
144
+
145
+ **Step 3: Handle the tricky cases.**
146
+
147
+ **VS Code Extension on Windows accessing WSL files (PROBLEMATIC):**
148
+ This is the hardest case. The VS Code extension runs on the Windows side but can see WSL files. Hooks execute in a Windows context, so:
149
+ - `/usr/bin/python3` does NOT exist
150
+ - `/home/user/...` paths are NOT valid
151
+ - The Windows Python stub (`WindowsApps/python3.exe`) can't access WSL paths
152
+
153
+ **Solutions (present to user in order of preference):**
154
+
155
+ 1. **Use VS Code Remote - WSL extension** (RECOMMENDED):
156
+ - Install the "WSL" extension in VS Code (by Microsoft)
157
+ - Open the workspace with "Reopen in WSL" or `code --remote wsl+Ubuntu /path/to/workspace`
158
+ - This runs the VS Code server inside WSL — all hooks fire natively
159
+ - All WSL paths and python work correctly
160
+
161
+ 2. **Use Claude Code CLI in WSL terminal instead of VS Code extension:**
162
+ - Open a WSL terminal, `cd` to workspace, run `claude`
163
+ - All hooks fire natively in WSL context
164
+ - Use VS Code separately for editing if needed
165
+
166
+ 3. **Wrapper script approach** (for advanced users who need both contexts):
167
+ Create a wrapper at a Windows-accessible location that detects context and routes:
168
+ ```bash
169
+ #!/bin/bash
170
+ # Detect if running in WSL or Windows and route accordingly
171
+ if [ -f /proc/version ] && grep -qi microsoft /proc/version; then
172
+ # Running in WSL context — use WSL python directly
173
+ /usr/bin/python3 "$@"
174
+ else
175
+ # Running in Windows context — invoke via wsl
176
+ wsl /usr/bin/python3 "$@"
177
+ fi
178
+ ```
179
+ This is fragile and NOT recommended for most users.
180
+
181
+ **IMPORTANT: Ask the user which environment they use Claude Code in before proceeding.**
182
+ If they use multiple environments (e.g., CLI in WSL + VS Code extension), explain the constraints and recommend option 1 (VS Code Remote WSL).
183
+
184
+ ---
185
+
186
+ ### HOOK REGISTRATION
187
+
188
+ After environment is classified and python path is determined:
189
+
190
+ For each auto-fire hook:
191
+ 1. Check if `.base/hooks/{hook}` exists
192
+ 2. If not: copy from `~/.qwen/base-framework/hooks/{hook}` (global install source)
193
+ - If `~/.qwen/base-framework/hooks/{hook}` doesn't exist either, warn:
194
+ "BASE framework not globally installed. Run `npx base-framework --global` first, then re-run scaffold."
195
+ 3. Check `.qwen/settings.json` for hook registration:
196
+ - **UserPromptSubmit hooks** → register in `UserPromptSubmit` array
197
+ - **SessionStart hooks** (satellite-detection.py) → register in `SessionStart` array
198
+ 4. If not registered: add the hook entry using detected python path + absolute path to `.base/hooks/{hook}`
199
+
200
+ Hook registration format in settings.json:
201
+
202
+ **CRITICAL: Each event type array contains objects with a `hooks` array inside — NOT flat command objects.** This is the Claude Code settings.json schema. Getting this wrong means hooks silently fail.
203
+
204
+ ```json
205
+ {
206
+ "hooks": {
207
+ "UserPromptSubmit": [
208
+ {
209
+ "hooks": [
210
+ { "type": "command", "command": "{detected_python3_path} {absolute_path_to_workspace}/.base/hooks/active-hook.py" },
211
+ { "type": "command", "command": "{detected_python3_path} {absolute_path_to_workspace}/.base/hooks/backlog-hook.py" },
212
+ { "type": "command", "command": "{detected_python3_path} {absolute_path_to_workspace}/.base/hooks/base-pulse-check.py" },
213
+ { "type": "command", "command": "{detected_python3_path} {absolute_path_to_workspace}/.base/hooks/psmm-injector.py" },
214
+ { "type": "command", "command": "{detected_python3_path} {absolute_path_to_workspace}/.base/hooks/operator.py" }
215
+ ]
216
+ }
217
+ ],
218
+ "SessionStart": [
219
+ {
220
+ "hooks": [
221
+ { "type": "command", "command": "{detected_python3_path} {absolute_path_to_workspace}/.base/hooks/satellite-detection.py" }
222
+ ]
223
+ }
224
+ ]
225
+ }
226
+ }
227
+ ```
228
+
229
+ **Merge strategy:** If `.qwen/settings.json` already has a `hooks` section with existing entries (e.g., from CARL or other tools), APPEND BASE hooks into the existing `hooks` arrays inside the event type objects. Do NOT overwrite existing hooks. Read the file first, find the right array, add entries that aren't already present.
230
+
231
+ ---
232
+
233
+ ### HOOK TROUBLESHOOTING
234
+
235
+ If hooks aren't firing after setup, diagnose with these checks:
236
+
237
+ **Symptom: "operation blocked by hook" or "No such file"**
238
+ - Python path is wrong for the current environment
239
+ - Fix: re-detect python path for the environment Claude Code is running in
240
+
241
+ **Symptom: Zero hooks fire (no CARL, no pulse, no calendar, nothing)**
242
+ - Likely a platform mismatch (Windows paths vs WSL paths)
243
+ - Check: `echo $PATH | tr ':' '\n' | grep python` — does python3 resolve?
244
+ - Check: Can Claude Code's shell access the hook file? Run `cat {hook_path}` to verify
245
+
246
+ **Symptom: Hooks fire in terminal but not in VS Code (or vice versa)**
247
+ - Different Claude Code instances run in different contexts
248
+ - VS Code extension (Windows-native) ≠ Claude Code CLI (WSL)
249
+ - Fix: Use VS Code Remote WSL extension so both contexts are WSL
250
+
251
+ **Symptom: "python3: command not found"**
252
+ - Python3 is not on PATH in the hook execution context
253
+ - Fix: Use absolute path to python3 (detect with `which python3`)
254
+
255
+ **Diagnostic command (run this to check hook health):**
256
+ ```bash
257
+ # Test each hook manually
258
+ for hook in .base/hooks/*.py; do
259
+ echo "--- Testing: $hook ---"
260
+ {detected_python3_path} "$hook" 2>&1 | head -3
261
+ echo "Exit code: $?"
262
+ done
263
+ ```
264
+
265
+ Report: "Hooks installed ({N} auto-fire hooks registered, 1 on-demand hook available)."
266
+ Report environment: "{environment_type} detected — hooks configured for {python_path}"
267
+ </step>
268
+
269
+ <step name="operator_profile">
270
+ Guide the operator through their profile setup.
271
+
272
+ 1. Check if `.base/operator.json` has completed sections (check `completed_at` fields)
273
+ 2. If all sections completed: "Operator profile already configured. Want to update any section?"
274
+ 3. If incomplete or new:
275
+ - Walk through each section of operator.json:
276
+ a. **Deep Why** — 5 progressively deeper questions about motivation
277
+ b. **North Star** — One measurable metric with timeframe
278
+ c. **Key Values** — Rank-ordered values with concrete meanings (max 5)
279
+ d. **Elevator Pitch** — Layered pitch (1-4 floors)
280
+ e. **Surface Vision** — Concrete scenes of what success looks like
281
+ - Each section can be skipped: "Skip for now? You can complete it later."
282
+ - Write responses to operator.json after each section
283
+ 4. Report: "Operator profile {complete|partially complete}. The operator hook will inject your identity context every session."
284
+ </step>
285
+
286
+ <step name="install_mcp">
287
+ Install and wire the MCP server from the global BASE package.
288
+
289
+ The MCP server package lives globally at `~/.qwen/base-framework/packages/base-mcp/`. Scaffold copies it into the workspace and wires it up.
290
+
291
+ 1. Check if `.base/base-mcp/index.js` exists in the workspace
292
+ 2. If NOT present:
293
+ a. Check if global source exists at `~/.qwen/base-framework/packages/base-mcp/`
294
+ b. If global source missing: warn "BASE framework not globally installed. Run the installer first."
295
+ c. If global source exists: copy the entire `base-mcp/` directory to `.base/base-mcp/`
296
+ d. Run `npm install` in `.base/base-mcp/` to install dependencies
297
+ 3. If already present: check for `node_modules/`. If missing, run `npm install`.
298
+ 4. Check `.mcp.json` for base-mcp registration
299
+ 5. If not registered: add registration to `.mcp.json`:
300
+ ```json
301
+ { "base-mcp": { "type": "stdio", "command": "node", "args": ["./.base/base-mcp/index.js"] } }
302
+ ```
303
+ 6. Report: "BASE MCP server installed from global package and registered. Claude can now manage your data surfaces through tool calls."
304
+ </step>
305
+
306
+ <step name="full_mode_extras">
307
+ **Full mode only.**
308
+
309
+ **CLAUDE.md audit:**
310
+ 1. Check if CLAUDE.md exists
311
+ 2. If exists: "Want me to audit your CLAUDE.md against the CLAUDE.md Strategy?"
312
+ - If yes: route to `/base:audit-claude-md` (interactive, strategy-driven audit with CARL detection)
313
+ 3. If doesn't exist: "Want me to generate a CLAUDE.md from the strategy template?"
314
+ - If yes: use `@{~/.qwen/commands/qwen-base/templates/claudemd-template.md}` as starting point, fill from detected workspace structure
315
+
316
+ **First groom:**
317
+ 1. "Want to run an initial groom to establish baseline? This reviews each area once."
318
+ 2. If yes: run /base:groom flow
319
+ 3. If no: "Baseline set from filesystem timestamps. First groom due: {date}."
320
+ </step>
321
+
322
+ <step name="post_scaffold_cleanup">
323
+ Quick review and cleanup. Catches artifacts from path detection bugs, stale files, or misaligned structure.
324
+
325
+ **Run these checks in order:**
326
+
327
+ 1. **Bogus directories** — Scan workspace root for directories that shouldn't exist:
328
+ - Any directory starting with `C:` or containing Windows-style paths (path detection bug)
329
+ - Any directory named `undefined`, `null`, or `[object Object]`
330
+ - If found: delete them and report what was removed
331
+
332
+ 2. **Sunset files** — Check for files that no longer belong:
333
+ - `.base/data/active.json` → sunset, replaced by projects.json
334
+ - `.base/data/backlog.json` → sunset, replaced by projects.json
335
+ - `ACTIVE.md` or `BACKLOG.md` at workspace root → legacy, offer to remove
336
+ - If found: report and offer to remove (don't auto-delete without confirmation)
337
+
338
+ 3. **Path sanity** — Verify all registered hooks use correct paths for the current environment:
339
+ - Read `.qwen/settings.json` hook entries
340
+ - Check each hook path exists on disk
341
+ - Check python path resolves (`which {python_path}`)
342
+ - If any path is invalid: flag it with the correct replacement
343
+
344
+ 4. **MCP sanity** — Verify MCP registration points to a real file:
345
+ - Read `.mcp.json`
346
+ - Check `.base/base-mcp/index.js` exists
347
+ - Check `node_modules/` exists in `.base/base-mcp/`
348
+ - If broken: fix it (copy from global, npm install, re-register)
349
+
350
+ 5. **Structure alignment** — Verify workspace matches CLAUDE.md's Where section:
351
+ - Read CLAUDE.md (if it exists) and extract the Where section
352
+ - Compare declared directories against what actually exists
353
+ - Flag any mismatches (declared but not created, or created but not declared)
354
+ - Don't auto-fix — just report for user awareness
355
+
356
+ **Report:**
357
+ ```
358
+ Post-scaffold cleanup:
359
+ - Artifacts removed: {list or "none"}
360
+ - Sunset files found: {list or "none"}
361
+ - Hook paths: {all valid | N issues}
362
+ - MCP: {healthy | issues}
363
+ - Structure alignment: {aligned | N mismatches}
364
+ ```
365
+
366
+ If everything is clean: "Workspace is clean. No artifacts, all paths valid, structure aligned."
367
+ </step>
368
+
369
+ </steps>
370
+
371
+ <output>
372
+ Fully configured BASE installation. Standard mode: data layer with JSON surfaces, hooks wired, operator profile setup, MCP registered, post-scaffold cleanup verified. Full mode: adds CLAUDE.md audit and guided first groom.
373
+ </output>
374
+
375
+ <acceptance-criteria>
376
+ - [ ] Workspace scanned and areas detected
377
+ - [ ] Operator confirmed tracked areas and cadences
378
+ - [ ] .base/ directory created with all required files
379
+ - [ ] workspace.json generated from guided configuration
380
+ - [ ] JSON data surfaces initialized (projects, entities, state, psmm, staging)
381
+ - [ ] operator.json created and profile questionnaire offered
382
+ - [ ] Satellite projects detected and registered
383
+ - [ ] All auto-fire hooks installed and registered in settings.json (UserPromptSubmit + SessionStart)
384
+ - [ ] BASE MCP server wired in .mcp.json
385
+ - [ ] Post-scaffold cleanup passed (no artifacts, valid paths, structure aligned)
386
+ - [ ] (Full mode) CLAUDE.md audit offered
387
+ - [ ] (Full mode) First groom offered
388
+ - [ ] Operator informed of next groom date
389
+ </acceptance-criteria>