@finebi/finebi-cli 1.2.0 → 1.3.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.
- package/README.md +62 -142
- package/package.json +38 -35
- package/skills/finebi-cli-agent/SKILL.md +133 -0
- package/skills/finebi-cli-agent/agents/openai.yaml +7 -0
- package/skills/finebi-cli-agent/references/analysis-dsl-api.md +318 -0
- package/skills/finebi-cli-agent/references/artifact-ordering.md +29 -0
- package/skills/finebi-cli-agent/references/command-workflows.md +194 -0
- package/skills/finebi-cli-agent/references/dashboard-dsl-api.md +1025 -0
- package/skills/finebi-cli-agent/references/dsl-handoff-contract.md +195 -0
- package/skills/finebi-cli-agent/references/file-to-dashboard.md +65 -0
- package/skills/finebi-cli-agent/references/formula-basics.md +102 -0
- package/skills/finebi-cli-agent/references/formula-contexts.md +66 -0
- package/skills/finebi-cli-agent/references/formula-functions.md +247 -0
- package/skills/finebi-cli-agent/references/formula-generation.md +121 -0
- package/skills/finebi-cli-agent/references/formula-glossary.md +17 -0
- package/skills/finebi-cli-agent/references/formula-help-boundaries.md +87 -0
- package/skills/finebi-cli-agent/references/formula-help-index.md +264 -0
- package/skills/finebi-cli-agent/references/formula-parameters-aggregate.md +143 -0
- package/skills/finebi-cli-agent/references/formula-parameters-analysis.md +223 -0
- package/skills/finebi-cli-agent/references/formula-parameters-date.md +236 -0
- package/skills/finebi-cli-agent/references/formula-parameters-math-logic.md +271 -0
- package/skills/finebi-cli-agent/references/formula-parameters-text.md +217 -0
- package/skills/finebi-cli-agent/references/formula-recipes-analysis.md +124 -0
- package/skills/finebi-cli-agent/references/formula-recipes-text-date.md +86 -0
- package/skills/finebi-cli-agent/references/formula-semantics.md +39 -0
- package/skills/finebi-cli-agent/references/formula-syntax.md +70 -0
- package/skills/finebi-cli-agent/references/formula-troubleshooting.md +63 -0
- package/skills/finebi-cli-agent/references/formula-validation.md +36 -0
- package/skills/finebi-cli-agent/references/formula.md +37 -0
- package/skills/finebi-cli-agent/references/handoff-contract.md +210 -0
- package/skills/finebi-cli-agent/references/mapping-rules.md +423 -0
- package/skills/finebi-cli-agent/references/mutation-confirmation-contract.md +150 -0
- package/skills/finebi-cli-agent/references/scenario-workflows.md +75 -0
- package/skills/finebi-cli-agent/references/widget-dsl-api-examples.md +457 -0
- package/skills/finebi-cli-agent/references/widget-dsl-api.md +1340 -0
- package/skills/finebi-cli-agent/scripts/finebi-cli/package.json +11 -0
- package/skills/finebi-cli-agent/scripts/finebi-cli/src/access-key-contract.js +2 -0
- package/skills/finebi-cli-agent/scripts/finebi-cli/src/access-key.js +174 -0
- package/skills/finebi-cli-agent/scripts/finebi-cli/src/auth-failure.js +18 -0
- package/skills/finebi-cli-agent/scripts/finebi-cli/src/auth-headers.js +21 -0
- package/skills/finebi-cli-agent/scripts/finebi-cli/src/auth.js +116 -0
- package/skills/finebi-cli-agent/scripts/finebi-cli/src/branding.js +31 -0
- package/skills/finebi-cli-agent/scripts/finebi-cli/src/browser-auth.js +331 -0
- package/skills/finebi-cli-agent/scripts/finebi-cli/src/capability.js +122 -0
- package/skills/finebi-cli-agent/scripts/finebi-cli/src/config-permissions.js +87 -0
- package/skills/finebi-cli-agent/scripts/finebi-cli/src/config.js +189 -0
- package/skills/finebi-cli-agent/scripts/finebi-cli/src/dynamic-command.js +324 -0
- package/skills/finebi-cli-agent/scripts/finebi-cli/src/error-catalog.js +482 -0
- package/skills/finebi-cli-agent/scripts/finebi-cli/src/errors.js +22 -0
- package/skills/finebi-cli-agent/scripts/finebi-cli/src/help.js +467 -0
- package/skills/finebi-cli-agent/scripts/finebi-cli/src/index.js +1343 -0
- package/skills/finebi-cli-agent/scripts/finebi-cli/src/install-skill.js +87 -0
- package/skills/finebi-cli-agent/scripts/finebi-cli/src/output-limits.js +188 -0
- package/skills/finebi-cli-agent/scripts/finebi-cli/src/output.js +33 -0
- package/skills/finebi-cli-agent/scripts/finebi-cli/src/profiles.js +158 -0
- package/skills/finebi-cli-agent/scripts/finebi-cli/src/schema-options.js +265 -0
- package/skills/finebi-cli-agent/scripts/finebi-cli/src/schema-validator.js +194 -0
- package/skills/finebi-cli-agent/scripts/finebi-cli/src/skill-files.js +94 -0
- package/skills/finebi-cli-agent/scripts/finebi-cli-runner-core.mjs +399 -0
- package/skills/finebi-cli-agent/scripts/finebi-cli-runner.mjs +29 -0
- package/src/error-catalog.js +12 -0
- package/src/help.js +15 -0
- package/src/index.js +6 -1
- package/src/install-skill.js +87 -0
- package/src/skill-files.js +94 -0
package/README.md
CHANGED
|
@@ -7,112 +7,10 @@ Array options take a JSON array as one argument, for example `--values '["上海
|
|
|
7
7
|
## Install
|
|
8
8
|
|
|
9
9
|
```powershell
|
|
10
|
-
npm install -g @finebi/finebi-cli --registry=https://registry.npmjs.org/
|
|
10
|
+
npm install -g @finebi/finebi-cli --registry=https://registry.npmjs.org/
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
```powershell
|
|
16
|
-
cd D:\project\ino-7.0\nuclear-all\plugin-bi-finecli\cli
|
|
17
|
-
npm link
|
|
18
|
-
finebi-cli --help
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
After `npm link`, edits under `src` are picked up by the global `finebi-cli` command without linking again. If `finebi-cli` was installed from a packed `.tgz`, rebuild and reinstall the package after code changes:
|
|
22
|
-
|
|
23
|
-
```powershell
|
|
24
|
-
cd D:\project\ino-7.0\nuclear-all\plugin-bi-finecli\cli
|
|
25
|
-
npm run pack:cli
|
|
26
|
-
npm install -g .\finebi-finebi-cli-1.0.0.tgz
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
On Windows, use `where finebi-cli` if the command does not appear to update. Multiple Node.js/npm installations can leave more than one global command shim on `PATH`.
|
|
30
|
-
|
|
31
|
-
## Publish an Update
|
|
32
|
-
|
|
33
|
-
Publish from this `cli` directory. A published npm version is immutable, so increment the version before every release. Make and commit the functional changes first, then run the following release checks and version update:
|
|
34
|
-
|
|
35
|
-
```powershell
|
|
36
|
-
cd D:\project\ino-7.0\nuclear-all\plugin-bi-finecli\cli
|
|
37
|
-
npm test
|
|
38
|
-
npm run verify:pack
|
|
39
|
-
npm version patch --no-git-tag-version
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
Use `patch` for bug fixes, `minor` for backward-compatible features, and `major` for breaking changes. `npm version` updates both `package.json` and `package-lock.json`. Review and commit the release version with a Chinese Conventional Commit message, then log in with an npm account authorized to publish under `@finebi`. The package publishes publicly to the official npm registry:
|
|
43
|
-
|
|
44
|
-
```powershell
|
|
45
|
-
git add package.json package-lock.json
|
|
46
|
-
git commit -m "chore(cli): 发布 1.0.1"
|
|
47
|
-
npm login --registry=https://registry.npmjs.org/
|
|
48
|
-
npm publish --registry=https://registry.npmjs.org/ --access public
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
After a successful publish, verify the registry version and install it. Public package installation does not require npm authentication:
|
|
52
|
-
|
|
53
|
-
```powershell
|
|
54
|
-
npm view @finebi/finebi-cli version --registry=https://registry.npmjs.org/
|
|
55
|
-
npm install -g @finebi/finebi-cli@latest --registry=https://registry.npmjs.org/
|
|
56
|
-
finebi-cli version
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
## Testing
|
|
60
|
-
|
|
61
|
-
Run these commands from the repository root. On Windows PowerShell use `npm.cmd`; on Linux/macOS use `npm`:
|
|
62
|
-
|
|
63
|
-
```powershell
|
|
64
|
-
npm.cmd --prefix cli test
|
|
65
|
-
npm.cmd --prefix cli run test:integration:stub
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
Linux/macOS:
|
|
69
|
-
|
|
70
|
-
```bash
|
|
71
|
-
npm --prefix cli test
|
|
72
|
-
npm --prefix cli run test:integration:stub
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
For a real FineBI environment, use the corresponding integration script:
|
|
76
|
-
|
|
77
|
-
Windows PowerShell:
|
|
78
|
-
|
|
79
|
-
```powershell
|
|
80
|
-
npm.cmd --prefix cli run test:integration:readonly
|
|
81
|
-
npm.cmd --prefix cli run test:integration:mutating
|
|
82
|
-
npm.cmd --prefix cli run test:integration:real
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
Linux/macOS:
|
|
86
|
-
|
|
87
|
-
```bash
|
|
88
|
-
npm --prefix cli run test:integration:readonly
|
|
89
|
-
npm --prefix cli run test:integration:mutating
|
|
90
|
-
npm --prefix cli run test:integration:real
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
### Real integration prerequisites
|
|
94
|
-
|
|
95
|
-
Before running a real FineBI test, configure all of the following:
|
|
96
|
-
|
|
97
|
-
- `cli/tests/fixtures/finebi-integration-environment.json`: set `ready` to `true`, and provide a reachable HTTP(S) `baseUrl`, the test `username`, a positive `revision`, and `passwordSource` pointing to `FINEBI_INTEGRATION_PASSWORD`. `reportDir` may be a relative default or an absolute path.
|
|
98
|
-
- `cli/tests/fixtures/capabilities/`: keep the per-resource snapshots valid and synchronized with the deployed plugin/environment. The commands and request schemas in real cases are checked against this Capability snapshot (aggregated by `fixtures/capabilities/load.js`).
|
|
99
|
-
- `cli/tests/real-cases/*.json`: enable at least one case with `enabled: true`. Readonly cases must use `mutation: false` commands; mutating cases must declare scoped cleanup for resources created by that case.
|
|
100
|
-
- FineBI: deploy the plugin version corresponding to the current source and verify that the configured account can log in and access the required resources. Run mutating cases only in a dedicated test environment.
|
|
101
|
-
- Credentials: inject the password through the environment variable before starting the test. `xxxx` below is only a placeholder and must be replaced locally or by CI Secret injection.
|
|
102
|
-
|
|
103
|
-
Windows PowerShell:
|
|
104
|
-
|
|
105
|
-
```powershell
|
|
106
|
-
$env:FINEBI_INTEGRATION_PASSWORD = 'xxxx'
|
|
107
|
-
```
|
|
108
|
-
|
|
109
|
-
Linux/macOS:
|
|
110
|
-
|
|
111
|
-
```bash
|
|
112
|
-
export FINEBI_INTEGRATION_PASSWORD='xxxx'
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
Do not commit the real value or place it in case JSON, CLI arguments, logs, or reports. If `--report-dir` is supplied, it must be an existing writable absolute directory; `--case` can narrow the run to one enabled case. See the complete [CLI testing guide](../docs/cli-testing/20260804-finebi-real-integration/cli-testing-guide.md) for platform-specific setup, real-case authoring with the `finebi-cli-case-authoring` skill, cleanup rules, and report troubleshooting.
|
|
13
|
+
This package includes the CLI and the complete `finebi-cli-agent` Skill. Contact service personnel to obtain the FineBI server plugin and have an administrator install or enable it before connecting to FineBI.
|
|
116
14
|
|
|
117
15
|
## Usage
|
|
118
16
|
|
|
@@ -142,39 +40,39 @@ finebi-cli <resource> --help
|
|
|
142
40
|
finebi-cli <resource> <command> [options]
|
|
143
41
|
```
|
|
144
42
|
|
|
145
|
-
Run `finebi-cli capability refresh` manually when backend commands changed, the cache expired, or you want to force a reload.
|
|
146
|
-
|
|
147
|
-
### Multiple environments
|
|
148
|
-
|
|
149
|
-
Create an environment by logging in with its name and address:
|
|
150
|
-
|
|
151
|
-
```powershell
|
|
152
|
-
finebi-cli auth login --profile test --base-url https://test.example.com/webroot/decision --browser
|
|
153
|
-
finebi-cli auth login --profile prod --base-url https://prod.example.com/webroot/decision --username admin --password-stdin
|
|
154
|
-
finebi-cli auth list
|
|
155
|
-
finebi-cli auth use test
|
|
156
|
-
finebi-cli capability info --profile prod
|
|
157
|
-
finebi-cli auth info --profile prod
|
|
158
|
-
finebi-cli config set timeout-ms 60000 --profile prod
|
|
159
|
-
finebi-cli auth logout --profile prod
|
|
160
|
-
finebi-cli auth remove prod
|
|
161
|
-
```
|
|
162
|
-
|
|
163
|
-
Successful login selects that environment as the default; add `--no-use` to keep the existing default. Login to an existing name reuses its address unless overridden. A new name requires `--base-url` or `FINEBI_BASE_URL` and never inherits another environment's identity. Failed authentication leaves existing environments and the default unchanged.
|
|
164
|
-
|
|
165
|
-
Selection order is `--profile` > `FINEBI_PROFILE` > saved default. The option works before or after the command. Ordinary commands never create missing environments or change the default. Names are case-sensitive, 1–64 ASCII letters/digits/underscores/hyphens, beginning with a letter or digit. `auth list` shows local metadata only, not a live authentication check. JSON responses identify the selected environment in `meta.profile`.
|
|
166
|
-
|
|
167
|
-
Each environment has separate credentials, connection settings and capabilities. Changing its saved `base-url` clears its credentials and cache. Temporary URL/token overrides do not change saved configuration; a different URL never inherits saved credentials. Requests with temporary credentials fetch capabilities for that invocation without overwriting a saved cache. Explicit session tokens take precedence over saved Access Keys.
|
|
168
|
-
|
|
169
|
-
`auth logout` revokes the selected environment's saved Key and keeps its connection settings. `auth remove <name>` and `config clear --profile <name>` delete only that local environment and cache, without revoking server credentials. Removing the default does not automatically select another saved environment. Persistent configuration and logout operations use the selected saved environment, not connection override variables.
|
|
170
|
-
|
|
171
|
-
Existing single-environment configuration is exposed as `default`; read-only commands do not rewrite it. Multi-environment writes migrate it while preserving its credentials and default capability cache. See the [command contract](../docs/commands/README.md#多环境管理) for the complete behavior.
|
|
172
|
-
|
|
173
|
-
## Access Key
|
|
43
|
+
Run `finebi-cli capability refresh` manually when backend commands changed, the cache expired, or you want to force a reload.
|
|
44
|
+
|
|
45
|
+
### Multiple environments
|
|
46
|
+
|
|
47
|
+
Create an environment by logging in with its name and address:
|
|
48
|
+
|
|
49
|
+
```powershell
|
|
50
|
+
finebi-cli auth login --profile test --base-url https://test.example.com/webroot/decision --browser
|
|
51
|
+
finebi-cli auth login --profile prod --base-url https://prod.example.com/webroot/decision --username admin --password-stdin
|
|
52
|
+
finebi-cli auth list
|
|
53
|
+
finebi-cli auth use test
|
|
54
|
+
finebi-cli capability info --profile prod
|
|
55
|
+
finebi-cli auth info --profile prod
|
|
56
|
+
finebi-cli config set timeout-ms 60000 --profile prod
|
|
57
|
+
finebi-cli auth logout --profile prod
|
|
58
|
+
finebi-cli auth remove prod
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Successful login selects that environment as the default; add `--no-use` to keep the existing default. Login to an existing name reuses its address unless overridden. A new name requires `--base-url` or `FINEBI_BASE_URL` and never inherits another environment's identity. Failed authentication leaves existing environments and the default unchanged.
|
|
62
|
+
|
|
63
|
+
Selection order is `--profile` > `FINEBI_PROFILE` > saved default. The option works before or after the command. Ordinary commands never create missing environments or change the default. Names are case-sensitive, 1–64 ASCII letters/digits/underscores/hyphens, beginning with a letter or digit. `auth list` shows local metadata only, not a live authentication check. JSON responses identify the selected environment in `meta.profile`.
|
|
64
|
+
|
|
65
|
+
Each environment has separate credentials, connection settings and capabilities. Changing its saved `base-url` clears its credentials and cache. Temporary URL/token overrides do not change saved configuration; a different URL never inherits saved credentials. Requests with temporary credentials fetch capabilities for that invocation without overwriting a saved cache. Explicit session tokens take precedence over saved Access Keys.
|
|
66
|
+
|
|
67
|
+
`auth logout` revokes the selected environment's saved Key and keeps its connection settings. `auth remove <name>` and `config clear --profile <name>` delete only that local environment and cache, without revoking server credentials. Removing the default does not automatically select another saved environment. Persistent configuration and logout operations use the selected saved environment, not connection override variables.
|
|
68
|
+
|
|
69
|
+
Existing single-environment configuration is exposed as `default`; read-only commands do not rewrite it. Multi-environment writes migrate it while preserving its credentials and default capability cache. See the [command contract](../docs/commands/README.md#多环境管理) for the complete behavior.
|
|
70
|
+
|
|
71
|
+
## Access Key
|
|
174
72
|
|
|
175
73
|
After a successful `auth login`, the CLI automatically issues a long-lived Access Key so commands keep working after the short-lived session token (JWT) expires:
|
|
176
74
|
|
|
177
|
-
- Login provisions a key with description `finebi-cli@<hostname>` for `default`, or `finebi-cli@<hostname>/<profile>` for a named environment, replacing stale keys with the same description. The plaintext key is stored in the environment's `auth.accessKey` and never printed. On POSIX systems, the CLI enforces mode `0700` on the config directory and `0600` on `config.json`. On Windows, it removes inherited ACLs and grants access only to the current user, SYSTEM, and Administrators; failures emit a security warning.
|
|
75
|
+
- Login provisions a key with description `finebi-cli@<hostname>` for `default`, or `finebi-cli@<hostname>/<profile>` for a named environment, replacing stale keys with the same description. The plaintext key is stored in the environment's `auth.accessKey` and never printed. On POSIX systems, the CLI enforces mode `0700` on the config directory and `0600` on `config.json`. On Windows, it removes inherited ACLs and grants access only to the current user, SYSTEM, and Administrators; failures emit a security warning.
|
|
178
76
|
- Business commands send `X-FineBI-CLI-Access-Key` when a key is present, and fall back to the session token otherwise.
|
|
179
77
|
- Add `--no-access-key` to `auth login` to skip issuance and stay on the session token.
|
|
180
78
|
- `auth info` shows `authMode` (`access-key` / `session-token` / `none`) with both the session token and Access Key masked.
|
|
@@ -202,9 +100,31 @@ For complex file-based resources, do not expect command help to contain a comple
|
|
|
202
100
|
|
|
203
101
|
## Agent Skills
|
|
204
102
|
|
|
205
|
-
|
|
103
|
+
Install the bundled `finebi-cli-agent` Skill into your Agent's directory:
|
|
104
|
+
|
|
105
|
+
```powershell
|
|
106
|
+
finebi-cli install-skill --list
|
|
107
|
+
finebi-cli install-skill --agents codex,cursor
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
Run `finebi-cli install-skill` in an interactive terminal to choose Agents. Non-interactive use requires `--agents`. Supported IDs are `claude-code`, `codex`, `cursor`, `gemini-cli`, `github-copilot`, `opencode`, `cline`, `windsurf`, `trae`, `trae-cn`, `openclaw`, `roo`, and `qwen-code`. Custom `CODEX_HOME`, `CLAUDE_CONFIG_DIR`, and `XDG_CONFIG_HOME` directories are respected.
|
|
206
111
|
|
|
207
|
-
|
|
112
|
+
Skill installation is local and does not require a server connection or credentials. It copies the Skill included in this installed npm version, including its own CLI runtime. Restart your Agent or refresh its Skills after installation. npm installation alone does not install Skills into Agent directories.
|
|
113
|
+
|
|
114
|
+
To update, install the latest CLI package and run `install-skill` again:
|
|
115
|
+
|
|
116
|
+
```powershell
|
|
117
|
+
npm install -g @finebi/finebi-cli@latest --registry=https://registry.npmjs.org/
|
|
118
|
+
finebi-cli install-skill --agents codex,cursor
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
Identical installations are left unchanged. Unmodified managed Skills are backed up and updated automatically. Local edits and installations without a recorded checksum are kept, and the command reports an incomplete installation. To explicitly replace them with a backup:
|
|
122
|
+
|
|
123
|
+
```powershell
|
|
124
|
+
finebi-cli install-skill --agents codex --replace
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
Backups are stored under `~/.finebi-cli/skill-backups/`; installation records are in `~/.finebi-cli/installation.json`. The command preserves other records and does not change authentication or connection configuration. The Skill follows the discovery flow above and treats dynamic command help as the source of truth after capability refresh.
|
|
208
128
|
|
|
209
129
|
## Output
|
|
210
130
|
|
|
@@ -302,11 +222,11 @@ echo your-password | finebi-cli auth login --username 1 --password-stdin
|
|
|
302
222
|
## Local Files
|
|
303
223
|
|
|
304
224
|
- Config: `%USERPROFILE%\.finebi-cli\config.json`
|
|
305
|
-
- Capability cache: `%USERPROFILE%\.finebi-cli\capabilities.json`
|
|
306
|
-
- Named environment caches: `%USERPROFILE%\.finebi-cli\capabilities-profile-<hex-encoded-name>.json` (`default` uses `capabilities.json`).
|
|
307
|
-
|
|
308
|
-
Multi-environment `config.json` stores `schemaVersion: 2`, `currentProfile` (nullable), and a `profiles` object keyed by environment name. Writes are serialized with a short-lived `config.json.lock` and atomically replace the configuration file. A lock timeout reports an error without modifying the file.
|
|
309
|
-
|
|
310
|
-
Concurrent logins to the same environment are rejected using `config.json.login-<hex-encoded-name>.lock`; different environments may log in concurrently. Locks are released when the operation settles. If a process is forcibly terminated and leaves a lock behind, verify that the owning operation has stopped before manually removing that lock file.
|
|
225
|
+
- Capability cache: `%USERPROFILE%\.finebi-cli\capabilities.json`
|
|
226
|
+
- Named environment caches: `%USERPROFILE%\.finebi-cli\capabilities-profile-<hex-encoded-name>.json` (`default` uses `capabilities.json`).
|
|
227
|
+
|
|
228
|
+
Multi-environment `config.json` stores `schemaVersion: 2`, `currentProfile` (nullable), and a `profiles` object keyed by environment name. Writes are serialized with a short-lived `config.json.lock` and atomically replace the configuration file. A lock timeout reports an error without modifying the file.
|
|
229
|
+
|
|
230
|
+
Concurrent logins to the same environment are rejected using `config.json.login-<hex-encoded-name>.lock`; different environments may log in concurrently. Locks are released when the operation settles. If a process is forcibly terminated and leaves a lock behind, verify that the owning operation has stopped before manually removing that lock file.
|
|
311
231
|
|
|
312
232
|
Passwords are not persisted by the CLI.
|
package/package.json
CHANGED
|
@@ -1,37 +1,40 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@finebi/finebi-cli",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "FineBI dynamic capability command line client.",
|
|
5
|
-
"license": "UNLICENSED",
|
|
6
|
-
"publishConfig": {
|
|
7
|
-
"registry": "https://registry.npmjs.org/",
|
|
8
|
-
"access": "public"
|
|
9
|
-
},
|
|
10
|
-
"type": "module",
|
|
11
|
-
"bin": {
|
|
12
|
-
"finebi-cli": "./src/index.js"
|
|
13
|
-
},
|
|
14
|
-
"files": [
|
|
1
|
+
{
|
|
2
|
+
"name": "@finebi/finebi-cli",
|
|
3
|
+
"version": "1.3.0",
|
|
4
|
+
"description": "FineBI dynamic capability command line client.",
|
|
5
|
+
"license": "UNLICENSED",
|
|
6
|
+
"publishConfig": {
|
|
7
|
+
"registry": "https://registry.npmjs.org/",
|
|
8
|
+
"access": "public"
|
|
9
|
+
},
|
|
10
|
+
"type": "module",
|
|
11
|
+
"bin": {
|
|
12
|
+
"finebi-cli": "./src/index.js"
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
15
|
"src",
|
|
16
|
-
"
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
"skills",
|
|
17
|
+
"README.md"
|
|
18
|
+
],
|
|
19
|
+
"engines": {
|
|
20
|
+
"node": ">=18.17"
|
|
21
|
+
},
|
|
21
22
|
"scripts": {
|
|
22
|
-
"
|
|
23
|
-
"test:
|
|
24
|
-
"test
|
|
25
|
-
"test:
|
|
26
|
-
"test:
|
|
27
|
-
"test:
|
|
28
|
-
"test:integration:
|
|
29
|
-
"test:integration:
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
|
|
37
|
-
|
|
23
|
+
"prepack": "node ../scripts/build-finebi-cli-agent.mjs",
|
|
24
|
+
"test:pack": "node ../scripts/test-cli-package.mjs",
|
|
25
|
+
"test": "npm run test:unit && npm run test:process && npm run test:contract && npm run test:integration:stub",
|
|
26
|
+
"test:unit": "node --test tests/unit/access-key.test.js tests/unit/auth.test.js tests/unit/capability.test.js tests/unit/config-permissions.test.js tests/unit/config.test.js tests/unit/dynamic-command-forwarding.test.js tests/unit/dynamic-command-multipart.test.js tests/unit/dynamic-command-preflight.test.js tests/unit/error-catalog-loader.test.js tests/unit/error-catalog.test.js tests/unit/error-construction-guard.test.js tests/unit/help.test.js tests/unit/http-stub.test.js tests/unit/index-auth-login.test.js tests/unit/index-auth-session.test.js tests/unit/index-browser-auth.test.js tests/unit/index-config.test.js tests/unit/index-dynamic-errors.test.js tests/unit/index-dynamic-render.test.js tests/unit/index-help.test.js tests/unit/index-profiles.test.js tests/unit/install-skill.test.js tests/unit/output-limits.test.js tests/unit/output.test.js tests/unit/package.test.js tests/unit/schema-options-capability.test.js tests/unit/schema-options-file-input.test.js tests/unit/schema-options-scalar.test.js",
|
|
27
|
+
"test:process": "node --test tests/process/bench-cli-runner.test.js tests/process/process-cli.test.js tests/process/profiles-cli.test.js",
|
|
28
|
+
"test:contract": "node --test tests/contract/capability-contract.test.js",
|
|
29
|
+
"test:integration:stub": "node --test tests/integration/analysis-ds-workflows.test.js tests/integration/assertions.test.js tests/integration/auth-system.test.js tests/integration/case-loader.test.js tests/integration/cli-process.test.js tests/integration/config.test.js tests/integration/dashboard-workflows.test.js tests/integration/entry.test.js tests/integration/failure-security.test.js tests/integration/file-template.test.js tests/integration/mutating-file-input.test.js tests/integration/mutating-resource-ledger.test.js tests/integration/mutating-workflow-guards.test.js tests/integration/readonly-assertions.test.js tests/integration/readonly-file-input.test.js tests/integration/readonly-workflow-contract.test.js tests/integration/report-directory.test.js tests/integration/report-entry.test.js tests/integration/report-secrets.test.js tests/integration/report-summary-artifacts.test.js tests/integration/runner.test.js",
|
|
30
|
+
"test:integration:readonly": "node tests/integration/entry.js readonly",
|
|
31
|
+
"test:integration:mutating": "node tests/integration/entry.js mutating",
|
|
32
|
+
"test:integration:real": "node tests/integration/entry.js all",
|
|
33
|
+
"prebench": "npm test",
|
|
34
|
+
"bench": "node bench/src/runner.js",
|
|
35
|
+
"prepack:cli": "npm test",
|
|
36
|
+
"pack:cli": "npm pack",
|
|
37
|
+
"preverify:pack": "npm test",
|
|
38
|
+
"verify:pack": "npm pack --dry-run"
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: finebi-cli-agent
|
|
3
|
+
description: 使用 FineBI CLI 查询和管理 FineBI 资源,生成并应用组件(Widget)和仪表板(Dashboard)DSL,优先使用内置 CLI,也支持已安装的全局 @finebi/finebi-cli。用户需要查看或操作分析主题、数据集、计算字段、图表组件、仪表板,或配置 FineBI CLI 连接与认证时使用。
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# FineBI CLI Agent
|
|
7
|
+
|
|
8
|
+
## 目标
|
|
9
|
+
|
|
10
|
+
优先使用本 Skill 内置的 CLI 完成 FineBI 资源发现、读取、DSL 制品生成和安全写入,也允许使用通过 npm 安装的全局 `@finebi/finebi-cli`。不得依赖原始源码仓库,也不得调用仓库外的另一项 FineBI Skill 才能完成主流程。
|
|
11
|
+
|
|
12
|
+
## 运行前提
|
|
13
|
+
|
|
14
|
+
- 使用 Node.js 18.17 或更高版本。
|
|
15
|
+
- 确认目标 FineBI 已部署与所选 CLI 兼容的 `plugin-bi-finebi-cli` 服务端插件。
|
|
16
|
+
- 确认 Agent 能访问目标 FineBI HTTP(S) 地址,并能在用户目录写入 `.finebi-cli` 配置。
|
|
17
|
+
- 将包含本文件的目录记为 `<skill-dir>`。所有脚本均使用 `<skill-dir>` 的绝对路径调用,不根据当前工作目录猜测位置。
|
|
18
|
+
|
|
19
|
+
## 按需读取参考
|
|
20
|
+
|
|
21
|
+
- 首次处理业务命令时,读取 [命令工作流](references/command-workflows.md) 的公共约束和目标命令族章节。
|
|
22
|
+
- 包含非只读动作时,读取 [变更计划与删除确认契约](references/mutation-confirmation-contract.md) 的计划、复检和验证规则;包含 `delete` 或失败清理时再读对应章节。
|
|
23
|
+
- 规划 Widget/Dashboard 时按当前场景读取 [场景工作流](references/scenario-workflows.md);构造或消费交接对象时读取 [语义交接契约](references/handoff-contract.md) 和 [DSL 输入契约](references/dsl-handoff-contract.md) 的公共结构及当前场景字段。
|
|
24
|
+
- 生成 Widget DSL 时,读取 [映射规则](references/mapping-rules.md) 和 [Widget DSL API](references/widget-dsl-api.md) 的公共约束及所用组件、字段类型和 API 章节。
|
|
25
|
+
- 需要可运行的推荐写法示例(分区折线/双轴/表格属性等)时,读取 [Widget DSL 写法示例](references/widget-dsl-api-examples.md)。
|
|
26
|
+
- 生成 Dashboard DSL 时,读取 [Dashboard DSL API](references/dashboard-dsl-api.md) 的公共约束和所用布局、引用及 API 章节;仅引用已有组件时无需加载 Widget API。产物顺序不清楚时读取 [产物顺序](references/artifact-ordering.md)。
|
|
27
|
+
- 解释或生成公式时,先用 `formula functions` 查询当前 FineBI 公式面板;绑定真实字段后,用 `calculated-field validate` 执行原生校验。
|
|
28
|
+
- 同一连续任务内复用未变化的已读内容;只有文件变化、进入未读能力,或上下文压缩后所需规则已不可用时,才补读相关部分。实时 capability、目标和文件摘要校验仍按变更契约执行,不以文档复用代替。
|
|
29
|
+
|
|
30
|
+
## 执行入口
|
|
31
|
+
|
|
32
|
+
默认优先使用内置 CLI。未显式指定入口且内置文件存在时,调用:
|
|
33
|
+
|
|
34
|
+
```text
|
|
35
|
+
node "<skill-dir>/scripts/finebi-cli/src/index.js" <built-in-command> ...
|
|
36
|
+
node "<skill-dir>/scripts/finebi-cli-runner.mjs" inspect <resource> <command>
|
|
37
|
+
node "<skill-dir>/scripts/finebi-cli-runner.mjs" run <resource> <command> ... --json
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
- 入口优先级:显式指定的 `FINEBI_CLI_PATH` → `<skill-dir>/scripts/finebi-cli/src/index.js` → PATH 中已安装的 `finebi-cli`。需要使用特定全局版本时,将 `FINEBI_CLI_PATH` 指向该 npm 包的 JavaScript 入口或可执行文件;Windows npm `.cmd` 入口也受支持。
|
|
41
|
+
- `config`、`auth`、`capability` 直接调用所选 CLI 入口。使用全局包时可调用 `finebi-cli <command> ...`;显式指定 JavaScript 入口时使用 `node "<CLI 入口绝对路径>" <command> ...`。这些命令与业务 runner 必须使用同一 CLI 安装。
|
|
42
|
+
- 动态业务命令仍使用上述 Skill runner;runner 按同一优先级选择 CLI,以 `shell:false` 启动并脱敏敏感参数。
|
|
43
|
+
- 不因机器上存在全局 CLI 就覆盖默认内置入口。没有任何可用入口时说明缺失,可由用户安装已发布的 `@finebi/finebi-cli`;当前业务任务不自动执行 `npm install`、`npm link` 或 `npx`。
|
|
44
|
+
- CLI 选定后,认证失败、服务端能力缺失或业务命令失败不触发自动换版本重试;需要切换入口时重新核对连接、认证和 capability/help,并重新校验受影响的计划。
|
|
45
|
+
- `inspect` 一次读取 capability 摘要和目标命令 help;不得把完整 capability manifest 输出到模型上下文。
|
|
46
|
+
- 仅以实时 capability 和目标命令 help 判断命令是否存在、参数结构和 `mutation` 属性。
|
|
47
|
+
- 名为 `template` 的动态命令必须先 `inspect`;仅当实时 capability 标记 `mutation:false` 时,才可用于读取文件 schema、Definition 模板和填写指引,不得把模板输出当作写操作授权。
|
|
48
|
+
|
|
49
|
+
## 安全边界
|
|
50
|
+
|
|
51
|
+
- 运行时 `mutation:false` 的业务命令可在参数完整且无歧义后执行。
|
|
52
|
+
- 所有非只读命令必须完成计划和执行前校验;仅命令名为 `delete` 的计划需要 `确认执行 <planId>`。`add`、`update`、`data-update` 等非删除命令在用户请求范围内可直接复检执行。
|
|
53
|
+
- `config set/clear`、`auth login/logout`、`capability refresh/clear-cache` 等非删除命令无需额外人工确认,但必须限定在当前任务所需的目标和影响范围。
|
|
54
|
+
- 删除计划的命令、参数、目标、顺序、文件路径、文件 SHA-256、schema 或 capability 任一变化,立即使原确认失效;重新生成计划并请求确认。
|
|
55
|
+
- 非删除计划的文件或前提变化时重新规划和校验,不增加人工确认步骤;不得沿用失效计划。
|
|
56
|
+
- 不得在多个资源、字段或关系之间静默选择;展示候选名称、ID 和归属后让用户消除歧义。
|
|
57
|
+
- 不得在命令、计划、日志或回复中暴露密码、token、cookie、Access Key。优先通过环境变量或标准输入传递密码。
|
|
58
|
+
- 不得把命令成功直接等同于业务完成;存在只读回查命令时必须验证,部分成功必须逐项报告。
|
|
59
|
+
- 失败清理和补偿同样需要计划与验证;包含 `delete` 的清理必须独立确认,非删除补偿在当前任务范围内完成复检后执行。
|
|
60
|
+
|
|
61
|
+
## 状态机
|
|
62
|
+
|
|
63
|
+
一次操作只能处于一个可见状态:
|
|
64
|
+
|
|
65
|
+
- `DISCOVERING`:读取 capability/help,解析资源、字段、ID、文件和依赖。
|
|
66
|
+
- `READY_READONLY`:只读命令参数完整且无歧义,可以执行。
|
|
67
|
+
- `GENERATING_ARTIFACTS`:仅写入已声明的本地 Definition 或 DSL 文件,不执行 FineBI 写命令。
|
|
68
|
+
- `AWAITING_CONFIRMATION`:包含 `delete` 的计划已冻结,等待确认指定 `planId`。
|
|
69
|
+
- `EXECUTING`:执行已复检且未变化的计划;包含 `delete` 时还须已获得确认。
|
|
70
|
+
- `VERIFYING`:使用只读命令核验结果并识别部分成功。
|
|
71
|
+
- `COMPLETED`:计划执行和验证均已完成。
|
|
72
|
+
- `BLOCKED`:能力缺失、目标歧义、运行时漂移或无法满足安全边界。
|
|
73
|
+
|
|
74
|
+
非只读命令须先完成计划和复检;不含 `delete` 的计划可直接进入 `EXECUTING`,不经过 `AWAITING_CONFIRMATION`。
|
|
75
|
+
|
|
76
|
+
## 工作流
|
|
77
|
+
|
|
78
|
+
### 1. 检查连接与认证
|
|
79
|
+
|
|
80
|
+
先按执行入口规则选定 CLI,再调用其只读状态命令检查配置、认证和 capability 缓存。需要配置地址或登录时,在当前任务范围内说明并执行必要的本地状态变更;缺少目标地址或认证输入时请求补充。成功登录后仍检查 capability 是否刷新成功。
|
|
81
|
+
|
|
82
|
+
### 2. 发现实时能力
|
|
83
|
+
|
|
84
|
+
使用 runner 的 `inspect` 模式核对资源、命令、`mutation`、必填参数、文件类型和响应结构。矩阵与运行时不一致时,以运行时结果阻断本次操作并报告差异,不得沿用旧计划或臆造语法。
|
|
85
|
+
|
|
86
|
+
### 3. 解析资源与字段
|
|
87
|
+
|
|
88
|
+
按照命令工作流使用 `search`、`info`、`definition`、`schema`、`preview` 等只读命令解析准确 ID、归属关系和字段。遍历分页结果;保留空结果、警告和部分数据标记。
|
|
89
|
+
|
|
90
|
+
需要生成 JSON Definition 时,先 `inspect` 对应的 `template` 命令;实时 capability 为 `mutation:false` 时执行它,并以返回的 `definitionSchema`、`definitionTemplate` 和填写指引生成文件。不得凭经验猜测 Definition 结构。
|
|
91
|
+
|
|
92
|
+
模型指标集不走分析表或公共数据集搜索。先调用 `subject info` 查看 `resources.models` 主题模型摘要,再用 `model search --subject-id <subjectId>` 消歧主题内模型,并用 `model info --subject-id <subjectId> --id <modelId>` 获取具体指标、数据集字段和模型计算字段。若用户要求的指标集尚未属于主题,单独以 `public-ds search` 确认唯一的 `type=METRIC_SET` 来源和可编辑目标主题;`model add` 返回的主题内模型 ID 才可用于 `model info/delete` 和字段回查,来源 ID 不得写进 DSL。模型目录命令未出现在实时 capability 时,既有 `widget dsl` 输出中的 `model(...)` 仍可作为只读证据;两类证据都不存在时进入 `BLOCKED`。不得把同名分析表改写成模型指标集。
|
|
93
|
+
|
|
94
|
+
### 4. 生成 Widget/Dashboard DSL
|
|
95
|
+
|
|
96
|
+
需要新建或更新 Widget/Dashboard 时:
|
|
97
|
+
|
|
98
|
+
1. 按语义交接契约构造并校验 `contractVersion: "1.0"` 的交接对象。
|
|
99
|
+
2. 明确列出唯一的绝对 `.js` 产物路径;只写入用户同意的映射路径。
|
|
100
|
+
3. 按 DSL 输入契约、映射规则和对应 API 生成文件。
|
|
101
|
+
4. 物理字段使用 `from("来源表").dim/sum/...`;模型级仅有指标,使用 `model("模型指标集").metrics().sum/avg/min/max/measure(...)`;模型表字段和模型计算字段分别使用 `model("模型指标集").dataset("数据集").dim/sum(...)` 与 `model("模型指标集").calculated().dim/sum(...)`;已保存计算字段使用 `measureID("配置 ID").dim()/sum()`。不把数据集 ID、模型 ID、字段 ID 或关系 ID 写进 DSL,也不把同名 `from(...)` 与 `model(...)` 互换。
|
|
102
|
+
5. Dashboard 统一通过 `.reference("组件名")` 引用组件,不内联组件定义。
|
|
103
|
+
6. 重新读取文件,自检根类型、名称、字段来源、API 和换行。
|
|
104
|
+
|
|
105
|
+
DSL 生成只授权本地文件写入,不授权任何 FineBI 写命令。模型字段支持模型指标、模型表字段和模型计算字段;模型根级维度和记录数不支持。同一作用域内字段展示名无法唯一解析时返回 `BLOCKED`,不得猜测或静默丢弃语义。
|
|
106
|
+
|
|
107
|
+
### 5. 执行只读业务命令
|
|
108
|
+
|
|
109
|
+
展示用途和业务命令 JSON `argv`,再用 runner 的 `run` 模式执行。解析结构化 envelope,只呈现任务所需结果,不重复倾倒原始 stdout。
|
|
110
|
+
|
|
111
|
+
### 6. 冻结写入计划
|
|
112
|
+
|
|
113
|
+
计划前先核对目标命令 help 是否能表达用户要求的名称、路径和其他目标属性。能力不支持时必须说明差距并进入 `BLOCKED`,不得把无法传入的目标写进计划。例如 `subject.add` 只有 `parentId` 时,不得承诺创建指定名称的主题。
|
|
114
|
+
|
|
115
|
+
按照变更确认契约生成计划,包含:精确目标、完整参数、文件绝对路径与 SHA-256、阶段依赖、影响、可逆性、前置验证、后置验证和失败清理策略。删除操作独立成批;不能可靠清理的操作单独执行或放在最后。
|
|
116
|
+
|
|
117
|
+
如果下游文件只能在上游写命令返回服务端实际 ID 后生成,不得在同一计划中使用占位 ID 或预期 ID。应先规划、复检、执行并回查上游资源;再生成下游文件并冻结新的 `planId`,仅包含 `delete` 时等待确认。典型顺序是:创建主题并回查实际 ID → 生成 Analysis DS Definition 并新建计划 → 创建分析表并回查实际 ID → 生成 Widget/Dashboard DSL 并新建计划。
|
|
118
|
+
|
|
119
|
+
生成唯一 `planId`;仅包含 `delete` 时将状态设为 `AWAITING_CONFIRMATION` 并要求用户回复 `确认执行 <planId>`,确认前不得执行该删除计划。不含 `delete` 时直接复检并执行。
|
|
120
|
+
|
|
121
|
+
### 7. 复检、执行与验证
|
|
122
|
+
|
|
123
|
+
按变更契约核验 capability/help、目标和文件摘要;删除计划先收到精确确认,再实时复检。全部符合计划时严格按阶段执行,每阶段完成后立即只读验证;首个写命令失败后立即停止,不得在同一 `planId` 下修改参数、改写文件或换一种 JSON 继续重试。
|
|
124
|
+
|
|
125
|
+
失败时汇总已成功或明确部分成功的资源,按依赖逆序生成新的 `cleanupPlanId`。其中 `delete` 必须独立确认;非删除补偿完成复检后执行。
|
|
126
|
+
|
|
127
|
+
### 8. 完成报告
|
|
128
|
+
|
|
129
|
+
报告每阶段结果、服务端实际 ID、验证证据、未执行项和残留风险。只有所有计划阶段及验证完成时进入 `COMPLETED`。
|
|
130
|
+
|
|
131
|
+
## 阻断输出
|
|
132
|
+
|
|
133
|
+
进入 `BLOCKED` 时报告状态、阻断命令或阶段、已收集只读证据、触发的安全边界,以及继续所需的最小用户操作。不得输出未经验证或可能误导用户执行的写命令。
|