refactor(version): extract version formatting helpers and improve build info display
Extract formatVersion() and formatBuildInfo() helper functions to reduce code duplication between printVersion() and statusCmd(). Update git commit default value to "dev" in Makefile for consistency with version handling. Update documentation for QQ and DingTalk chat integration in Japanese README.
This commit is contained in:
2
Makefile
2
Makefile
@@ -8,7 +8,7 @@ MAIN_GO=$(CMD_DIR)/main.go
|
|||||||
|
|
||||||
# Version
|
# Version
|
||||||
VERSION?=$(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
|
VERSION?=$(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
|
||||||
GIT_COMMIT=$(shell git rev-parse --short=8 HEAD 2>/dev/null || echo "unknown")
|
GIT_COMMIT=$(shell git rev-parse --short=8 HEAD 2>/dev/null || echo "dev")
|
||||||
BUILD_TIME=$(shell date +%FT%T%z)
|
BUILD_TIME=$(shell date +%FT%T%z)
|
||||||
GO_VERSION=$(shell $(GO) version | awk '{print $$3}')
|
GO_VERSION=$(shell $(GO) version | awk '{print $$3}')
|
||||||
LDFLAGS=-ldflags "-X main.version=$(VERSION) -X main.gitCommit=$(GIT_COMMIT) -X main.buildTime=$(BUILD_TIME) -X main.goVersion=$(GO_VERSION)"
|
LDFLAGS=-ldflags "-X main.version=$(VERSION) -X main.gitCommit=$(GIT_COMMIT) -X main.buildTime=$(BUILD_TIME) -X main.goVersion=$(GO_VERSION)"
|
||||||
|
|||||||
73
README.ja.md
73
README.ja.md
@@ -186,7 +186,7 @@ picoclaw onboard
|
|||||||
"providers": {
|
"providers": {
|
||||||
"openrouter": {
|
"openrouter": {
|
||||||
"api_key": "xxx",
|
"api_key": "xxx",
|
||||||
"api_base": "https://open.bigmodel.cn/api/paas/v4"
|
"api_base": "https://openrouter.ai/api/v1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"tools": {
|
"tools": {
|
||||||
@@ -223,12 +223,14 @@ picoclaw agent -m "What is 2+2?"
|
|||||||
|
|
||||||
## 💬 チャットアプリ
|
## 💬 チャットアプリ
|
||||||
|
|
||||||
Telegram で PicoClaw と会話できます
|
Telegram、Discord、QQ、DingTalk で PicoClaw と会話できます
|
||||||
|
|
||||||
| チャネル | セットアップ |
|
| チャネル | セットアップ |
|
||||||
|---------|------------|
|
|---------|------------|
|
||||||
| **Telegram** | 簡単(トークンのみ) |
|
| **Telegram** | 簡単(トークンのみ) |
|
||||||
| **Discord** | 簡単(Bot トークン + Intents) |
|
| **Discord** | 簡単(Bot トークン + Intents) |
|
||||||
|
| **QQ** | 簡単(AppID + AppSecret) |
|
||||||
|
| **DingTalk** | 普通(アプリ認証情報) |
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
<summary><b>Telegram</b>(推奨)</summary>
|
<summary><b>Telegram</b>(推奨)</summary>
|
||||||
@@ -307,6 +309,73 @@ picoclaw gateway
|
|||||||
|
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary><b>QQ</b></summary>
|
||||||
|
|
||||||
|
**1. Bot を作成**
|
||||||
|
|
||||||
|
- [QQ オープンプラットフォーム](https://connect.qq.com/) にアクセス
|
||||||
|
- アプリケーションを作成 → **AppID** と **AppSecret** を取得
|
||||||
|
|
||||||
|
**2. 設定**
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"channels": {
|
||||||
|
"qq": {
|
||||||
|
"enabled": true,
|
||||||
|
"app_id": "YOUR_APP_ID",
|
||||||
|
"app_secret": "YOUR_APP_SECRET",
|
||||||
|
"allow_from": []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
> `allow_from` を空にすると全ユーザーを許可、QQ番号を指定してアクセス制限可能。
|
||||||
|
|
||||||
|
**3. 起動**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
picoclaw gateway
|
||||||
|
```
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary><b>DingTalk</b></summary>
|
||||||
|
|
||||||
|
**1. Bot を作成**
|
||||||
|
|
||||||
|
- [オープンプラットフォーム](https://open.dingtalk.com/) にアクセス
|
||||||
|
- 内部アプリを作成
|
||||||
|
- Client ID と Client Secret をコピー
|
||||||
|
|
||||||
|
**2. 設定**
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"channels": {
|
||||||
|
"dingtalk": {
|
||||||
|
"enabled": true,
|
||||||
|
"client_id": "YOUR_CLIENT_ID",
|
||||||
|
"client_secret": "YOUR_CLIENT_SECRET",
|
||||||
|
"allow_from": []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
> `allow_from` を空にすると全ユーザーを許可、ユーザーIDを指定してアクセス制限可能。
|
||||||
|
|
||||||
|
**3. 起動**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
picoclaw gateway
|
||||||
|
```
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
## ⚙️ 設定
|
## ⚙️ 設定
|
||||||
|
|
||||||
設定ファイル: `~/.picoclaw/config.json`
|
設定ファイル: `~/.picoclaw/config.json`
|
||||||
|
|||||||
@@ -43,19 +43,33 @@ var (
|
|||||||
|
|
||||||
const logo = "🦞"
|
const logo = "🦞"
|
||||||
|
|
||||||
func printVersion() {
|
// formatVersion returns the version string with optional git commit
|
||||||
fmt.Printf("%s picoclaw %s", logo, version)
|
func formatVersion() string {
|
||||||
|
v := version
|
||||||
if gitCommit != "" {
|
if gitCommit != "" {
|
||||||
fmt.Printf(" (git: %s)", gitCommit)
|
v += fmt.Sprintf(" (git: %s)", gitCommit)
|
||||||
}
|
}
|
||||||
fmt.Println()
|
return v
|
||||||
|
}
|
||||||
|
|
||||||
|
// formatBuildInfo returns build time and go version info
|
||||||
|
func formatBuildInfo() (build string, goVer string) {
|
||||||
if buildTime != "" {
|
if buildTime != "" {
|
||||||
fmt.Printf(" Build: %s\n", buildTime)
|
build = buildTime
|
||||||
}
|
}
|
||||||
goVer := goVersion
|
goVer = goVersion
|
||||||
if goVer == "" {
|
if goVer == "" {
|
||||||
goVer = runtime.Version()
|
goVer = runtime.Version()
|
||||||
}
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func printVersion() {
|
||||||
|
fmt.Printf("%s picoclaw %s\n", logo, formatVersion())
|
||||||
|
build, goVer := formatBuildInfo()
|
||||||
|
if build != "" {
|
||||||
|
fmt.Printf(" Build: %s\n", build)
|
||||||
|
}
|
||||||
if goVer != "" {
|
if goVer != "" {
|
||||||
fmt.Printf(" Go: %s\n", goVer)
|
fmt.Printf(" Go: %s\n", goVer)
|
||||||
}
|
}
|
||||||
@@ -766,13 +780,10 @@ func statusCmd() {
|
|||||||
configPath := getConfigPath()
|
configPath := getConfigPath()
|
||||||
|
|
||||||
fmt.Printf("%s picoclaw Status\n", logo)
|
fmt.Printf("%s picoclaw Status\n", logo)
|
||||||
fmt.Printf("Version: %s", version)
|
fmt.Printf("Version: %s\n", formatVersion())
|
||||||
if gitCommit != "" {
|
build, _ := formatBuildInfo()
|
||||||
fmt.Printf(" (git: %s)", gitCommit)
|
if build != "" {
|
||||||
}
|
fmt.Printf("Build: %s\n", build)
|
||||||
fmt.Println()
|
|
||||||
if buildTime != "" {
|
|
||||||
fmt.Printf("Build: %s\n", buildTime)
|
|
||||||
}
|
}
|
||||||
fmt.Println()
|
fmt.Println()
|
||||||
|
|
||||||
@@ -1295,53 +1306,6 @@ func cronEnableCmd(storePath string, disable bool) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func skillsCmd() {
|
|
||||||
if len(os.Args) < 3 {
|
|
||||||
skillsHelp()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
subcommand := os.Args[2]
|
|
||||||
|
|
||||||
cfg, err := loadConfig()
|
|
||||||
if err != nil {
|
|
||||||
fmt.Printf("Error loading config: %v\n", err)
|
|
||||||
os.Exit(1)
|
|
||||||
}
|
|
||||||
|
|
||||||
workspace := cfg.WorkspacePath()
|
|
||||||
installer := skills.NewSkillInstaller(workspace)
|
|
||||||
// 获取全局配置目录和内置 skills 目录
|
|
||||||
globalDir := filepath.Dir(getConfigPath())
|
|
||||||
globalSkillsDir := filepath.Join(globalDir, "skills")
|
|
||||||
builtinSkillsDir := filepath.Join(globalDir, "picoclaw", "skills")
|
|
||||||
skillsLoader := skills.NewSkillsLoader(workspace, globalSkillsDir, builtinSkillsDir)
|
|
||||||
|
|
||||||
switch subcommand {
|
|
||||||
case "list":
|
|
||||||
skillsListCmd(skillsLoader)
|
|
||||||
case "install":
|
|
||||||
skillsInstallCmd(installer)
|
|
||||||
case "remove", "uninstall":
|
|
||||||
if len(os.Args) < 4 {
|
|
||||||
fmt.Println("Usage: picoclaw skills remove <skill-name>")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
skillsRemoveCmd(installer, os.Args[3])
|
|
||||||
case "search":
|
|
||||||
skillsSearchCmd(installer)
|
|
||||||
case "show":
|
|
||||||
if len(os.Args) < 4 {
|
|
||||||
fmt.Println("Usage: picoclaw skills show <skill-name>")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
skillsShowCmd(skillsLoader, os.Args[3])
|
|
||||||
default:
|
|
||||||
fmt.Printf("Unknown skills command: %s\n", subcommand)
|
|
||||||
skillsHelp()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func skillsHelp() {
|
func skillsHelp() {
|
||||||
fmt.Println("\nSkills commands:")
|
fmt.Println("\nSkills commands:")
|
||||||
fmt.Println(" list List installed skills")
|
fmt.Println(" list List installed skills")
|
||||||
|
|||||||
Reference in New Issue
Block a user