fix: resolve build errors in pass_mgr, pcexec, and safe-restart
- Fix Go syntax error: use BoolVar for --username flag instead of string - Fix TypeScript type errors: filter undefined values from process.env - Fix TypeScript type error: add type assertion for fetch response - Add .gitignore to exclude node_modules and build outputs
This commit is contained in:
30
.gitignore
vendored
Normal file
30
.gitignore
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
# Dependencies
|
||||
node_modules/
|
||||
*.log
|
||||
|
||||
# Build outputs
|
||||
dist/
|
||||
*.exe
|
||||
*.dll
|
||||
*.so
|
||||
*.dylib
|
||||
|
||||
# Environment
|
||||
.env
|
||||
.env.local
|
||||
|
||||
# IDE
|
||||
.vscode/
|
||||
.idea/
|
||||
*.swp
|
||||
*.swo
|
||||
|
||||
# OS
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
|
||||
# Go
|
||||
*.o
|
||||
*.a
|
||||
*.test
|
||||
vendor/
|
||||
71
TEST_PLAN.md
Normal file
71
TEST_PLAN.md
Normal file
@@ -0,0 +1,71 @@
|
||||
# PaddedCell 测试计划 - 2026-03-05
|
||||
|
||||
## 当前状态
|
||||
- 代码已推送到 `dev/zhi` 分支
|
||||
- install.mjs 安装脚本已完成
|
||||
- 准备进行安装测试
|
||||
|
||||
## 测试步骤
|
||||
|
||||
### 1. 安装脚本测试
|
||||
```bash
|
||||
cd /root/.openclaw/workspace-developer/PaddedCell
|
||||
node install.mjs --verbose
|
||||
```
|
||||
|
||||
### 2. 验证安装
|
||||
- [ ] pass_mgr 二进制可执行
|
||||
- [ ] pcexec 模块存在
|
||||
- [ ] safe-restart 模块存在
|
||||
- [ ] manifest.json 已创建
|
||||
|
||||
### 3. pass_mgr 功能测试
|
||||
```bash
|
||||
# 初始化
|
||||
pass_mgr admin init
|
||||
|
||||
# 设置测试密码
|
||||
pass_mgr set test_key test_password --username testuser
|
||||
|
||||
# 获取密码
|
||||
pass_mgr get test_key
|
||||
|
||||
# 获取用户名
|
||||
pass_mgr get test_key --username
|
||||
|
||||
# 生成新密码
|
||||
pass_mgr generate new_key --username newuser
|
||||
|
||||
# 轮换密码
|
||||
pass_mgr rotate new_key
|
||||
|
||||
# 删除密码
|
||||
pass_mgr unset test_key
|
||||
```
|
||||
|
||||
### 4. pcexec 功能测试
|
||||
- 测试密码脱敏功能
|
||||
- 测试多次 pass_mgr get 替换
|
||||
|
||||
### 5. safe-restart 功能测试
|
||||
- 测试状态机
|
||||
- 测试 API 接口
|
||||
|
||||
## 可能遇到的问题
|
||||
|
||||
1. **Go 依赖问题** - 需要确保 go mod tidy 能正常下载依赖
|
||||
2. **Node.js 构建问题** - npm install 可能需要较长时间
|
||||
3. **权限问题** - 二进制可能需要 chmod +x
|
||||
|
||||
## 重启后计划
|
||||
|
||||
如果测试过程中需要重启 OpenClaw gateway,重启后我需要:
|
||||
|
||||
1. **验证环境变量** - 检查 PATH 和 PADDEDCELL_SKILLS_DIR 是否正确设置
|
||||
2. **继续安装测试** - 重新运行 install.mjs 或验证已安装组件
|
||||
3. **功能测试** - 测试 pass_mgr/pcexec/safe-restart 是否正常工作
|
||||
4. **记录结果** - 更新此文件,记录测试通过/失败项
|
||||
|
||||
## 阻塞点
|
||||
|
||||
当前无阻塞,可以立即开始测试。
|
||||
@@ -2,9 +2,7 @@ module pass_mgr
|
||||
|
||||
go 1.22
|
||||
|
||||
require (
|
||||
github.com/spf13/cobra v1.8.0
|
||||
)
|
||||
require github.com/spf13/cobra v1.8.0
|
||||
|
||||
require (
|
||||
github.com/inconshreveable/mousetrap v1.1.0 // indirect
|
||||
|
||||
10
pass_mgr/go.sum
Normal file
10
pass_mgr/go.sum
Normal file
@@ -0,0 +1,10 @@
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
|
||||
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
|
||||
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
|
||||
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||
github.com/spf13/cobra v1.8.0 h1:7aJaZx1B85qltLMc546zn58BxxfZdR/W22ej9CFoEf0=
|
||||
github.com/spf13/cobra v1.8.0/go.mod h1:WXLWApfZ71AjXPya3WOlMsY9yMs7YeiHhFVlvLyhcho=
|
||||
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
|
||||
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
@@ -41,7 +41,6 @@ type Config struct {
|
||||
var (
|
||||
workspaceDir string
|
||||
agentID string
|
||||
username string
|
||||
)
|
||||
|
||||
func main() {
|
||||
@@ -70,7 +69,8 @@ func main() {
|
||||
}
|
||||
|
||||
func getCmd() *cobra.Command {
|
||||
return &cobra.Command{
|
||||
var showUsername bool
|
||||
cmd := &cobra.Command{
|
||||
Use: "get [key]",
|
||||
Short: "Get password for a key",
|
||||
Args: cobra.ExactArgs(1),
|
||||
@@ -81,13 +81,15 @@ func getCmd() *cobra.Command {
|
||||
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
if username {
|
||||
if showUsername {
|
||||
fmt.Println(user)
|
||||
} else {
|
||||
fmt.Println(password)
|
||||
}
|
||||
},
|
||||
}
|
||||
cmd.Flags().BoolVar(&showUsername, "username", false, "Show username instead of password")
|
||||
return cmd
|
||||
}
|
||||
|
||||
func generateCmd() *cobra.Command {
|
||||
|
||||
3846
pcexec/package-lock.json
generated
Normal file
3846
pcexec/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -164,10 +164,19 @@ async function replacePassMgrGets(command: string): Promise<{ command: string; p
|
||||
*/
|
||||
export async function pcexec(command: string, options: PcExecOptions = {}): Promise<PcExecResult> {
|
||||
// Set up environment with workspace/agent info
|
||||
const env: Record<string, string> = {
|
||||
...process.env,
|
||||
...options.env,
|
||||
};
|
||||
const env: Record<string, string> = {};
|
||||
|
||||
// Copy process.env, filtering out undefined values
|
||||
for (const [key, value] of Object.entries(process.env)) {
|
||||
if (value !== undefined) {
|
||||
env[key] = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Merge options.env
|
||||
if (options.env) {
|
||||
Object.assign(env, options.env);
|
||||
}
|
||||
|
||||
if (process.env.AGENT_WORKSPACE) {
|
||||
env.AGENT_WORKSPACE = process.env.AGENT_WORKSPACE;
|
||||
@@ -284,10 +293,19 @@ export function pcexecSync(command: string, options: PcExecOptions = {}): PcExec
|
||||
const { execSync } = require('child_process');
|
||||
|
||||
// Set up environment
|
||||
const env: Record<string, string> = {
|
||||
...process.env,
|
||||
...options.env,
|
||||
};
|
||||
const env: Record<string, string> = {};
|
||||
|
||||
// Copy process.env, filtering out undefined values
|
||||
for (const [key, value] of Object.entries(process.env)) {
|
||||
if (value !== undefined) {
|
||||
env[key] = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Merge options.env
|
||||
if (options.env) {
|
||||
Object.assign(env, options.env);
|
||||
}
|
||||
|
||||
if (process.env.AGENT_WORKSPACE) {
|
||||
env.AGENT_WORKSPACE = process.env.AGENT_WORKSPACE;
|
||||
|
||||
4821
safe-restart/package-lock.json
generated
Normal file
4821
safe-restart/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -73,7 +73,7 @@ export async function safeRestart(options: SafeRestartOptions): Promise<SafeRest
|
||||
}),
|
||||
});
|
||||
|
||||
const data = await response.json();
|
||||
const data = await response.json() as { status: string };
|
||||
|
||||
if (data.status === 'OK') {
|
||||
log('All agents ready for restart');
|
||||
|
||||
Reference in New Issue
Block a user