maskweaver 0.11.0 → 0.11.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.
- package/dist/shared/generate-agents.js +48 -33
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
- package/postinstall.mjs +19 -36
|
@@ -124,13 +124,39 @@ function readOpencodeConfig(basePath) {
|
|
|
124
124
|
}
|
|
125
125
|
return null;
|
|
126
126
|
}
|
|
127
|
+
function collectModelValues(opencodeConfig) {
|
|
128
|
+
const values = [];
|
|
129
|
+
const modelFields = ['model', 'small_model', 'large_model'];
|
|
130
|
+
const configs = [opencodeConfig];
|
|
131
|
+
if (opencodeConfig.agent) {
|
|
132
|
+
for (const agentConfig of Object.values(opencodeConfig.agent)) {
|
|
133
|
+
if (agentConfig && typeof agentConfig === 'object')
|
|
134
|
+
configs.push(agentConfig);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
for (const cfg of configs) {
|
|
138
|
+
for (const field of modelFields) {
|
|
139
|
+
const val = cfg[field];
|
|
140
|
+
if (typeof val === 'string' && val)
|
|
141
|
+
values.push(val);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
return values;
|
|
145
|
+
}
|
|
146
|
+
function hasSubscriptionHints(opencodeConfig) {
|
|
147
|
+
return collectModelValues(opencodeConfig).some((val) => val.startsWith('opencode-go/') || val.startsWith('zai-coding-plan/'));
|
|
148
|
+
}
|
|
127
149
|
function runCli(command, args) {
|
|
128
150
|
try {
|
|
129
151
|
const result = spawnSync(command, args, {
|
|
130
152
|
encoding: 'utf-8',
|
|
131
153
|
stdio: ['pipe', 'pipe', 'pipe'],
|
|
132
|
-
timeout:
|
|
154
|
+
timeout: 5000,
|
|
133
155
|
windowsHide: true,
|
|
156
|
+
env: {
|
|
157
|
+
...process.env,
|
|
158
|
+
OPENCODE_DISABLE_AUTOUPDATE: '1',
|
|
159
|
+
},
|
|
134
160
|
});
|
|
135
161
|
if (result.error || result.status !== 0)
|
|
136
162
|
return null;
|
|
@@ -176,17 +202,6 @@ function parseProvidersList(output) {
|
|
|
176
202
|
}
|
|
177
203
|
return providers;
|
|
178
204
|
}
|
|
179
|
-
function detectFromModels(output) {
|
|
180
|
-
const subs = new Set();
|
|
181
|
-
for (const line of output.split('\n')) {
|
|
182
|
-
const trimmed = line.trim();
|
|
183
|
-
if (trimmed.startsWith('opencode-go/'))
|
|
184
|
-
subs.add('opencode-go');
|
|
185
|
-
if (trimmed.startsWith('zai-coding-plan/'))
|
|
186
|
-
subs.add('zai-coding-plan');
|
|
187
|
-
}
|
|
188
|
-
return Array.from(subs);
|
|
189
|
-
}
|
|
190
205
|
export function detectSubscriptionsFromCli() {
|
|
191
206
|
const evidence = [];
|
|
192
207
|
const allProviders = [];
|
|
@@ -202,19 +217,9 @@ export function detectSubscriptionsFromCli() {
|
|
|
202
217
|
}
|
|
203
218
|
}
|
|
204
219
|
}
|
|
205
|
-
const modelsOutput = runCli('opencode', ['models']);
|
|
206
|
-
if (modelsOutput) {
|
|
207
|
-
const modelSubs = detectFromModels(modelsOutput);
|
|
208
|
-
for (const sub of modelSubs) {
|
|
209
|
-
if (!subs.has(sub)) {
|
|
210
|
-
subs.add(sub);
|
|
211
|
-
evidence.push(`models: ${sub}/* models available`);
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
220
|
if (subs.size === 0) {
|
|
216
221
|
subs.add('opencode-go');
|
|
217
|
-
evidence.push('No subscription detected via
|
|
222
|
+
evidence.push('No subscription detected via provider list, defaulting to opencode-go');
|
|
218
223
|
}
|
|
219
224
|
const primary = subs.has('zai-coding-plan') ? 'zai-coding-plan' : 'opencode-go';
|
|
220
225
|
return {
|
|
@@ -414,16 +419,6 @@ export function formatProviderChecklist(detection) {
|
|
|
414
419
|
return lines.join('\n');
|
|
415
420
|
}
|
|
416
421
|
export function writeAutoDetectedConfig(projectDir, force) {
|
|
417
|
-
let detection;
|
|
418
|
-
try {
|
|
419
|
-
detection = detectSubscriptionsFromCli();
|
|
420
|
-
}
|
|
421
|
-
catch {
|
|
422
|
-
const opencodeConfig = readOpencodeConfig(projectDir);
|
|
423
|
-
if (!opencodeConfig)
|
|
424
|
-
return null;
|
|
425
|
-
detection = detectSubscriptionsFromConfig(opencodeConfig);
|
|
426
|
-
}
|
|
427
422
|
const targetPath = path.join(projectDir, 'maskweaver.config.json');
|
|
428
423
|
const existingConfig = fs.existsSync(targetPath)
|
|
429
424
|
? (() => { try {
|
|
@@ -436,6 +431,26 @@ export function writeAutoDetectedConfig(projectDir, force) {
|
|
|
436
431
|
if (!force && existingConfig?.dummyHumans?.pool?.length > 0) {
|
|
437
432
|
return null;
|
|
438
433
|
}
|
|
434
|
+
let detection;
|
|
435
|
+
const opencodeConfig = readOpencodeConfig(projectDir);
|
|
436
|
+
if (opencodeConfig && hasSubscriptionHints(opencodeConfig)) {
|
|
437
|
+
detection = detectSubscriptionsFromConfig(opencodeConfig);
|
|
438
|
+
}
|
|
439
|
+
else {
|
|
440
|
+
try {
|
|
441
|
+
detection = detectSubscriptionsFromCli();
|
|
442
|
+
}
|
|
443
|
+
catch {
|
|
444
|
+
detection = opencodeConfig
|
|
445
|
+
? detectSubscriptionsFromConfig(opencodeConfig)
|
|
446
|
+
: {
|
|
447
|
+
subscriptions: ['opencode-go'],
|
|
448
|
+
primary: 'opencode-go',
|
|
449
|
+
evidence: ['No opencode config found, defaulting to opencode-go'],
|
|
450
|
+
allProviders: [],
|
|
451
|
+
};
|
|
452
|
+
}
|
|
453
|
+
}
|
|
439
454
|
const newConfig = buildConfigFromDetection(detection);
|
|
440
455
|
try {
|
|
441
456
|
fs.writeFileSync(targetPath, JSON.stringify(newConfig, null, 2) + '\n', 'utf-8');
|
package/dist/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "0.
|
|
1
|
+
export declare const VERSION = "0.11.1";
|
|
2
2
|
export declare function getVersionString(): string;
|
package/dist/version.js
CHANGED
package/package.json
CHANGED
package/postinstall.mjs
CHANGED
|
@@ -149,42 +149,16 @@ const OPENCODE_GO_POOL = [
|
|
|
149
149
|
},
|
|
150
150
|
];
|
|
151
151
|
|
|
152
|
-
function runCli(command, args) {
|
|
153
|
-
try {
|
|
154
|
-
const result = spawnSync(command, args, {
|
|
155
|
-
encoding: 'utf-8',
|
|
156
|
-
stdio: ['pipe', 'pipe', 'pipe'],
|
|
157
|
-
timeout: 8000,
|
|
158
|
-
windowsHide: true,
|
|
159
|
-
});
|
|
160
|
-
if (result.error || result.status !== 0) return null;
|
|
161
|
-
return result.stdout || null;
|
|
162
|
-
} catch {
|
|
163
|
-
return null;
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
|
|
167
152
|
function detectSubscription() {
|
|
168
153
|
let hasOpencodeGo = false;
|
|
169
154
|
let hasZai = false;
|
|
170
155
|
|
|
171
|
-
const
|
|
172
|
-
if (providersOutput) {
|
|
173
|
-
const stripped = providersOutput.replace(/\x1b\[[0-9;]*m/g, '');
|
|
174
|
-
if (/opencode\s*go/i.test(stripped)) hasOpencodeGo = true;
|
|
175
|
-
if (/z\.ai\s*coding\s*plan|zai-coding-plan/i.test(stripped)) hasZai = true;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
const modelsOutput = runCli('opencode', ['models']);
|
|
179
|
-
if (modelsOutput) {
|
|
180
|
-
if (/^opencode-go\//m.test(modelsOutput)) hasOpencodeGo = true;
|
|
181
|
-
if (/^zai-coding-plan\//m.test(modelsOutput)) hasZai = true;
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
if (hasZai) return 'zai-coding-plan';
|
|
185
|
-
if (hasOpencodeGo) return 'opencode-go';
|
|
186
|
-
|
|
156
|
+
const initCwd = process.env.INIT_CWD;
|
|
187
157
|
const candidates = [
|
|
158
|
+
...(initCwd ? [
|
|
159
|
+
join(initCwd, 'opencode.json'),
|
|
160
|
+
join(initCwd, 'opencode.jsonc'),
|
|
161
|
+
] : []),
|
|
188
162
|
join(homedir(), '.config', 'opencode', 'opencode.json'),
|
|
189
163
|
join(homedir(), '.config', 'opencode', 'opencode.jsonc'),
|
|
190
164
|
];
|
|
@@ -198,11 +172,20 @@ function detectSubscription() {
|
|
|
198
172
|
if (!parsed || typeof parsed !== 'object') continue;
|
|
199
173
|
|
|
200
174
|
const modelFields = ['model', 'small_model', 'large_model'];
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
175
|
+
const configs = [parsed];
|
|
176
|
+
if (parsed.agent && typeof parsed.agent === 'object') {
|
|
177
|
+
for (const agentConfig of Object.values(parsed.agent)) {
|
|
178
|
+
if (agentConfig && typeof agentConfig === 'object') configs.push(agentConfig);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
for (const cfg of configs) {
|
|
183
|
+
for (const field of modelFields) {
|
|
184
|
+
const val = cfg[field];
|
|
185
|
+
if (typeof val !== 'string' || !val) continue;
|
|
186
|
+
if (val.startsWith('opencode-go/')) hasOpencodeGo = true;
|
|
187
|
+
if (val.startsWith('zai-coding-plan/')) hasZai = true;
|
|
188
|
+
}
|
|
206
189
|
}
|
|
207
190
|
} catch { continue; }
|
|
208
191
|
}
|