@powerbase/cli 0.1.1 → 0.1.3

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 CHANGED
@@ -1,63 +1,63 @@
1
- # PowerBase CLI
2
-
3
- PowerBase CLI(`powerbase`)用于在终端或 AI 办公助手里检索、问答和管理 PowerBase 知识库。
4
-
5
- ## 安装
6
-
7
- 需要 Node.js 18 及以上。Windows 与 macOS 使用同一条命令:
8
-
9
- ```bash
10
- npm install -g @powerbase/cli
11
- ```
12
-
13
- 安装会自动匹配当前平台(Windows x64/ARM64、macOS Apple 芯片/Intel),并预置公司服务器地址。
14
-
15
- ## 登录
16
-
17
- ```bash
18
- powerbase auth login
19
- ```
20
-
21
- 命令会打开浏览器授权页,登录公司账号并点击“授权 CLI 登录”,终端会自动完成登录。凭据保存在系统凭据管理器(Windows 凭据管理器 / macOS 钥匙串)。
22
-
23
- ```bash
24
- powerbase auth status # 查看当前账号与空间
25
- ```
26
-
27
- ## 快速开始
28
-
29
- ```bash
30
- powerbase space list # 我有哪些空间
31
- powerbase kb list # 当前空间的知识库
32
- powerbase search chunks "合同评审流程" # 检索原文片段
33
- powerbase chat "总结一下这份报告" # 基于知识库问答
34
- powerbase doc upload ./报告.pdf # 上传文档(会先确认目标知识库)
35
- ```
36
-
37
- ## 接入 AI 办公助手
38
-
39
- 技能是带 `SKILL.md` 的普通目录,任何支持 Agent Skills 的助手都能用:
40
-
41
- ```bash
42
- powerbase skills install --name powerbase --dir <助手技能目录>
43
- ```
44
-
45
- 常见助手的技能目录(相对用户主目录):
46
-
47
- | 助手 | Windows | macOS |
48
- |---|---|---|
49
- | WorkBuddy | `%USERPROFILE%\.workbuddy\skills` | `~/.workbuddy/skills` |
50
-
51
- 其他助手:在其设置中查看“技能/插件目录”,用同一条命令指过去即可。
52
-
53
- ## 升级与卸载
54
-
55
- ```bash
56
- npm install -g @powerbase/cli@latest # 升级
57
- npm uninstall -g @powerbase/cli # 卸载(登录态保留在系统凭据管理器)
58
- ```
59
-
60
- ## 说明
61
-
62
- - 仅支持公司内网环境;公开包内的下载与更新逻辑不依赖外部服务。
63
- - 所有命令默认输出 JSON,便于脚本和 Agent 解析;人工阅读可加 `--format text`。
1
+ # PowerBase CLI
2
+
3
+ PowerBase CLI(`powerbase`)用于在终端或 AI 办公助手里检索、问答和管理 PowerBase 知识库。
4
+
5
+ ## 安装
6
+
7
+ 需要 Node.js 18 及以上。Windows 与 macOS 使用同一条命令:
8
+
9
+ ```bash
10
+ npm install -g @powerbase/cli
11
+ ```
12
+
13
+ 安装会自动匹配当前平台(Windows x64/ARM64、macOS Apple 芯片/Intel),并预置公司服务器地址。
14
+
15
+ ## 登录
16
+
17
+ ```bash
18
+ powerbase auth login
19
+ ```
20
+
21
+ 命令会打开浏览器授权页,登录公司账号并点击“授权 CLI 登录”,终端会自动完成登录。凭据保存在系统凭据管理器(Windows 凭据管理器 / macOS 钥匙串)。
22
+
23
+ ```bash
24
+ powerbase auth status # 查看当前账号与空间
25
+ ```
26
+
27
+ ## 快速开始
28
+
29
+ ```bash
30
+ powerbase space list # 我有哪些空间
31
+ powerbase kb list # 当前空间的知识库
32
+ powerbase search chunks "合同评审流程" # 检索原文片段
33
+ powerbase chat "总结一下这份报告" # 基于知识库问答
34
+ powerbase doc upload ./报告.pdf # 上传文档(会先确认目标知识库)
35
+ ```
36
+
37
+ ## 接入 AI 办公助手
38
+
39
+ 技能是带 `SKILL.md` 的普通目录,任何支持 Agent Skills 的助手都能用:
40
+
41
+ ```bash
42
+ powerbase skills install --name powerbase --dir <助手技能目录>
43
+ ```
44
+
45
+ 常见助手的技能目录(相对用户主目录):
46
+
47
+ | 助手 | Windows | macOS |
48
+ |---|---|---|
49
+ | WorkBuddy | `%USERPROFILE%\.workbuddy\skills` | `~/.workbuddy/skills` |
50
+
51
+ 其他助手:在其设置中查看“技能/插件目录”,用同一条命令指过去即可。
52
+
53
+ ## 升级与卸载
54
+
55
+ ```bash
56
+ npm install -g @powerbase/cli@latest # 升级
57
+ npm uninstall -g @powerbase/cli # 卸载(登录态保留在系统凭据管理器)
58
+ ```
59
+
60
+ ## 说明
61
+
62
+ - 仅支持公司内网环境;公开包内的下载与更新逻辑不依赖外部服务。
63
+ - 所有命令默认输出 JSON,便于脚本和 Agent 解析;人工阅读可加 `--format text`。
@@ -1,75 +1,82 @@
1
- 'use strict';
2
-
3
- // `npx -y @powerbase/cli@latest install` 的一键安装向导:
4
- // 1) 全局安装 CLI 2) 安装 AI 技能 3) 预置连接 4) 浏览器登录(如未登录)
5
-
6
- const fs = require('node:fs');
7
- const path = require('node:path');
8
- const { spawnSync } = require('node:child_process');
9
-
10
- const PLATFORM_PACKAGES = {
11
- 'win32-x64': '@powerbase/cli-win32-x64',
12
- 'win32-arm64': '@powerbase/cli-win32-arm64',
13
- 'darwin-arm64': '@powerbase/cli-darwin-arm64',
14
- 'darwin-x64': '@powerbase/cli-darwin-x64',
15
- };
16
-
17
- function resolveBinary() {
18
- const pkg = PLATFORM_PACKAGES[`${process.platform}-${process.arch}`];
19
- if (!pkg) return null;
20
- try {
21
- const pkgJson = require.resolve(`${pkg}/package.json`);
22
- const exe = process.platform === 'win32' ? 'powerbase.exe' : 'powerbase';
23
- return path.join(path.dirname(pkgJson), 'bin', exe);
24
- } catch {
25
- return null;
26
- }
27
- }
28
-
29
- function loadConfig() {
30
- try {
31
- return JSON.parse(fs.readFileSync(path.join(__dirname, '..', 'install-config.json'), 'utf8'));
32
- } catch {
33
- return {};
34
- }
35
- }
36
-
37
- function run(cmd, args) {
38
- return spawnSync(cmd, args, { stdio: 'inherit', shell: true });
39
- }
40
-
41
- function main() {
42
- const { serverHost, webHost } = loadConfig();
43
- const skillsUrl = webHost || serverHost;
44
- console.log('正在安装 PowerBase CLI...');
45
-
46
- const installed = run('npm', ['install', '-g', '@powerbase/cli@latest']);
47
- if (installed.status !== 0) {
48
- console.error('全局安装失败。请重试:npm install -g @powerbase/cli');
49
- return 1;
50
- }
51
-
52
- if (skillsUrl) {
53
- console.log('正在安装 AI 技能...');
54
- const skills = run('npx', ['-y', 'skills', 'add', skillsUrl, '--skill', 'powerbase', '-y', '-g']);
55
- if (skills.status !== 0) {
56
- console.warn(`技能安装失败。可稍后手动执行:npx -y skills add ${skillsUrl} --skill powerbase -y -g`);
57
- }
58
- }
59
-
60
- const binary = resolveBinary();
61
- if (binary && serverHost) {
62
- spawnSync(binary, ['profile', 'add', 'powerbase', '--host', serverHost, '--use'], { stdio: 'ignore' });
63
- const status = spawnSync(binary, ['auth', 'status'], { stdio: 'ignore' });
64
- if (status.status !== 0) {
65
- console.log('接下来需要在浏览器中完成登录授权...');
66
- spawnSync(binary, ['auth', 'login'], { stdio: 'inherit' });
67
- }
68
- }
69
-
70
- console.log('安装完成!重启你的 AI 助手即可使用。');
71
- console.log('升级命令:npx -y @powerbase/cli@latest install');
72
- return 0;
73
- }
74
-
75
- process.exit(main());
1
+ 'use strict';
2
+
3
+ // `npx -y @powerbase/cli@latest install` 的一键安装向导:
4
+ // 1) 全局安装 CLI 2) 安装 AI 技能 3) 预置连接 4) 浏览器登录(如未登录)
5
+
6
+ const fs = require('node:fs');
7
+ const path = require('node:path');
8
+ const { spawnSync } = require('node:child_process');
9
+
10
+ const PLATFORM_PACKAGES = {
11
+ 'win32-x64': '@powerbase/cli-win32-x64',
12
+ 'win32-arm64': '@powerbase/cli-win32-arm64',
13
+ 'darwin-arm64': '@powerbase/cli-darwin-arm64',
14
+ 'darwin-x64': '@powerbase/cli-darwin-x64',
15
+ };
16
+
17
+ function resolveBinary() {
18
+ const pkg = PLATFORM_PACKAGES[`${process.platform}-${process.arch}`];
19
+ if (!pkg) return null;
20
+ try {
21
+ const pkgJson = require.resolve(`${pkg}/package.json`);
22
+ const exe = process.platform === 'win32' ? 'powerbase.exe' : 'powerbase';
23
+ return path.join(path.dirname(pkgJson), 'bin', exe);
24
+ } catch {
25
+ return null;
26
+ }
27
+ }
28
+
29
+ function loadConfig() {
30
+ try {
31
+ return JSON.parse(fs.readFileSync(path.join(__dirname, '..', 'install-config.json'), 'utf8'));
32
+ } catch {
33
+ return {};
34
+ }
35
+ }
36
+
37
+ function run(cmd, args) {
38
+ return spawnSync(cmd, args, { stdio: 'inherit', shell: true });
39
+ }
40
+
41
+ function main() {
42
+ const { serverHost, webHost } = loadConfig();
43
+ const skillsUrl = webHost || serverHost;
44
+ console.log('正在安装 PowerBase CLI...');
45
+
46
+ let installed = run('npm', ['install', '-g', '@powerbase/cli@latest']);
47
+ if (installed.status !== 0) {
48
+ console.log('默认源未取到最新版本,改用官方 registry 重试...');
49
+ installed = run('npm', ['install', '-g', '@powerbase/cli@latest', '--registry', 'https://registry.npmjs.org']);
50
+ }
51
+ if (installed.status !== 0) {
52
+ console.error('全局安装失败。请重试:npm install -g @powerbase/cli');
53
+ return 1;
54
+ }
55
+
56
+ if (skillsUrl) {
57
+ console.log('正在安装 AI 技能...');
58
+ let skills = run('npx', ['-y', 'skills', 'add', skillsUrl, '--skill', 'powerbase', '-y', '-g']);
59
+ if (skills.status !== 0) {
60
+ skills = run('npx', ['--registry', 'https://registry.npmjs.org', '-y', 'skills', 'add', skillsUrl, '--skill', 'powerbase', '-y', '-g']);
61
+ }
62
+ if (skills.status !== 0) {
63
+ console.warn(`技能安装失败。可稍后手动执行:npx -y skills add ${skillsUrl} --skill powerbase -y -g`);
64
+ }
65
+ }
66
+
67
+ const binary = resolveBinary();
68
+ if (binary && serverHost) {
69
+ spawnSync(binary, ['profile', 'add', 'powerbase', '--host', serverHost, '--use'], { stdio: 'ignore' });
70
+ const status = spawnSync(binary, ['auth', 'status'], { stdio: 'ignore' });
71
+ if (status.status !== 0) {
72
+ console.log('接下来需要在浏览器中完成登录授权...');
73
+ spawnSync(binary, ['auth', 'login'], { stdio: 'inherit' });
74
+ }
75
+ }
76
+
77
+ console.log('安装完成!重启你的 AI 助手即可使用。');
78
+ console.log('升级命令:npx -y @powerbase/cli@latest install');
79
+ return 0;
80
+ }
81
+
82
+ process.exit(main());
package/bin/powerbase.js CHANGED
@@ -1,52 +1,52 @@
1
- #!/usr/bin/env node
2
- 'use strict';
3
-
4
- const path = require('node:path');
5
- const { spawnSync } = require('node:child_process');
6
-
7
- const PLATFORM_PACKAGES = {
8
- 'win32-x64': '@powerbase/cli-win32-x64',
9
- 'win32-arm64': '@powerbase/cli-win32-arm64',
10
- 'darwin-arm64': '@powerbase/cli-darwin-arm64',
11
- 'darwin-x64': '@powerbase/cli-darwin-x64',
12
- };
13
-
14
- if (process.argv[2] === 'install') {
15
- require('./install-wizard.js');
16
- return;
17
- }
18
-
19
- function resolveBinary() {
20
- const key = `${process.platform}-${process.arch}`;
21
- const pkg = PLATFORM_PACKAGES[key];
22
- if (!pkg) {
23
- console.error(
24
- `PowerBase CLI 暂不支持当前系统:${process.platform}-${process.arch}\n` +
25
- `支持的平台:${Object.keys(PLATFORM_PACKAGES).join(', ')}`,
26
- );
27
- process.exit(1);
28
- }
29
- try {
30
- const pkgJson = require.resolve(`${pkg}/package.json`);
31
- const exe = process.platform === 'win32' ? 'powerbase.exe' : 'powerbase';
32
- return path.join(path.dirname(pkgJson), 'bin', exe);
33
- } catch {
34
- console.error(
35
- `PowerBase CLI 缺少平台组件 ${pkg}。\n` +
36
- `请重新安装:npm install -g @powerbase/cli\n` +
37
- `(若使用了 --omit=optional,请去掉后重装。)`,
38
- );
39
- process.exit(1);
40
- }
41
- }
42
-
43
- const result = spawnSync(resolveBinary(), process.argv.slice(2), { stdio: 'inherit' });
44
-
45
- if (result.error) {
46
- console.error(`PowerBase CLI 启动失败:${result.error.message}`);
47
- process.exit(1);
48
- }
49
- if (result.signal) {
50
- process.kill(process.pid, result.signal);
51
- }
52
- process.exit(result.status === null ? 1 : result.status);
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+
4
+ const path = require('node:path');
5
+ const { spawnSync } = require('node:child_process');
6
+
7
+ const PLATFORM_PACKAGES = {
8
+ 'win32-x64': '@powerbase/cli-win32-x64',
9
+ 'win32-arm64': '@powerbase/cli-win32-arm64',
10
+ 'darwin-arm64': '@powerbase/cli-darwin-arm64',
11
+ 'darwin-x64': '@powerbase/cli-darwin-x64',
12
+ };
13
+
14
+ if (process.argv[2] === 'install') {
15
+ require('./install-wizard.js');
16
+ return;
17
+ }
18
+
19
+ function resolveBinary() {
20
+ const key = `${process.platform}-${process.arch}`;
21
+ const pkg = PLATFORM_PACKAGES[key];
22
+ if (!pkg) {
23
+ console.error(
24
+ `PowerBase CLI 暂不支持当前系统:${process.platform}-${process.arch}\n` +
25
+ `支持的平台:${Object.keys(PLATFORM_PACKAGES).join(', ')}`,
26
+ );
27
+ process.exit(1);
28
+ }
29
+ try {
30
+ const pkgJson = require.resolve(`${pkg}/package.json`);
31
+ const exe = process.platform === 'win32' ? 'powerbase.exe' : 'powerbase';
32
+ return path.join(path.dirname(pkgJson), 'bin', exe);
33
+ } catch {
34
+ console.error(
35
+ `PowerBase CLI 缺少平台组件 ${pkg}。\n` +
36
+ `请重新安装:npm install -g @powerbase/cli\n` +
37
+ `(若使用了 --omit=optional,请去掉后重装。)`,
38
+ );
39
+ process.exit(1);
40
+ }
41
+ }
42
+
43
+ const result = spawnSync(resolveBinary(), process.argv.slice(2), { stdio: 'inherit' });
44
+
45
+ if (result.error) {
46
+ console.error(`PowerBase CLI 启动失败:${result.error.message}`);
47
+ process.exit(1);
48
+ }
49
+ if (result.signal) {
50
+ process.kill(process.pid, result.signal);
51
+ }
52
+ process.exit(result.status === null ? 1 : result.status);
@@ -1,4 +1,4 @@
1
1
  {
2
- "serverHost": "http://192.168.5.66:2447",
3
- "webHost": "http://192.168.5.66:2446"
2
+ "serverHost": "https://powerbase.mybjx.net",
3
+ "webHost": "https://powerbase.mybjx.net"
4
4
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@powerbase/cli",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "PowerBase CLI - query and manage PowerBase knowledge bases from the terminal",
5
5
  "license": "MIT",
6
6
  "bin": {
@@ -19,9 +19,9 @@
19
19
  "node": "\u003e=18"
20
20
  },
21
21
  "optionalDependencies": {
22
- "@powerbase/cli-win32-x64": "0.1.1",
23
- "@powerbase/cli-win32-arm64": "0.1.1",
24
- "@powerbase/cli-darwin-arm64": "0.1.1",
25
- "@powerbase/cli-darwin-x64": "0.1.1"
22
+ "@powerbase/cli-win32-x64": "0.1.3",
23
+ "@powerbase/cli-win32-arm64": "0.1.3",
24
+ "@powerbase/cli-darwin-arm64": "0.1.3",
25
+ "@powerbase/cli-darwin-x64": "0.1.3"
26
26
  }
27
27
  }
@@ -1,54 +1,54 @@
1
- 'use strict';
2
-
3
- // 全局安装时预置默认 profile,员工装完只需 auth login。
4
- // 任何异常都不阻断安装:失败时打印提示,由用户手动执行同样命令。
5
-
6
- const fs = require('node:fs');
7
- const path = require('node:path');
8
- const { spawnSync } = require('node:child_process');
9
-
10
- if (String(process.env.npm_config_global) !== 'true') process.exit(0);
11
-
12
- const PLATFORM_PACKAGES = {
13
- 'win32-x64': '@powerbase/cli-win32-x64',
14
- 'win32-arm64': '@powerbase/cli-win32-arm64',
15
- 'darwin-arm64': '@powerbase/cli-darwin-arm64',
16
- 'darwin-x64': '@powerbase/cli-darwin-x64',
17
- };
18
-
19
- function resolveBinary() {
20
- const pkg = PLATFORM_PACKAGES[`${process.platform}-${process.arch}`];
21
- if (!pkg) return null;
22
- try {
23
- const pkgJson = require.resolve(`${pkg}/package.json`);
24
- const exe = process.platform === 'win32' ? 'powerbase.exe' : 'powerbase';
25
- return path.join(path.dirname(pkgJson), 'bin', exe);
26
- } catch {
27
- return null;
28
- }
29
- }
30
-
31
- try {
32
- const configPath = path.join(__dirname, '..', 'install-config.json');
33
- if (!fs.existsSync(configPath)) process.exit(0);
34
- const { serverHost } = JSON.parse(fs.readFileSync(configPath, 'utf8'));
35
- if (!serverHost) process.exit(0);
36
-
37
- const binary = resolveBinary();
38
- if (!binary) process.exit(0);
39
-
40
- const result = spawnSync(
41
- binary,
42
- ['profile', 'add', 'powerbase', '--host', serverHost, '--use', '--format', 'json'],
43
- { encoding: 'utf8' },
44
- );
45
- if (result.status !== 0) {
46
- const output = `${result.stdout || ''}${result.stderr || ''}`;
47
- if (!output.includes('already exists')) {
48
- console.warn(`PowerBase CLI: 未能自动创建默认连接,请手动执行:powerbase profile add powerbase --host ${serverHost} --use`);
49
- }
50
- }
51
- } catch {
52
- // 静默:安装不应因预置失败而中止。
53
- }
54
- process.exit(0);
1
+ 'use strict';
2
+
3
+ // 全局安装时预置默认 profile,员工装完只需 auth login。
4
+ // 任何异常都不阻断安装:失败时打印提示,由用户手动执行同样命令。
5
+
6
+ const fs = require('node:fs');
7
+ const path = require('node:path');
8
+ const { spawnSync } = require('node:child_process');
9
+
10
+ if (String(process.env.npm_config_global) !== 'true') process.exit(0);
11
+
12
+ const PLATFORM_PACKAGES = {
13
+ 'win32-x64': '@powerbase/cli-win32-x64',
14
+ 'win32-arm64': '@powerbase/cli-win32-arm64',
15
+ 'darwin-arm64': '@powerbase/cli-darwin-arm64',
16
+ 'darwin-x64': '@powerbase/cli-darwin-x64',
17
+ };
18
+
19
+ function resolveBinary() {
20
+ const pkg = PLATFORM_PACKAGES[`${process.platform}-${process.arch}`];
21
+ if (!pkg) return null;
22
+ try {
23
+ const pkgJson = require.resolve(`${pkg}/package.json`);
24
+ const exe = process.platform === 'win32' ? 'powerbase.exe' : 'powerbase';
25
+ return path.join(path.dirname(pkgJson), 'bin', exe);
26
+ } catch {
27
+ return null;
28
+ }
29
+ }
30
+
31
+ try {
32
+ const configPath = path.join(__dirname, '..', 'install-config.json');
33
+ if (!fs.existsSync(configPath)) process.exit(0);
34
+ const { serverHost } = JSON.parse(fs.readFileSync(configPath, 'utf8'));
35
+ if (!serverHost) process.exit(0);
36
+
37
+ const binary = resolveBinary();
38
+ if (!binary) process.exit(0);
39
+
40
+ const result = spawnSync(
41
+ binary,
42
+ ['profile', 'add', 'powerbase', '--host', serverHost, '--use', '--format', 'json'],
43
+ { encoding: 'utf8' },
44
+ );
45
+ if (result.status !== 0) {
46
+ const output = `${result.stdout || ''}${result.stderr || ''}`;
47
+ if (!output.includes('already exists')) {
48
+ console.warn(`PowerBase CLI: 未能自动创建默认连接,请手动执行:powerbase profile add powerbase --host ${serverHost} --use`);
49
+ }
50
+ }
51
+ } catch {
52
+ // 静默:安装不应因预置失败而中止。
53
+ }
54
+ process.exit(0);