Skip to content

Commit d07e2f4

Browse files
committed
feat: optimize vibe module
1 parent 57c89cb commit d07e2f4

File tree

11 files changed

+66
-28
lines changed

11 files changed

+66
-28
lines changed

Makefile

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,9 @@ repo-clean:
166166
node-repo:
167167
./node.yml -t node_repo
168168

169+
node-pkg:
170+
./node.yml -t node_pkg
171+
169172
node-upstream:
170173
./node.yml -t node_repo -e node_repo_modules=node,pgsql,infra,local
171174

@@ -196,6 +199,10 @@ docker:
196199
app:
197200
./app.yml
198201

202+
# claude
203+
claude:
204+
./vibe.yml -t nodejs,claude
205+
199206
# install & uninstall pgsql (dangerous!!)
200207
pgsql-add:
201208
./infra.yml -t repo_build
@@ -661,8 +668,8 @@ rs:
661668
src \
662669
c v validate \
663670
infra repo repo-upstream repo-check repo-build repo-add repo-clean \
664-
node-repo node-upstream redeploy \
665-
grafana vv vlogs vector nginx cert docker app \
671+
node-repo node-upstream node-pkg redeploy \
672+
grafana vv vlogs vector nginx cert claude cc docker app \
666673
pgsql-add pgsql-rm pgsql-ext \
667674
deps dns start ssh tssh \
668675
up dw del nuke new clean \

conf/docker.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ all:
5353
node_kernel_modules: []
5454
node_repo_remove: true
5555
node_repo_modules: 'node,infra,pgsql'
56-
#node_packages: [ openssh-server ]
56+
5757

5858
#----------------------------------------------#
5959
# PGSQL: https://pigsty.io/docs/pgsql
@@ -91,14 +91,14 @@ all:
9191
#----------------------------------------------#
9292
#code_password: DBUser.Meta
9393
#jupyter_password: DBUser.Meta
94-
#
9594
#juice_instances: # dict of juicefs filesystems to deploy
9695
# jfs:
9796
# path : /fs
9897
# meta : postgres://dbuser_meta:DBUser.Meta@10.10.10.10:5432/meta
9998
# data : --storage postgres --bucket 10.10.10.10:5432/meta --access-key dbuser_meta --secret-key DBUser.Meta
10099
# port : 9567
101-
#
100+
#node_packages: [ openssh-server, tumx, juicefs, restic, rclone, uv, code-server ]
101+
#npm_packages: [ '@anthropic-ai/claude-code' , 'happy-coder' ]
102102
#claude_env:
103103
# ANTHROPIC_BASE_URL: https://open.bigmodel.cn/api/anthropic
104104
# ANTHROPIC_API_URL: https://open.bigmodel.cn/api/anthropic

conf/vibe.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ all:
5757
node_tune: oltp # node tuning specs: oltp,olap,tiny,crit
5858
node_dns_method: none # do not setup dns
5959
node_repo_modules: node,infra,pgsql # add these repos directly to the singleton node
60-
node_packages: [ openssh-server, juicefs, restic, rclone, uv, opencode, claude, code-server, golang, asciinema, genai-toolbox, postgrest ]
60+
node_packages: [ openssh-server, juicefs, restic, rclone, uv, opencode, code-server, golang, asciinema, tmux ]
6161
docker_enabled: true # enable docker service
6262
node_firewall_mode: none # change to 'zone' to enable firewall
6363
node_firewall_public_port: [22, 80, 443, 5432] # add custom public ports
@@ -109,6 +109,8 @@ all:
109109
meta : postgres://dbuser_meta:DBUser.Meta@10.10.10.10:5432/meta
110110
data : --storage postgres --bucket 10.10.10.10:5432/meta --access-key dbuser_meta --secret-key DBUser.Meta
111111
port : 9567
112+
113+
npm_packages: [ '@anthropic-ai/claude-code' , 'happy-coder' ]
112114
#claude_env:
113115
# ANTHROPIC_BASE_URL: https://open.bigmodel.cn/api/anthropic
114116
# ANTHROPIC_API_URL: https://open.bigmodel.cn/api/anthropic

files/cmdb.sql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1657,4 +1657,5 @@ INSERT INTO pigsty.default_var VALUES
16571657
(1030, 'claude_enabled', 'true', 'VIBE', 'CLAUDE', 'bool', 'C', 'enable claude code configuration', NULL),
16581658
(1031, 'claude_env', '{}', 'VIBE', 'CLAUDE', 'dict', 'C', 'extra env vars to merge with defaults', NULL),
16591659
(1040, 'nodejs_enabled', 'true', 'VIBE', 'NODEJS', 'bool', 'C', 'enable nodejs installation', NULL),
1660-
(1041, 'nodejs_registry', '""', 'VIBE', 'NODEJS', 'url', 'C', 'npm registry, auto china mirror if empty', NULL);
1660+
(1041, 'nodejs_registry', '""', 'VIBE', 'NODEJS', 'url', 'C', 'npm registry, auto china mirror if empty', NULL),
1661+
(1042, 'npm_packages', '[]', 'VIBE', 'NODEJS', 'string[]', 'C', 'list of global npm packages to install', NULL);

files/grafana/node/claude-code.json

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
{
22
"annotations":{"list":[{"builtIn":1,"datasource":{"type":"grafana","uid":"-- Grafana --"},"enable":true,"hide":true,"iconColor":"#BF6C50","name":"Annotations & Alerts","type":"dashboard"}]},
3-
"author":"Ruohang Feng (rh@vonng.com)",
43
"description":"Claude Code Observability",
54
"editable":true,
65
"fiscalYearStartMonth":0,
76
"graphTooltip":1,
87
"id":null,
9-
"license":"https://pigsty.io/docs/about/license/",
108
"links":[],
119
"panels":[
1210
{"collapsed":false,"gridPos":{"h":1,"w":24,"x":0,"y":0},"id":1,"panels":[],"title":"Overview","type":"row"},
@@ -36,10 +34,8 @@
3634
"defaults":{"color":{"mode":"thresholds"},"custom":{"align":"center","cellOptions":{"type":"auto"},"footer":{"reducers":[]},"inspect":true},"mappings":[],"thresholds":{"mode":"absolute","steps":[{"color":"text","value":0}]}},
3735
"overrides":[
3836
{"matcher":{"id":"byName","options":"duration_ms"},"properties":[{"id":"unit","value":"ms"},{"id":"custom.width","value":100},{"id":"custom.cellOptions","value":{"mode":"gradient","type":"color-background"}},{"id":"thresholds","value":{"mode":"absolute","steps":[{"color":"#5B8C7A","value":0},{"color":"#C9A257","value":2000},{"color":"#C45B47","value":5000}]}}]},
39-
{"matcher":{"id":"byName","options":"session.id"},"properties":[{"id":"custom.width","value":300},{"id":"links","value":[{"title":"Claude Code : ${__data.fields.SessionID}","url":"/d/claude-code?var-session=${__data.fields.SessionID}&${__url_time_range}"}]}]},{"matcher":{"id":"byName","options":"Time"},"properties":[{"id":"custom.width","value":160},{"id":"unit","value":"s"}]},
40-
{"matcher":{"id":"byName","options":"user.id"},"properties":[{"id":"custom.width","value":550}]},{"matcher":{"id":"byName","options":"scope.name"},"properties":[{"id":"custom.width","value":255}]},{"matcher":{"id":"byName","options":"scope.version"},"properties":[{"id":"custom.width","value":110}]},
41-
{"matcher":{"id":"byName","options":"service.name"},"properties":[{"id":"custom.width","value":110}]},{"matcher":{"id":"byName","options":"service.version"},"properties":[{"id":"custom.width","value":120}]},{"matcher":{"id":"byName","options":"os.type"},"properties":[{"id":"custom.width","value":70}]},
42-
{"matcher":{"id":"byName","options":"os.version"},"properties":[{"id":"custom.width","value":220}]},{"matcher":{"id":"byName","options":"host.arch"},"properties":[{"id":"custom.width","value":80}]},{"matcher":{"id":"byName","options":"terminal.type"},"properties":[{"id":"custom.width","value":133}]},
37+
{"matcher":{"id":"byName","options":"SessionID"},"properties":[{"id":"custom.width","value":308},{"id":"links","value":[{"title":"Claude Code : ${__data.fields.SessionID}","url":"/d/claude-code?var-session=${__data.fields.SessionID}&${__url_time_range}"}]}]},{"matcher":{"id":"byName","options":"service.version"},"properties":[{"id":"custom.width","value":120}]},
38+
{"matcher":{"id":"byName","options":"os.type"},"properties":[{"id":"custom.width","value":70}]},{"matcher":{"id":"byName","options":"os.version"},"properties":[{"id":"custom.width","value":220}]},{"matcher":{"id":"byName","options":"host.arch"},"properties":[{"id":"custom.width","value":80}]},{"matcher":{"id":"byName","options":"terminal.type"},"properties":[{"id":"custom.width","value":133}]},
4339
{
4440
"matcher":{"id":"byName","options":"event.name"},
4541
"properties":[{"id":"custom.width","value":100},{"id":"custom.align","value":"center"},{"id":"mappings","value":[{"options":{"api_request":{"color":"#f79f64","index":1},"tool_decision":{"color":"#5b9cd5","index":3},"tool_result":{"color":"#346f36cc","index":2},"user_prompt":{"color":"#3e668f","index":0}},"type":"value"}]},{"id":"custom.cellOptions","value":{"type":"color-background"}}]
@@ -51,7 +47,7 @@
5147
{"matcher":{"id":"byName","options":"success"},"properties":[{"id":"custom.width","value":80}]},{"matcher":{"id":"byName","options":"tool_name"},"properties":[{"id":"custom.width","value":100}]},{"matcher":{"id":"byName","options":"tool_parameters"},"properties":[{"id":"custom.align","value":"left"},{"id":"custom.minWidth","value":200},{"id":"custom.cellOptions","value":{"type":"json-view"}}]},
5248
{"matcher":{"id":"byName","options":"tool_result_size_bytes"},"properties":[{"id":"custom.width","value":180}]},{"matcher":{"id":"byName","options":"decision"},"properties":[{"id":"custom.width","value":90}]},{"matcher":{"id":"byName","options":"source"},"properties":[{"id":"custom.width","value":70}]},{"matcher":{"id":"byName","options":"use_id"},"properties":[{"id":"custom.width","value":250}]},
5349
{"matcher":{"id":"byName","options":"Logs"},"properties":[{"id":"custom.width","value":100}]},{"matcher":{"id":"byName","options":"IP"},"properties":[{"id":"custom.width","value":120},{"id":"links","value":[{"title":"Node Instance : ${__data.fields.IP}","url":"/d/node-instance?var-id=${__data.fields.IP}&{__url_time_range}"}]}]},
54-
{"matcher":{"id":"byName","options":"First Seen"},"properties":[{"id":"custom.width","value":160}]},{"matcher":{"id":"byName","options":"Last Seen"},"properties":[{"id":"custom.width","value":160}]},{"matcher":{"id":"byName","options":"UserID"},"properties":[{"id":"custom.width","value":139}]}
50+
{"matcher":{"id":"byName","options":"First Seen"},"properties":[{"id":"custom.width","value":160}]},{"matcher":{"id":"byName","options":"Last Seen"},"properties":[{"id":"custom.width","value":160}]},{"matcher":{"id":"byName","options":"UserID"},"properties":[{"id":"custom.width","value":120}]}
5551
]
5652
},
5753
"gridPos":{"h":6,"w":18,"x":6,"y":1},
@@ -263,7 +259,7 @@
263259
{
264260
"matcher":{"id":"byName","options":"Model"},
265261
"properties":[
266-
{ "id":"custom.width" ,"value":150 },
262+
{ "id":"custom.width" ,"value":200 },
267263
{ "id":"custom.cellOptions","value":{"type":"color-text"} },
268264
{ "id":"custom.align" ,"value":"left" },
269265
{ "id":"mappings" ,"value":[{"options":{"pattern":"claude-opus.*|glm-4.7.*","result":{"color":"#f79f64","index":0}},"type":"regex"},{"options":{"pattern":"claude-sonnet.*|glm-4.6.*","result":{"color":"#346f36cc","index":1}},"type":"regex"},{"options":{"pattern":"claude-haiku.*|glm-4.5.*","result":{"color":"#5b9cd5","index":2}},"type":"regex"}] },
@@ -1031,7 +1027,8 @@
10311027
{ "id":"custom.cellOptions","value":{"type":"color-text"} },
10321028
{ "id":"custom.align" ,"value":"left" },
10331029
{ "id":"mappings" ,"value":[{"options":{"pattern":"claude-opus.*|glm-4.7.*","result":{"color":"#f79f64","index":0}},"type":"regex"},{"options":{"pattern":"claude-sonnet.*|glm-4.6.*","result":{"color":"#346f36cc","index":1}},"type":"regex"},{"options":{"pattern":"claude-haiku.*|glm-4.5.*","result":{"color":"#5b9cd5","index":2}},"type":"regex"}] },
1034-
{ "id":"custom.cellOptions","value":{"type":"pill"} }
1030+
{ "id":"custom.cellOptions","value":{"type":"pill"} },
1031+
{ "id":"custom.minWidth" ,"value":160 }
10351032
]
10361033
},{
10371034
"matcher":{"id":"byName","options":"Elapse"},
@@ -1913,5 +1910,7 @@
19131910
"title":"Claude Code",
19141911
"uid":"claude-code",
19151912
"version":1,
1916-
"weekStart":""
1913+
"weekStart":"",
1914+
"author":"Ruohang Feng (rh@vonng.com)",
1915+
"license":"https://pigsty.io/docs/about/license/"
19171916
}

files/grafana/pgsql/pgsql-xacts.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,6 @@
343343
"axisColorMode":"text",
344344
"axisLabel":"",
345345
"axisPlacement":"auto",
346-
"axisSoftMax":1,
347346
"axisSoftMin":0,
348347
"barAlignment":0,
349348
"barWidthFactor":0.6,

roles/vibe/README.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ vibe
5757
│ └── claude_config
5858
└── nodejs # Node.js Runtime
5959
├── nodejs_install
60-
└── nodejs_config
60+
├── nodejs_config
61+
└── nodejs_pkg
6162
```
6263

6364

@@ -104,9 +105,19 @@ Claude Code is pre-configured with OpenTelemetry, sending metrics and logs to Vi
104105
|-------------------|---------|--------------------------------------------------|
105106
| `nodejs_enabled` | `true` | Enable Node.js installation |
106107
| `nodejs_registry` | `''` | npm registry URL, auto china mirror if empty |
108+
| `npm_packages` | `[]` | List of global npm packages to install |
107109

108110
When `nodejs_registry` is empty and `region=china`, npm is automatically configured to use `https://registry.npmmirror.com`.
109111

112+
Use `npm_packages` to install global npm packages like `@anthropic-ai/claude-code`:
113+
114+
```yaml
115+
npm_packages:
116+
- '@anthropic-ai/claude-code'
117+
- typescript
118+
- pnpm
119+
```
120+
110121
111122
## Usage
112123

roles/vibe/defaults/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,5 @@ claude_env: {} # extra env vars to merge with defaults
4242
#--------------------------------------------------------------#
4343
nodejs_enabled: true # enable nodejs installation
4444
nodejs_registry: '' # npm registry, auto china mirror if empty
45-
45+
npm_packages: [] # list of global npm packages to install
4646
...

roles/vibe/tasks/claude.yml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,17 @@
44
#--------------------------------------------------------------#
55

66
#--------------------------------------------------------------#
7-
# claude_install - install claude package
7+
# claude_install - install claude-code via npm
88
#--------------------------------------------------------------#
9-
- name: install claude package
10-
tags: claude_install
11-
package: name=claude state=present
12-
environment: "{{ proxy_env | default({}) }}"
9+
# now installed via npm_packages
10+
#- name: install claude-code via npm
11+
# tags: claude_install
12+
# community.general.npm:
13+
# name: "@anthropic-ai/claude-code"
14+
# global: true
15+
# state: present
16+
# environment: "{{ proxy_env | default({}) }}"
17+
1318

1419
#--------------------------------------------------------------#
1520
# claude_config - create claude configuration directory

roles/vibe/tasks/nodejs.yml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
#--------------------------------------------------------------#
55

66
#--------------------------------------------------------------#
7-
# nodejs_install - install nodejs package
7+
# nodejs_install - install nodejs package [nodejs_install]
88
#--------------------------------------------------------------#
99
- name: install nodejs package
1010
tags: nodejs_install
1111
package: name=nodejs state=present
1212

1313
#--------------------------------------------------------------#
14-
# nodejs_config - configure npm registry
14+
# nodejs_config - configure npm registry [nodejs_config]
1515
#--------------------------------------------------------------#
1616
- name: configure npm registry
1717
tags: nodejs_config
@@ -30,4 +30,16 @@
3030
content: |
3131
registry={{ nodejs_registry | default('https://registry.npmmirror.com', true) }}
3232
33+
#--------------------------------------------------------------#
34+
# npm_packages - install global npm packages [npm_pkg]
35+
#--------------------------------------------------------------#
36+
- name: install global npm packages
37+
tags: nodejs_pkg
38+
when: npm_packages | default([]) | length > 0
39+
shell: npm install -g {{ item }}
40+
args:
41+
executable: /bin/bash
42+
loop: "{{ npm_packages }}"
43+
environment: "{{ proxy_env | default({}) | combine({'PATH': '/usr/local/node/bin:/usr/local/bin:/usr/bin:/bin'}) }}"
44+
3345
...

0 commit comments

Comments
 (0)