@xiashe/cli 0.1.51 → 0.1.52
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/bin/xiashe.mjs +4 -2
- package/lib/share-code.mjs +16 -0
- package/package.json +2 -2
package/bin/xiashe.mjs
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createInterface } from 'node:readline/promises';
|
|
3
3
|
import { syncNumber } from '../lib/skill-sync.mjs';
|
|
4
|
+
import { fileURLToPath } from 'node:url';
|
|
5
|
+
import { resolveUseShareCode } from '../lib/share-code.mjs';
|
|
4
6
|
import { expandUseNumber, runAccountAwareUse } from '../lib/use-number.mjs';
|
|
5
7
|
import { deliverNumber } from '../lib/delivery.mjs';
|
|
6
8
|
import { runAccessCommand } from '../skills/xiashe/scripts/runtime-state.mjs';
|
|
@@ -1896,7 +1898,7 @@ function osPlatform() {
|
|
|
1896
1898
|
async function main() {
|
|
1897
1899
|
const shortUse = process.argv[2] === 'use';
|
|
1898
1900
|
let argv;
|
|
1899
|
-
try { argv = expandUseNumber(process.argv.slice(2), { brand: COMMAND_NAME }); }
|
|
1901
|
+
try { argv = expandUseNumber(await resolveUseShareCode(process.argv.slice(2), { brand: COMMAND_NAME }), { brand: COMMAND_NAME }); }
|
|
1900
1902
|
catch (error) { fail(error.message, EXIT_USAGE); }
|
|
1901
1903
|
const parsed = parseGlobal(argv);
|
|
1902
1904
|
const [command, sub, ...args] = parsed.argv;
|
|
@@ -1957,7 +1959,7 @@ async function main() {
|
|
|
1957
1959
|
};
|
|
1958
1960
|
const decision = checked.metadata.buyerNextStep;
|
|
1959
1961
|
if (!Object.hasOwn(steps, decision)) throw Error('SKILL_ACCESS_STATUS_UNAVAILABLE');
|
|
1960
|
-
return { ...result, buyerNextStep: decision, next: steps[decision] };
|
|
1962
|
+
return { ...result, buyerNextStep: decision, next: steps[decision], officialProtocolFile: fileURLToPath(new URL('../skills/xiashe/SKILL.md', import.meta.url)) };
|
|
1961
1963
|
};
|
|
1962
1964
|
const result = await use(options);
|
|
1963
1965
|
if (!global.json && result.stage === 'purchase_choice') {
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { protocolJsonRequest } from '../skills/xiashe/scripts/http.mjs';
|
|
2
|
+
|
|
3
|
+
// Resolve to the canonical number before opening any local state or account session.
|
|
4
|
+
export async function resolveUseShareCode(argv, { brand, fetchImpl = fetch }) {
|
|
5
|
+
if (brand !== 'xiashe' || argv[0] !== 'use' || !argv[1]?.startsWith('XS')) return argv;
|
|
6
|
+
const [, code, ...flags] = argv;
|
|
7
|
+
const match = /^XS1([PS])\d{2}-[0-9a-f]{40}$/.exec(code);
|
|
8
|
+
if (!match || flags.some(flag => !['--staging', '--guest', '--json'].includes(flag))) throw Error('SKILL_SHARE_CODE_INVALID');
|
|
9
|
+
const staging = match[1] === 'S';
|
|
10
|
+
if (!staging && flags.includes('--staging')) throw Error('SKILL_SHARE_ENVIRONMENT_MISMATCH');
|
|
11
|
+
const origin = staging ? 'https://actions.projectphenix.site' : 'https://actions.xiashe.chat';
|
|
12
|
+
const result = await protocolJsonRequest(origin + '/public/skill-share-codes/' + code, undefined, { method: 'GET', fetchImpl, maxResponseBytes: 2048 });
|
|
13
|
+
if (result.ok !== true || typeof result.number !== 'string' || !/^[1-9]\d{5,8}$/.test(result.number) ||
|
|
14
|
+
result.environment !== (staging ? 'staging' : 'production')) throw Error('SKILL_SHARE_CODE_INVALID');
|
|
15
|
+
return ['use', result.number, ...flags, ...(staging && !flags.includes('--staging') ? ['--staging'] : [])];
|
|
16
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xiashe/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.52",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bin": {
|
|
6
6
|
"xiashe": "bin/xiashe.mjs"
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"lib"
|
|
13
13
|
],
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@xiashe/sdk": "0.1.
|
|
15
|
+
"@xiashe/sdk": "0.1.52"
|
|
16
16
|
},
|
|
17
17
|
"engines": {
|
|
18
18
|
"node": ">=20"
|