@wwkit/opm 1.0.10 → 1.0.12
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/README.md +4 -4
- package/package.json +2 -3
- package/src/cli/index.js +13 -1
- package/src/harnesses/opencode/index.js +1 -1
- package/src/tools/webwork/index.js +34 -16
package/README.md
CHANGED
|
@@ -68,7 +68,7 @@ pnpm opm <command> [args] [options]
|
|
|
68
68
|
| `ensure <runtime> [version]` | 确保运行时已安装(node/php/python) |
|
|
69
69
|
| `ping <host|proxy|registry>` | 验证主机、代理或所有 registry 的可访问性 |
|
|
70
70
|
| `config [section]` | 查看常用配置(proxy + 各 registry 段,段名动态生成) |
|
|
71
|
-
| `opencode <action>` | opencode 运维命令(安装/升级/清理/env
|
|
71
|
+
| `opencode <action>` | opencode 运维命令(安装/升级/清理/env);裸 `opm opencode` 启动 TUI |
|
|
72
72
|
| `harness <action>` | @wwkit/harness 插件管理(安装/升级/list/status/env/dir) |
|
|
73
73
|
|
|
74
74
|
## Managers
|
|
@@ -120,7 +120,7 @@ pnpm opm <command> [args] [options]
|
|
|
120
120
|
| `opencode config` | 显示配置文件内容 |
|
|
121
121
|
| `opencode dir` | 显示 data/db/log/config 路径 |
|
|
122
122
|
| `opencode env` | 显示环境变量(OPENCODE_CONFIG_DIR / CONTENT) |
|
|
123
|
-
| `opencode
|
|
123
|
+
| `opencode [-d <dir>]` | 启动 TUI(默认 cwd),自动注入环境变量;可透传 args 给 opencode |
|
|
124
124
|
| `opencode clear` | 清理过期会话并 VACUUM 压缩数据库(缺省 `-d 1`,只保留今天) |
|
|
125
125
|
| `opencode clear -d, --days <n>` | 保留最近 n 天(对齐本地零点,含今天) |
|
|
126
126
|
| `opencode clear -h, --hours <n>` | 保留最近 n 小时(滚动窗口) |
|
|
@@ -542,8 +542,8 @@ opm opencode upgrade # 升级到最新
|
|
|
542
542
|
opm opencode config # 显示配置文件内容
|
|
543
543
|
opm opencode dir # 查看数据/日志/DB路径
|
|
544
544
|
opm opencode env # 查看环境变量
|
|
545
|
-
opm opencode
|
|
546
|
-
opm opencode
|
|
545
|
+
opm opencode # 在当前目录启动 TUI
|
|
546
|
+
opm opencode -d /path/to/project # 在指定目录启动 TUI
|
|
547
547
|
opm opencode clear # 只保留今天创建的会话
|
|
548
548
|
opm opencode clear -d 7 # 保留最近 7 天会话
|
|
549
549
|
opm opencode clear -h 24 # 保留最近 24 小时会话
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wwkit/opm",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.12",
|
|
4
4
|
"author": "bluesliu <langcai163@163.com>",
|
|
5
5
|
"description": "Unified CLI — package management (npm/pip/dnf/apt) + config view + opencode maintenance",
|
|
6
6
|
"type": "module",
|
|
@@ -35,8 +35,7 @@
|
|
|
35
35
|
"basic-ftp": "^6.2.1",
|
|
36
36
|
"extract-zip": "^2.0.1",
|
|
37
37
|
"systeminformation": "^5.23.0",
|
|
38
|
-
"@wwkit/
|
|
39
|
-
"@wwkit/shared": "1.0.14"
|
|
38
|
+
"@wwkit/shared": "1.0.16"
|
|
40
39
|
},
|
|
41
40
|
"publishConfig": {
|
|
42
41
|
"registry": "https://registry.npmjs.org/",
|
package/src/cli/index.js
CHANGED
|
@@ -77,12 +77,23 @@ class CLI {
|
|
|
77
77
|
return
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
-
|
|
80
|
+
if (groupName === 'version' || groupName === '-v' || groupName === '--version') {
|
|
81
81
|
const pkg = JSON.parse(readFileSync(new URL('../../package.json', import.meta.url), 'utf8'))
|
|
82
82
|
console.log(pkg.version)
|
|
83
83
|
return
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
+
if (groupName === 'upgrade') {
|
|
87
|
+
const { NpmManager } = await import('../managers/npm.js')
|
|
88
|
+
const { getActiveProxy } = await import('../config.js')
|
|
89
|
+
const npm = new NpmManager()
|
|
90
|
+
const proxy = getActiveProxy()
|
|
91
|
+
await npm.upgrade('@wwkit/harness', { global: true, proxy })
|
|
92
|
+
const result = await npm.upgrade('@wwkit/opm', { global: true, proxy })
|
|
93
|
+
console.log(`opm upgraded to ${result.version || 'latest'}`)
|
|
94
|
+
return
|
|
95
|
+
}
|
|
96
|
+
|
|
86
97
|
if (groupName === 'doc') {
|
|
87
98
|
generateDocHtml()
|
|
88
99
|
return
|
|
@@ -114,6 +125,7 @@ Usage: opm <command> [args] [options]
|
|
|
114
125
|
Commands:
|
|
115
126
|
${groupLines}
|
|
116
127
|
version Show opm version
|
|
128
|
+
upgrade Upgrade opm itself (npm install -g @wwkit/opm@latest)
|
|
117
129
|
doc Build docs HTML and open in browser
|
|
118
130
|
|
|
119
131
|
Options:
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* opencode 是 AI coding agent,通过 npm 全局包 opencode-ai 安装(binary: opencode)。
|
|
5
5
|
* 数据目录跨平台(db.js),会话清理复用 clear.js。
|
|
6
6
|
* env 命令管理 OPENCODE_CONFIG_DIR / OPENCODE_CONFIG_CONTENT 环境变量。
|
|
7
|
-
*
|
|
7
|
+
* 裸 `opm opencode`(或带透传 args)在指定工作目录启动 opencode TUI(自动注入 env 变量)。
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
import fs from 'node:fs'
|
|
@@ -33,7 +33,7 @@ const COMPONENTS = [
|
|
|
33
33
|
|
|
34
34
|
const ACTIONS = {
|
|
35
35
|
version: { desc: 'Show installed version of each component' },
|
|
36
|
-
versions: { desc: 'Show latest available
|
|
36
|
+
versions: { desc: 'Show latest available versions (default 10, -n <num>)' },
|
|
37
37
|
installed: { desc: 'Show install status (true/false) of each component' },
|
|
38
38
|
install: { desc: 'Mirror check + ensure runtime + write registry env + blues-lib + ww init' },
|
|
39
39
|
uninstall: { desc: 'Uninstall all components in reverse order' },
|
|
@@ -96,11 +96,13 @@ export class WebworkGroup {
|
|
|
96
96
|
|
|
97
97
|
async _versions(parsed) {
|
|
98
98
|
const proxy = this._resolveProxy(parsed)
|
|
99
|
+
const num = parseInt(parsed.flags.n || parsed.flags.num || '10', 10)
|
|
100
|
+
|
|
99
101
|
const result = {}
|
|
100
102
|
|
|
101
|
-
result['python'] = await this.
|
|
102
|
-
result['node'] = await this.
|
|
103
|
-
result['blues-lib'] = await this.
|
|
103
|
+
result['python'] = await this._pythonVersions(proxy, num)
|
|
104
|
+
result['node'] = await this._nodeVersions(proxy, num)
|
|
105
|
+
result['blues-lib'] = await this._pipVersions('blues-lib', proxy, num)
|
|
104
106
|
|
|
105
107
|
output(result)
|
|
106
108
|
}
|
|
@@ -368,14 +370,14 @@ export class WebworkGroup {
|
|
|
368
370
|
return '-'
|
|
369
371
|
}
|
|
370
372
|
|
|
371
|
-
async
|
|
373
|
+
async _pythonVersions(proxy, num) {
|
|
372
374
|
const mgr = new PythonManager()
|
|
373
375
|
try {
|
|
374
376
|
const out = mgr._exec(mgr.cfg.listRemoteCmd, { allowNonZero: true, proxy })
|
|
375
377
|
const versions = mgr._parseRemote(out)
|
|
376
|
-
return versions
|
|
378
|
+
return this._topVersions(versions, num)
|
|
377
379
|
} catch {
|
|
378
|
-
return
|
|
380
|
+
return []
|
|
379
381
|
}
|
|
380
382
|
}
|
|
381
383
|
|
|
@@ -412,15 +414,15 @@ export class WebworkGroup {
|
|
|
412
414
|
return '-'
|
|
413
415
|
}
|
|
414
416
|
|
|
415
|
-
async
|
|
417
|
+
async _nodeVersions(proxy, num) {
|
|
416
418
|
const mgr = new NodeManager()
|
|
417
|
-
if (!isNvmInstalled()) return
|
|
419
|
+
if (!isNvmInstalled()) return []
|
|
418
420
|
try {
|
|
419
421
|
const out = mgr._exec(mgr.cfg.listRemoteCmd, { allowNonZero: true, proxy })
|
|
420
|
-
const versions = mgr._parseRemote(out)
|
|
421
|
-
return
|
|
422
|
+
const versions = mgr._parseRemote(out).map((v) => v.replace(/^v/, ''))
|
|
423
|
+
return this._topVersions(versions, num)
|
|
422
424
|
} catch {
|
|
423
|
-
return
|
|
425
|
+
return []
|
|
424
426
|
}
|
|
425
427
|
}
|
|
426
428
|
|
|
@@ -458,10 +460,26 @@ export class WebworkGroup {
|
|
|
458
460
|
return result.version || '-'
|
|
459
461
|
}
|
|
460
462
|
|
|
461
|
-
async
|
|
463
|
+
async _pipVersions(name, proxy, num) {
|
|
462
464
|
const pip = new PipManager()
|
|
463
|
-
|
|
464
|
-
|
|
465
|
+
try {
|
|
466
|
+
const { versions } = await pip.packageVersions(name, { proxy })
|
|
467
|
+
return this._topVersions(versions, num)
|
|
468
|
+
} catch {
|
|
469
|
+
return []
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
/**
|
|
474
|
+
* 取版本列表前 num 条,降序排列(高版本在上)
|
|
475
|
+
* @param {string[]} versions
|
|
476
|
+
* @param {number} num
|
|
477
|
+
* @returns {string[]}
|
|
478
|
+
*/
|
|
479
|
+
_topVersions(versions, num) {
|
|
480
|
+
return [...versions]
|
|
481
|
+
.sort((a, b) => this._compareVersion(b, a))
|
|
482
|
+
.slice(0, num)
|
|
465
483
|
}
|
|
466
484
|
|
|
467
485
|
async _installPipPackage(name, proxy) {
|
|
@@ -502,7 +520,7 @@ Options:
|
|
|
502
520
|
|
|
503
521
|
Examples:
|
|
504
522
|
opm webwork version Show installed versions of all components
|
|
505
|
-
opm webwork versions Show latest available versions (
|
|
523
|
+
opm webwork versions Show latest available versions (default 10, -n <num>)
|
|
506
524
|
opm webwork installed Show install status of all components
|
|
507
525
|
opm webwork install Mirror check + ensure runtime + registry env + blues-lib + ww init
|
|
508
526
|
opm webwork uninstall Uninstall all components in reverse order
|