qwen-base 1.0.3 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bin/install.js CHANGED
@@ -54,15 +54,25 @@ function expandTilde(filePath) {
54
54
  return filePath;
55
55
  }
56
56
 
57
- function copyDir(srcDir, destDir, skipDirs = []) {
57
+ /**
58
+ * Recursively copy directory, replacing ~/.qwen/ paths in .md files
59
+ */
60
+ function copyDir(srcDir, destDir, pathPrefix, skipDirs = []) {
58
61
  fs.mkdirSync(destDir, { recursive: true });
59
62
  const entries = fs.readdirSync(srcDir, { withFileTypes: true });
60
63
  for (const entry of entries) {
61
64
  if (skipDirs.includes(entry.name)) continue;
62
65
  const srcPath = path.join(srcDir, entry.name);
63
66
  const destPath = path.join(destDir, entry.name);
64
- if (entry.isDirectory()) copyDir(srcPath, destPath, skipDirs);
65
- else fs.copyFileSync(srcPath, destPath);
67
+ if (entry.isDirectory()) {
68
+ copyDir(srcPath, destPath, pathPrefix, skipDirs);
69
+ } else if (entry.name.endsWith('.md')) {
70
+ let content = fs.readFileSync(srcPath, 'utf8');
71
+ content = content.replace(/~\/\.qwen\//g, pathPrefix);
72
+ fs.writeFileSync(destPath, content);
73
+ } else {
74
+ fs.copyFileSync(srcPath, destPath);
75
+ }
66
76
  }
67
77
  }
68
78
 
@@ -123,6 +133,9 @@ function install(isGlobal) {
123
133
  const cmdsDest = path.join(qwenDir, 'commands', 'qwen-base');
124
134
  const workspaceRoot = isGlobal ? os.homedir() : process.cwd();
125
135
 
136
+ // Path prefix for @-reference replacement in .md files
137
+ const pathPrefix = isGlobal ? '~/.qwen/' : './.qwen/';
138
+
126
139
  const locationLabel = isGlobal
127
140
  ? qwenDir.replace(os.homedir(), '~')
128
141
  : qwenDir.replace(process.cwd(), '.');
@@ -136,16 +149,16 @@ function install(isGlobal) {
136
149
 
137
150
  console.log(` Installing to ${cyan}${locationLabel}${reset}\n`);
138
151
 
139
- // Copy framework (src/ → base/)
152
+ // Copy framework (src/ → base/) with path replacement
140
153
  if (fs.existsSync(path.join(src, 'src'))) {
141
- copyDir(path.join(src, 'src'), baseDest);
154
+ copyDir(path.join(src, 'src'), baseDest, pathPrefix);
142
155
  console.log(` ${green}+${reset} base/ ${dim}(${countFiles(baseDest)} framework files)${reset}`);
143
156
  }
144
157
 
145
- // Copy commands
158
+ // Copy commands with path replacement
146
159
  if (fs.existsSync(path.join(src, 'src', 'commands'))) {
147
160
  fs.mkdirSync(cmdsDest, { recursive: true });
148
- copyDir(path.join(src, 'src', 'commands'), cmdsDest);
161
+ copyDir(path.join(src, 'src', 'commands'), cmdsDest, pathPrefix);
149
162
  console.log(` ${green}+${reset} commands/qwen-base/ ${dim}(${countFiles(cmdsDest)} commands)${reset}`);
150
163
  }
151
164
 
@@ -165,6 +178,35 @@ function install(isGlobal) {
165
178
  }
166
179
  }
167
180
 
181
+ // Wire BASE Python hooks into settings.json
182
+ const settingsPath = path.join(qwenDir, 'settings.json');
183
+ let settings = {};
184
+ if (fs.existsSync(settingsPath)) {
185
+ try { settings = JSON.parse(fs.readFileSync(settingsPath, 'utf8')); } catch (e) {}
186
+ }
187
+ if (!settings.hooks) settings.hooks = {};
188
+
189
+ const hookFiles = [
190
+ { event: 'UserPromptSubmit', file: 'base-pulse-check.py' },
191
+ { event: 'UserPromptSubmit', file: 'psmm-injector.py' },
192
+ { event: 'SessionStart', file: 'satellite-detection.py' },
193
+ ];
194
+
195
+ for (const hook of hookFiles) {
196
+ const hookPath = path.join(baseDest, 'hooks', hook.file).replace(/\\/g, '/');
197
+ const hookCommand = `python3 ${hookPath}`;
198
+ if (!settings.hooks[hook.event]) settings.hooks[hook.event] = [];
199
+ const exists = settings.hooks[hook.event].some(h =>
200
+ (h.command && h.command.includes(hook.file)) ||
201
+ (h.hooks && h.hooks.some(i => i.command && i.command.includes(hook.file)))
202
+ );
203
+ if (!exists) {
204
+ settings.hooks[hook.event].push({ hooks: [{ type: 'command', command: hookCommand }] });
205
+ }
206
+ }
207
+ fs.writeFileSync(settingsPath, JSON.stringify(settings, null, 2));
208
+ console.log(` ${green}+${reset} Wired BASE hooks in settings.json`);
209
+
168
210
  console.log(`
169
211
  ${green}Done!${reset} Open Qwen Code and type ${cyan}/base${reset} to start.
170
212
  `);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "qwen-base",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "description": "Builder's Automated State Engine — workspace lifecycle management for Qwen Code",
5
5
  "bin": {
6
6
  "qwen-base": "bin/install.js"
@@ -11,9 +11,9 @@ Audit the project's QWEN.md for strategy compliance, interactively rewrite it se
11
11
  </objective>
12
12
 
13
13
  <execution_context>
14
- @{~/.qwen/commands/qwen-base/frameworks/claudemd-strategy.md}
15
- @{~/.qwen/commands/qwen-base/templates/claudemd-template.md}
16
- @{~/.qwen/commands/qwen-base/tasks/audit-claude-md.md}
14
+ @{~/.qwen/base/framework/frameworks/claudemd-strategy.md}
15
+ @{~/.qwen/base/framework/templates/claudemd-template.md}
16
+ @{~/.qwen/base/framework/tasks/audit-claude-md.md}
17
17
  </execution_context>
18
18
 
19
19
  <context>
@@ -23,7 +23,7 @@ $ARGUMENTS
23
23
  </context>
24
24
 
25
25
  <process>
26
- Follow task: @{~/.qwen/commands/qwen-base/tasks/audit-claude-md.md}
26
+ Follow task: @{~/.qwen/base/framework/tasks/audit-claude-md.md}
27
27
 
28
28
  Key gates (do NOT skip):
29
29
  1. Load strategy + template BEFORE reading user's QWEN.md
@@ -11,8 +11,8 @@ Audit all .qwen/ directories in this workspace. Discover sprawl, classify items
11
11
  </objective>
12
12
 
13
13
  <execution_context>
14
- @{~/.qwen/commands/qwen-base/framework/}tasks/audit-QWEN.md
15
- @{~/.qwen/commands/qwen-base/framework/}frameworks/qwen-config-alignment.md
14
+ @{~/.qwen/base/framework/}tasks/audit-QWEN.md
15
+ @{~/.qwen/base/framework/}frameworks/qwen-config-alignment.md
16
16
  </execution_context>
17
17
 
18
18
  <context>
@@ -23,7 +23,7 @@ Workspace root config: .qwen/
23
23
  </context>
24
24
 
25
25
  <process>
26
- Follow task: @{~/.qwen/commands/qwen-base/framework/}tasks/audit-QWEN.md
26
+ Follow task: @{~/.qwen/base/framework/}tasks/audit-QWEN.md
27
27
 
28
28
  The framework file defines classification rules, safety protocol, and output format.
29
29
  The task file defines the step-by-step process.
@@ -11,9 +11,9 @@ Deep workspace audit — comprehensive optimization across all areas with action
11
11
  </objective>
12
12
 
13
13
  <execution_context>
14
- @{~/.qwen/commands/qwen-base/tasks/audit.md}
15
- @{~/.qwen/commands/qwen-base/context/base-principles.md}
16
- @{~/.qwen/commands/qwen-base/frameworks/audit-strategies.md}
14
+ @{~/.qwen/base/framework/tasks/audit.md}
15
+ @{~/.qwen/base/framework/context/base-principles.md}
16
+ @{~/.qwen/base/framework/frameworks/audit-strategies.md}
17
17
  </execution_context>
18
18
 
19
19
  <context>
@@ -23,7 +23,7 @@ $ARGUMENTS
23
23
  </context>
24
24
 
25
25
  <process>
26
- Follow task: @{~/.qwen/commands/qwen-base/tasks/audit.md}
26
+ Follow task: @{~/.qwen/base/framework/tasks/audit.md}
27
27
  </process>
28
28
 
29
29
  <success_criteria>
@@ -11,7 +11,7 @@ CARL rule lifecycle management — review staleness, staging pipeline, domain he
11
11
  </objective>
12
12
 
13
13
  <execution_context>
14
- @{~/.qwen/commands/qwen-base/tasks/carl-hygiene.md}
14
+ @{~/.qwen/base/framework/tasks/carl-hygiene.md}
15
15
  </execution_context>
16
16
 
17
17
  <context>
@@ -22,7 +22,7 @@ $ARGUMENTS
22
22
  </context>
23
23
 
24
24
  <process>
25
- Follow task: @{~/.qwen/commands/qwen-base/tasks/carl-hygiene.md}
25
+ Follow task: @{~/.qwen/base/framework/tasks/carl-hygiene.md}
26
26
  </process>
27
27
 
28
28
  <success_criteria>
@@ -11,9 +11,9 @@ Structured weekly maintenance — review each workspace area, update statuses, a
11
11
  </objective>
12
12
 
13
13
  <execution_context>
14
- @{~/.qwen/commands/qwen-base/tasks/groom.md}
15
- @{~/.qwen/commands/qwen-base/context/base-principles.md}
16
- @{~/.qwen/commands/qwen-base/frameworks/audit-strategies.md}
14
+ @{~/.qwen/base/framework/tasks/groom.md}
15
+ @{~/.qwen/base/framework/context/base-principles.md}
16
+ @{~/.qwen/base/framework/frameworks/audit-strategies.md}
17
17
  </execution_context>
18
18
 
19
19
  <context>
@@ -24,7 +24,7 @@ $ARGUMENTS
24
24
  </context>
25
25
 
26
26
  <process>
27
- Follow task: @{~/.qwen/commands/qwen-base/tasks/groom.md}
27
+ Follow task: @{~/.qwen/base/framework/tasks/groom.md}
28
28
  </process>
29
29
 
30
30
  <success_criteria>
@@ -11,7 +11,7 @@ Show workspace evolution — grooming history, audits, major changes over time.
11
11
  </objective>
12
12
 
13
13
  <execution_context>
14
- @{~/.qwen/commands/qwen-base/tasks/history.md}
14
+ @{~/.qwen/base/framework/tasks/history.md}
15
15
  </execution_context>
16
16
 
17
17
  <context>
@@ -19,7 +19,7 @@ Show workspace evolution — grooming history, audits, major changes over time.
19
19
  </context>
20
20
 
21
21
  <process>
22
- Follow task: @{~/.qwen/commands/qwen-base/tasks/history.md}
22
+ Follow task: @{~/.qwen/base/framework/tasks/history.md}
23
23
  </process>
24
24
 
25
25
  <success_criteria>
@@ -11,8 +11,8 @@ Workspace health briefing — drift score, stale areas, overdue grooming, quick
11
11
  </objective>
12
12
 
13
13
  <execution_context>
14
- @{~/.qwen/commands/qwen-base/tasks/pulse.md}
15
- @{~/.qwen/commands/qwen-base/context/base-principles.md}
14
+ @{~/.qwen/base/framework/tasks/pulse.md}
15
+ @{~/.qwen/base/framework/context/base-principles.md}
16
16
  </execution_context>
17
17
 
18
18
  <context>
@@ -23,7 +23,7 @@ $ARGUMENTS
23
23
  </context>
24
24
 
25
25
  <process>
26
- Follow task: @{~/.qwen/commands/qwen-base/tasks/pulse.md}
26
+ Follow task: @{~/.qwen/base/framework/tasks/pulse.md}
27
27
  </process>
28
28
 
29
29
  <success_criteria>
@@ -12,9 +12,9 @@ Guided workspace setup — scan, configure, install BASE infrastructure. Optiona
12
12
  </objective>
13
13
 
14
14
  <execution_context>
15
- @{~/.qwen/commands/qwen-base/tasks/scaffold.md}
16
- @{~/.qwen/commands/qwen-base/templates/workspace-json.md}
17
- @{~/.qwen/commands/qwen-base/templates/workspace-json.md}
15
+ @{~/.qwen/base/framework/tasks/scaffold.md}
16
+ @{~/.qwen/base/framework/templates/workspace-json.md}
17
+ @{~/.qwen/base/framework/templates/workspace-json.md}
18
18
  </execution_context>
19
19
 
20
20
  <context>
@@ -22,7 +22,7 @@ $ARGUMENTS
22
22
  </context>
23
23
 
24
24
  <process>
25
- Follow task: @{~/.qwen/commands/qwen-base/tasks/scaffold.md}
25
+ Follow task: @{~/.qwen/base/framework/tasks/scaffold.md}
26
26
  </process>
27
27
 
28
28
  <success_criteria>
@@ -11,7 +11,7 @@ One-liner workspace health status — drift score and area summary.
11
11
  </objective>
12
12
 
13
13
  <execution_context>
14
- @{~/.qwen/commands/qwen-base/tasks/status.md}
14
+ @{~/.qwen/base/framework/tasks/status.md}
15
15
  </execution_context>
16
16
 
17
17
  <context>
@@ -20,7 +20,7 @@ One-liner workspace health status — drift score and area summary.
20
20
  </context>
21
21
 
22
22
  <process>
23
- Follow task: @{~/.qwen/commands/qwen-base/tasks/status.md}
23
+ Follow task: @{~/.qwen/base/framework/tasks/status.md}
24
24
  </process>
25
25
 
26
26
  <success_criteria>
@@ -12,7 +12,7 @@ Convert an existing @-mentioned markdown file into a structured data surface. An
12
12
  </objective>
13
13
 
14
14
  <execution_context>
15
- @{~/.qwen/commands/qwen-base/tasks/surface-convert.md}
15
+ @{~/.qwen/base/framework/tasks/surface-convert.md}
16
16
  @.base/hooks/_template.py
17
17
  </execution_context>
18
18
 
@@ -23,7 +23,7 @@ $ARGUMENTS
23
23
  </context>
24
24
 
25
25
  <process>
26
- Follow task: @{~/.qwen/commands/qwen-base/tasks/surface-convert.md}
26
+ Follow task: @{~/.qwen/base/framework/tasks/surface-convert.md}
27
27
  </process>
28
28
 
29
29
  <success_criteria>
@@ -12,7 +12,7 @@ Create a new data surface through guided conversation. Generates JSON data file,
12
12
  </objective>
13
13
 
14
14
  <execution_context>
15
- @{~/.qwen/commands/qwen-base/tasks/surface-create.md}
15
+ @{~/.qwen/base/framework/tasks/surface-create.md}
16
16
  @.base/hooks/_template.py
17
17
  </execution_context>
18
18
 
@@ -23,7 +23,7 @@ $ARGUMENTS
23
23
  </context>
24
24
 
25
25
  <process>
26
- Follow task: @{~/.qwen/commands/qwen-base/tasks/surface-create.md}
26
+ Follow task: @{~/.qwen/base/framework/tasks/surface-create.md}
27
27
  </process>
28
28
 
29
29
  <success_criteria>
@@ -11,7 +11,7 @@ Display all registered data surfaces with item counts and hook status.
11
11
  </objective>
12
12
 
13
13
  <execution_context>
14
- @{~/.qwen/commands/qwen-base/tasks/surface-list.md}
14
+ @{~/.qwen/base/framework/tasks/surface-list.md}
15
15
  </execution_context>
16
16
 
17
17
  <context>
@@ -19,7 +19,7 @@ Display all registered data surfaces with item counts and hook status.
19
19
  </context>
20
20
 
21
21
  <process>
22
- Follow task: @{~/.qwen/commands/qwen-base/tasks/surface-list.md}
22
+ Follow task: @{~/.qwen/base/framework/tasks/surface-list.md}
23
23
  </process>
24
24
 
25
25
  <success_criteria>
@@ -11,7 +11,7 @@ Guided creation of a custom domain phase for /base:weekly. Walks the user throug
11
11
  </objective>
12
12
 
13
13
  <execution_context>
14
- @{~/.qwen/commands/qwen-base/tasks/weekly-domain-create.md}
14
+ @{~/.qwen/base/framework/tasks/weekly-domain-create.md}
15
15
  </execution_context>
16
16
 
17
17
  <context>
@@ -21,7 +21,7 @@ $ARGUMENTS
21
21
  </context>
22
22
 
23
23
  <process>
24
- Follow task: @{~/.qwen/commands/qwen-base/tasks/weekly-domain-create.md}
24
+ Follow task: @{~/.qwen/base/framework/tasks/weekly-domain-create.md}
25
25
  </process>
26
26
 
27
27
  <success_criteria>
@@ -11,8 +11,8 @@ Guided weekly ritual — close the week, plan the next, run maintenance, lock in
11
11
  </objective>
12
12
 
13
13
  <execution_context>
14
- @{~/.qwen/commands/qwen-base/tasks/weekly.md}
15
- @{~/.qwen/commands/qwen-base/context/base-principles.md}
14
+ @{~/.qwen/base/framework/tasks/weekly.md}
15
+ @{~/.qwen/base/framework/context/base-principles.md}
16
16
  </execution_context>
17
17
 
18
18
  <context>
@@ -24,7 +24,7 @@ $ARGUMENTS
24
24
  </context>
25
25
 
26
26
  <process>
27
- Follow task: @{~/.qwen/commands/qwen-base/tasks/weekly.md}
27
+ Follow task: @{~/.qwen/base/framework/tasks/weekly.md}
28
28
  </process>
29
29
 
30
30
  <success_criteria>