yuangs 1.3.21 → 1.3.23
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/.github/workflows/publish.yml +6 -6
- package/README.md +3 -0
- package/package.json +5 -2
- package/test/index.test.js +68 -0
|
@@ -3,7 +3,7 @@ name: Auto Bump & Publish
|
|
|
3
3
|
on:
|
|
4
4
|
push:
|
|
5
5
|
branches:
|
|
6
|
-
- main
|
|
6
|
+
- main # 如果你的默认分支不是 main,记得改成对应名字
|
|
7
7
|
|
|
8
8
|
jobs:
|
|
9
9
|
publish:
|
|
@@ -19,13 +19,13 @@ jobs:
|
|
|
19
19
|
uses: actions/checkout@v4
|
|
20
20
|
with:
|
|
21
21
|
token: ${{ secrets.GITHUB_TOKEN }}
|
|
22
|
-
fetch-depth: 0
|
|
22
|
+
fetch-depth: 0 # 完整历史,方便推 tag
|
|
23
23
|
|
|
24
24
|
- name: Set up Node.js
|
|
25
25
|
uses: actions/setup-node@v4
|
|
26
26
|
with:
|
|
27
|
-
node-version:
|
|
28
|
-
registry-url:
|
|
27
|
+
node-version: "18"
|
|
28
|
+
registry-url: "https://registry.npmjs.org/"
|
|
29
29
|
|
|
30
30
|
- name: Configure Git
|
|
31
31
|
run: |
|
|
@@ -36,7 +36,7 @@ jobs:
|
|
|
36
36
|
# [skip ci] 防止这个 commit 再次触发 workflow 形成死循环
|
|
37
37
|
- name: Bump version
|
|
38
38
|
run: |
|
|
39
|
-
npm version patch -m "
|
|
39
|
+
npm version patch -m "苑广山注:自动升版本号%s[skip ci]"
|
|
40
40
|
|
|
41
41
|
# 推送 commit + tag 回 GitHub
|
|
42
42
|
- name: Push changes
|
|
@@ -51,4 +51,4 @@ jobs:
|
|
|
51
51
|
- name: Publish to npm
|
|
52
52
|
run: npm publish --provenance
|
|
53
53
|
env:
|
|
54
|
-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
54
|
+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
package/README.md
CHANGED
|
@@ -65,6 +65,9 @@ Pong 游戏: https://wealth.want.biz/pages/pong.html
|
|
|
65
65
|
|
|
66
66
|
## 近期主要更新日志
|
|
67
67
|
|
|
68
|
+
### v1.3.22 (2025-11-30)
|
|
69
|
+
- **新增** AI 命令支持 `-p` `-f` `-l` 简写,快速选择gemini默认模型
|
|
70
|
+
|
|
68
71
|
### v1.3.6 (2025-11-29)
|
|
69
72
|
|
|
70
73
|
- **新增** AI 命令交互模式:直接输入 `yuangs ai` 即可进入一问一答模式,无需每次输入问题,quit 或 exit 可退出。
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "yuangs",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.23",
|
|
4
4
|
"description": "苑广山的个人应用集合 CLI(彩色版)",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
7
7
|
"yuangs": "cli.js"
|
|
8
8
|
},
|
|
9
9
|
"scripts": {
|
|
10
|
-
"test": "
|
|
10
|
+
"test": "jest"
|
|
11
11
|
},
|
|
12
12
|
"keywords": [
|
|
13
13
|
"yuangs",
|
|
@@ -29,6 +29,9 @@
|
|
|
29
29
|
"axios": "^1.13.2",
|
|
30
30
|
"chalk": "^4.1.2"
|
|
31
31
|
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"jest": "^29.7.0"
|
|
34
|
+
},
|
|
32
35
|
"publishConfig": {
|
|
33
36
|
"access": "public"
|
|
34
37
|
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
const { exec } = require('child_process');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const yuangs = require('../index.js');
|
|
4
|
+
|
|
5
|
+
describe('Module: index.js', () => {
|
|
6
|
+
beforeEach(() => {
|
|
7
|
+
yuangs.clearConversationHistory();
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
test('should export correct app URLs', () => {
|
|
11
|
+
expect(yuangs.urls).toHaveProperty('shici');
|
|
12
|
+
expect(yuangs.urls).toHaveProperty('dict');
|
|
13
|
+
expect(yuangs.urls).toHaveProperty('pong');
|
|
14
|
+
expect(yuangs.urls.shici).toContain('shici/index.html');
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
test('should manage conversation history correctly', () => {
|
|
18
|
+
yuangs.addToConversationHistory('user', 'hello');
|
|
19
|
+
let history = yuangs.getConversationHistory();
|
|
20
|
+
expect(history).toHaveLength(1);
|
|
21
|
+
expect(history[0]).toEqual({ role: 'user', content: 'hello' });
|
|
22
|
+
|
|
23
|
+
yuangs.addToConversationHistory('assistant', 'hi');
|
|
24
|
+
history = yuangs.getConversationHistory();
|
|
25
|
+
expect(history).toHaveLength(2);
|
|
26
|
+
expect(history[1]).toEqual({ role: 'assistant', content: 'hi' });
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
test('should limit conversation history to 20 items', () => {
|
|
30
|
+
for (let i = 0; i < 25; i++) {
|
|
31
|
+
yuangs.addToConversationHistory('user', `msg ${i}`);
|
|
32
|
+
}
|
|
33
|
+
const history = yuangs.getConversationHistory();
|
|
34
|
+
expect(history).toHaveLength(20);
|
|
35
|
+
expect(history[history.length - 1].content).toBe('msg 24');
|
|
36
|
+
// The first 5 should be dropped, so the first one in history should be 'msg 5'
|
|
37
|
+
expect(history[0].content).toBe('msg 5');
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
test('should clear conversation history', () => {
|
|
41
|
+
yuangs.addToConversationHistory('user', 'test');
|
|
42
|
+
yuangs.clearConversationHistory();
|
|
43
|
+
expect(yuangs.getConversationHistory()).toHaveLength(0);
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
describe('CLI Integration', () => {
|
|
48
|
+
const cliPath = path.join(__dirname, '../cli.js');
|
|
49
|
+
|
|
50
|
+
test('should print help message', (done) => {
|
|
51
|
+
exec(`node ${cliPath} --help`, (error, stdout, stderr) => {
|
|
52
|
+
expect(error).toBeNull();
|
|
53
|
+
expect(stdout).toContain('苑广山的个人应用启动器');
|
|
54
|
+
expect(stdout).toContain('使用方法:');
|
|
55
|
+
done();
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
test('should list apps', (done) => {
|
|
60
|
+
exec(`node ${cliPath} list`, (error, stdout, stderr) => {
|
|
61
|
+
expect(error).toBeNull();
|
|
62
|
+
expect(stdout).toContain('苑广山的应用列表');
|
|
63
|
+
expect(stdout).toContain('shici');
|
|
64
|
+
expect(stdout).toContain('dict');
|
|
65
|
+
done();
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
});
|