@xqyz/xq-cli 0.1.1 → 0.1.2

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.
Files changed (3) hide show
  1. package/README.md +5 -4
  2. package/package.json +1 -1
  3. package/src/cli.mjs +27 -18
package/README.md CHANGED
@@ -40,14 +40,15 @@ npm pack
40
40
  That command produces a `.tgz` tarball which can be shared and installed with:
41
41
 
42
42
  ```bash
43
- npm install -g .\xqyz-xq-cli-0.1.1.tgz
43
+ npm install -g .\xqyz-xq-cli-0.1.2.tgz
44
44
  ```
45
45
 
46
46
  ## Usage
47
47
 
48
48
  ```bash
49
- xq-cli login --base-url https://ai.bidfile.qianlima.com/api
50
- xq-cli login --base-url https://ai.bidfile.qianlima.com/api --name your-account --password your-password
49
+ xq-cli login
50
+ xq-cli login --name your-account --password your-password
51
+ xq-cli login --base-url https://xqai.atest.qianlima.com/api --browser
51
52
  xq-cli wizard
52
53
  xq-cli wizard --file D:\bids\tender.docx
53
54
  xq-cli init --file D:\bids\tender.docx --wait
@@ -59,7 +60,7 @@ xq-cli export --cid <cid> --interactive --out D:\output
59
60
  xq-cli export --cid <cid> --out D:\output
60
61
  ```
61
62
 
62
- Fresh installs do not ship with a saved API address. Users must run `login` once to save the target `--base-url`.
63
+ Fresh installs default to the production API address `https://ai.bidfile.qianlima.com/api`. Use `--base-url` only when you need to target another environment such as `https://xqai.atest.qianlima.com/api`.
63
64
 
64
65
  `login` now defaults to browser authorization. If you explicitly pass `--name` and `--password`, the CLI falls back to password login.
65
66
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xqyz/xq-cli",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "CLI for xique bid-book task workflows",
5
5
  "type": "module",
6
6
  "scripts": {
package/src/cli.mjs CHANGED
@@ -15,6 +15,7 @@ import { AI_PURPOSE_MAP, detectFileType } from './fileTypeConfig.mjs';
15
15
 
16
16
  const APP_DIR = path.join(os.homedir(), '.xq-opencli');
17
17
  const CONFIG_FILE = path.join(APP_DIR, 'config.json');
18
+ const DEFAULT_BASE_URL = 'https://ai.bidfile.qianlima.com/api';
18
19
  const DEFAULT_PARSE_INTERVAL_MS = 10_000;
19
20
  const DEFAULT_TASK_INTERVAL_MS = 10_000;
20
21
  const DEFAULT_TIMEOUT_MS = 10 * 60 * 1000;
@@ -365,9 +366,9 @@ Commands
365
366
  export Download the generated docx
366
367
 
367
368
  Examples
368
- xq-cli login --base-url https://ai.bidfile.qianlima.com/api
369
- xq-cli login --base-url https://ai.bidfile.qianlima.com/api --name your-account --password your-password
370
- xq-cli login --base-url https://ai.bidfile.qianlima.com/api --browser
369
+ xq-cli login
370
+ xq-cli login --name your-account --password your-password
371
+ xq-cli login --base-url https://xqai.atest.qianlima.com/api --browser
371
372
  xq-cli init --file D:\\bids\\tender.docx --wait
372
373
  xq-cli parse-status --cid <cid> --uuid <uuid> --wait
373
374
  xq-cli choices
@@ -389,7 +390,7 @@ Examples
389
390
 
390
391
  Common options
391
392
  --json Print machine-readable JSON output
392
- --base-url <url> Override the saved base URL
393
+ --base-url <url> Override the default or saved base URL
393
394
  --timeout-sec <n> Poll timeout in seconds, default 600
394
395
  --interval-sec <n> Poll interval in seconds, default 10
395
396
  --reference-type <0|1|2> Outline reference choice: 0=merge, 1=format only, 2=score only
@@ -3193,26 +3194,34 @@ function normalizeBaseUrl(value) {
3193
3194
  return String(value).replace(/\/+$/, '');
3194
3195
  }
3195
3196
 
3197
+ function createDefaultState() {
3198
+ return {
3199
+ baseUrl: DEFAULT_BASE_URL,
3200
+ token: '',
3201
+ user: {},
3202
+ lastCid: '',
3203
+ tasks: {},
3204
+ };
3205
+ }
3206
+
3196
3207
  function readState() {
3208
+ const defaultState = createDefaultState();
3197
3209
  if (!fs.existsSync(CONFIG_FILE)) {
3198
- return {
3199
- baseUrl: '',
3200
- token: '',
3201
- user: {},
3202
- lastCid: '',
3203
- tasks: {},
3204
- };
3210
+ return defaultState;
3205
3211
  }
3206
3212
  try {
3207
- return JSON.parse(fs.readFileSync(CONFIG_FILE, 'utf8'));
3208
- } catch (error) {
3213
+ const parsed = JSON.parse(fs.readFileSync(CONFIG_FILE, 'utf8'));
3209
3214
  return {
3210
- baseUrl: '',
3211
- token: '',
3212
- user: {},
3213
- lastCid: '',
3214
- tasks: {},
3215
+ ...defaultState,
3216
+ ...parsed,
3217
+ baseUrl: normalizeBaseUrl(parsed?.baseUrl || defaultState.baseUrl),
3218
+ token: parsed?.token || '',
3219
+ user: parsed?.user && typeof parsed.user === 'object' ? parsed.user : {},
3220
+ lastCid: parsed?.lastCid || '',
3221
+ tasks: parsed?.tasks && typeof parsed.tasks === 'object' ? parsed.tasks : {},
3215
3222
  };
3223
+ } catch (error) {
3224
+ return defaultState;
3216
3225
  }
3217
3226
  }
3218
3227