clawsouls 0.0.1 → 0.1.1
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/LICENSE +204 -0
- package/README.md +143 -0
- package/dist/bin/clawsouls.d.ts +2 -0
- package/dist/bin/clawsouls.js +31 -0
- package/dist/bin/clawsouls.js.map +1 -0
- package/dist/commands/init.d.ts +1 -0
- package/dist/commands/init.js +107 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/install.d.ts +3 -0
- package/dist/commands/install.js +53 -0
- package/dist/commands/install.js.map +1 -0
- package/dist/commands/list.d.ts +1 -0
- package/dist/commands/list.js +21 -0
- package/dist/commands/list.js.map +1 -0
- package/dist/commands/restore.d.ts +1 -0
- package/dist/commands/restore.js +21 -0
- package/dist/commands/restore.js.map +1 -0
- package/dist/commands/use.d.ts +1 -0
- package/dist/commands/use.js +28 -0
- package/dist/commands/use.js.map +1 -0
- package/dist/registry/client.d.ts +24 -0
- package/dist/registry/client.js +55 -0
- package/dist/registry/client.js.map +1 -0
- package/dist/storage/local.d.ts +21 -0
- package/dist/storage/local.js +98 -0
- package/dist/storage/local.js.map +1 -0
- package/dist/storage/manager.d.ts +31 -0
- package/dist/storage/manager.js +141 -0
- package/dist/storage/manager.js.map +1 -0
- package/dist/utils/config.d.ts +12 -0
- package/dist/utils/config.js +37 -0
- package/dist/utils/config.js.map +1 -0
- package/dist/utils/validate.d.ts +30 -0
- package/dist/utils/validate.js +32 -0
- package/dist/utils/validate.js.map +1 -0
- package/package.json +44 -6
- package/index.js +0 -2
package/LICENSE
ADDED
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
Copyright 2026 ClawSouls
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
Apache License
|
|
5
|
+
Version 2.0, January 2004
|
|
6
|
+
http://www.apache.org/licenses/
|
|
7
|
+
|
|
8
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
9
|
+
|
|
10
|
+
1. Definitions.
|
|
11
|
+
|
|
12
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
13
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
14
|
+
|
|
15
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
16
|
+
the copyright owner that is granting the License.
|
|
17
|
+
|
|
18
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
19
|
+
other entities that control, are controlled by, or are under common
|
|
20
|
+
control with that entity. For the purposes of this definition,
|
|
21
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
22
|
+
direction or management of such entity, whether by contract or
|
|
23
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
24
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
25
|
+
|
|
26
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
27
|
+
exercising permissions granted by this License.
|
|
28
|
+
|
|
29
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
30
|
+
including but not limited to software source code, documentation
|
|
31
|
+
source, and configuration files.
|
|
32
|
+
|
|
33
|
+
"Object" form shall mean any form resulting from mechanical
|
|
34
|
+
transformation or translation of a Source form, including but
|
|
35
|
+
not limited to compiled object code, generated documentation,
|
|
36
|
+
and conversions to other media types.
|
|
37
|
+
|
|
38
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
39
|
+
Object form, made available under the License, as indicated by a
|
|
40
|
+
copyright notice that is included in or attached to the work
|
|
41
|
+
(an example is provided in the Appendix below).
|
|
42
|
+
|
|
43
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
44
|
+
form, that is based on (or derived from) the Work and for which the
|
|
45
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
46
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
47
|
+
of this License, Derivative Works shall not include works that remain
|
|
48
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
49
|
+
the Work and Derivative Works thereof.
|
|
50
|
+
|
|
51
|
+
"Contribution" shall mean any work of authorship, including
|
|
52
|
+
the original version of the Work and any modifications or additions
|
|
53
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
54
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
55
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
56
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
57
|
+
means any form of electronic, verbal, or written communication sent
|
|
58
|
+
to the Licensor or its representatives, including but not limited to
|
|
59
|
+
communication on electronic mailing lists, source code control systems,
|
|
60
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
61
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
62
|
+
excluding communication that is conspicuously marked or otherwise
|
|
63
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
64
|
+
|
|
65
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
66
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
67
|
+
subsequently incorporated within the Work.
|
|
68
|
+
|
|
69
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
70
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
71
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
72
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
73
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
74
|
+
Work and such Derivative Works in Source or Object form.
|
|
75
|
+
|
|
76
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
77
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
78
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
79
|
+
(except as stated in this section) patent license to make, have made,
|
|
80
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
81
|
+
where such license applies only to those patent claims licensable
|
|
82
|
+
by such Contributor that are necessarily infringed by their
|
|
83
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
84
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
85
|
+
institute patent litigation against any entity (including a
|
|
86
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
87
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
88
|
+
or contributory patent infringement, then any patent licenses
|
|
89
|
+
granted to You under this License for that Work shall terminate
|
|
90
|
+
as of the date such litigation is filed.
|
|
91
|
+
|
|
92
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
93
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
94
|
+
modifications, and in Source or Object form, provided that You
|
|
95
|
+
meet the following conditions:
|
|
96
|
+
|
|
97
|
+
(a) You must give any other recipients of the Work or
|
|
98
|
+
Derivative Works a copy of this License; and
|
|
99
|
+
|
|
100
|
+
(b) You must cause any modified files to carry prominent notices
|
|
101
|
+
stating that You changed the files; and
|
|
102
|
+
|
|
103
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
104
|
+
that You distribute, all copyright, patent, trademark, and
|
|
105
|
+
attribution notices from the Source form of the Work,
|
|
106
|
+
excluding those notices that do not pertain to any part of
|
|
107
|
+
the Derivative Works; and
|
|
108
|
+
|
|
109
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
110
|
+
distribution, then any Derivative Works that You distribute must
|
|
111
|
+
include a readable copy of the attribution notices contained
|
|
112
|
+
within such NOTICE file, excluding those notices that do not
|
|
113
|
+
pertain to any part of the Derivative Works, in at least one
|
|
114
|
+
of the following places: within a NOTICE text file distributed
|
|
115
|
+
as part of the Derivative Works; within the Source form or
|
|
116
|
+
documentation, if provided along with the Derivative Works; or,
|
|
117
|
+
within a display generated by the Derivative Works, if and
|
|
118
|
+
wherever such third-party notices normally appear. The contents
|
|
119
|
+
of the NOTICE file are for informational purposes only and
|
|
120
|
+
do not modify the License. You may add Your own attribution
|
|
121
|
+
notices within Derivative Works that You distribute, alongside
|
|
122
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
123
|
+
that such additional attribution notices cannot be construed
|
|
124
|
+
as modifying the License.
|
|
125
|
+
|
|
126
|
+
You may add Your own copyright statement to Your modifications and
|
|
127
|
+
may provide additional or different license terms and conditions
|
|
128
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
129
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
130
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
131
|
+
the conditions stated in this License.
|
|
132
|
+
|
|
133
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
134
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
135
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
136
|
+
this License, without any additional terms or conditions.
|
|
137
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
138
|
+
the terms of any separate license agreement you may have executed
|
|
139
|
+
with Licensor regarding such Contributions.
|
|
140
|
+
|
|
141
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
142
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
143
|
+
except as required for reasonable and customary use in describing the
|
|
144
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
145
|
+
|
|
146
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
147
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
148
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
149
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
150
|
+
implied, including, without limitation, any warranties or conditions
|
|
151
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
152
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
153
|
+
appropriateness of using or redistributing the Work and assume any
|
|
154
|
+
risks associated with Your exercise of permissions under this License.
|
|
155
|
+
|
|
156
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
157
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
158
|
+
unless required by applicable law (such as deliberate and grossly
|
|
159
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
160
|
+
liable to You for damages, including any direct, indirect, special,
|
|
161
|
+
incidental, or consequential damages of any character arising as a
|
|
162
|
+
result of this License or out of the use or inability to use the
|
|
163
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
164
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
165
|
+
other commercial damages or losses), even if such Contributor
|
|
166
|
+
has been advised of the possibility of such damages.
|
|
167
|
+
|
|
168
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
169
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
170
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
171
|
+
or other liability obligations and/or rights consistent with this
|
|
172
|
+
License. However, in accepting such obligations, You may act only
|
|
173
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
174
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
175
|
+
defend, and hold each Contributor harmless for any liability
|
|
176
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
177
|
+
of your accepting any such warranty or additional liability.
|
|
178
|
+
|
|
179
|
+
END OF TERMS AND CONDITIONS
|
|
180
|
+
|
|
181
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
182
|
+
|
|
183
|
+
To apply the Apache License to your work, attach the following
|
|
184
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
185
|
+
replaced with your own identifying information. (Don't include
|
|
186
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
187
|
+
comment syntax for the file format. We also recommend that a
|
|
188
|
+
file or class name and description of purpose be included on the
|
|
189
|
+
same "printed page" as the copyright notice for easier
|
|
190
|
+
identification within third-party archives.
|
|
191
|
+
|
|
192
|
+
Copyright [yyyy] [name of copyright owner]
|
|
193
|
+
|
|
194
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
195
|
+
you may not use this file except in compliance with the License.
|
|
196
|
+
You may obtain a copy of the License at
|
|
197
|
+
|
|
198
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
199
|
+
|
|
200
|
+
Unless required by applicable law or agreed to in writing, software
|
|
201
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
202
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
203
|
+
See the License for the specific language governing permissions and
|
|
204
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
# 🧠 ClawSouls CLI
|
|
2
|
+
|
|
3
|
+
**Give your AI a soul.** Install, manage, and switch AI agent personas for [OpenClaw](https://github.com/openclaw/openclaw).
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/clawsouls)
|
|
6
|
+
[](LICENSE)
|
|
7
|
+
|
|
8
|
+
## What is ClawSouls?
|
|
9
|
+
|
|
10
|
+
ClawSouls is a persona sharing platform for AI agents. A **Soul** is a personality package — a set of markdown files that define how your AI thinks, talks, and behaves. Same LLM, completely different personality.
|
|
11
|
+
|
|
12
|
+
Browse available souls at [clawsouls.ai](https://clawsouls.ai).
|
|
13
|
+
|
|
14
|
+
## Quick Start
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
# Install a soul
|
|
18
|
+
npx clawsouls install brad
|
|
19
|
+
|
|
20
|
+
# Activate it (backs up your current workspace)
|
|
21
|
+
npx clawsouls use brad
|
|
22
|
+
|
|
23
|
+
# Restart your OpenClaw session — done!
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Installation
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
# Use directly with npx (no install needed)
|
|
30
|
+
npx clawsouls <command>
|
|
31
|
+
|
|
32
|
+
# Or install globally
|
|
33
|
+
npm install -g clawsouls
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
**Requirements:** Node.js 22+
|
|
37
|
+
|
|
38
|
+
## Commands
|
|
39
|
+
|
|
40
|
+
### `clawsouls install <name>`
|
|
41
|
+
|
|
42
|
+
Download and install a soul from the registry.
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
clawsouls install minimalist
|
|
46
|
+
clawsouls install devops-veteran
|
|
47
|
+
clawsouls install brad --force # overwrite existing
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### `clawsouls use <name>`
|
|
51
|
+
|
|
52
|
+
Activate an installed soul. Your current workspace files are automatically backed up before switching.
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
clawsouls use minimalist
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
**Protected files** — these are never overwritten:
|
|
59
|
+
- `USER.md` (your personal data)
|
|
60
|
+
- `MEMORY.md` (your AI's memories)
|
|
61
|
+
- `TOOLS.md` (your tool configuration)
|
|
62
|
+
|
|
63
|
+
### `clawsouls restore`
|
|
64
|
+
|
|
65
|
+
Revert to your previous soul from the latest backup.
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
clawsouls restore
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### `clawsouls list`
|
|
72
|
+
|
|
73
|
+
Show all installed souls.
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
clawsouls list
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## Available Souls
|
|
80
|
+
|
|
81
|
+
| Soul | Category | Description |
|
|
82
|
+
|------|----------|-------------|
|
|
83
|
+
| 🅱️ **Brad** | Engineering | Formal, project-focused development partner |
|
|
84
|
+
| 🔧 **DevOps Veteran** | DevOps | Battle-scarred infrastructure engineer |
|
|
85
|
+
| 🎮 **GameDev Mentor** | Game Dev | Experienced game developer and mentor |
|
|
86
|
+
| ⚡ **Minimalist** | Lifestyle | Extremely concise responses |
|
|
87
|
+
| 🔍 **Code Reviewer** | Engineering | Thorough, constructive code reviewer |
|
|
88
|
+
| 📚 **Coding Tutor** | Education | Patient programming teacher |
|
|
89
|
+
| 📋 **Personal Assistant** | Lifestyle | Proactive daily life assistant |
|
|
90
|
+
| 📝 **Tech Writer** | Writing | Clear technical documentation writer |
|
|
91
|
+
| 📊 **Data Analyst** | Data | Insight-driven data analyst |
|
|
92
|
+
| ✍️ **Storyteller** | Creative | Narrative crafter and worldbuilder |
|
|
93
|
+
|
|
94
|
+
Browse all at [clawsouls.ai](https://clawsouls.ai).
|
|
95
|
+
|
|
96
|
+
## What's in a Soul?
|
|
97
|
+
|
|
98
|
+
A soul is a directory with these files:
|
|
99
|
+
|
|
100
|
+
```
|
|
101
|
+
my-soul/
|
|
102
|
+
├── clawsoul.json # Metadata (name, version, tags)
|
|
103
|
+
├── SOUL.md # Personality & behavior
|
|
104
|
+
├── IDENTITY.md # Name, emoji, avatar
|
|
105
|
+
├── AGENTS.md # Workflow & rules
|
|
106
|
+
├── HEARTBEAT.md # Periodic task config
|
|
107
|
+
└── README.md # Documentation
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
The spec is open — see [Soul Spec](https://github.com/clawsouls/clawsouls/blob/main/docs/SOUL_SPEC.md).
|
|
111
|
+
|
|
112
|
+
## How It Works
|
|
113
|
+
|
|
114
|
+
```
|
|
115
|
+
┌─────────────┐ install ┌──────────────┐
|
|
116
|
+
│ Registry │ ──────────────→│ ~/.openclaw/ │
|
|
117
|
+
│ (GitHub) │ │ souls/brad/ │
|
|
118
|
+
└─────────────┘ └──────┬───────┘
|
|
119
|
+
│ use
|
|
120
|
+
▼
|
|
121
|
+
┌──────────────┐
|
|
122
|
+
│ ~/.openclaw/ │
|
|
123
|
+
│ workspace/ │
|
|
124
|
+
│ ├ SOUL.md │
|
|
125
|
+
│ ├ IDENTITY.md│
|
|
126
|
+
│ └ AGENTS.md │
|
|
127
|
+
└──────────────┘
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
1. **Install** downloads soul files to `~/.openclaw/souls/<name>/`
|
|
131
|
+
2. **Use** backs up your workspace, then copies soul files in
|
|
132
|
+
3. **Restart** your OpenClaw session to load the new personality
|
|
133
|
+
|
|
134
|
+
## Links
|
|
135
|
+
|
|
136
|
+
- 🌐 [clawsouls.ai](https://clawsouls.ai) — Browse souls
|
|
137
|
+
- 📦 [npm](https://www.npmjs.com/package/clawsouls) — Package
|
|
138
|
+
- 📋 [Soul Spec](https://github.com/clawsouls/clawsouls/blob/main/docs/SOUL_SPEC.md) — Create your own
|
|
139
|
+
- 🐙 [GitHub Org](https://github.com/clawsouls) — Source code
|
|
140
|
+
|
|
141
|
+
## License
|
|
142
|
+
|
|
143
|
+
Apache 2.0 — see [LICENSE](LICENSE).
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { Command } from 'commander';
|
|
3
|
+
import { installCommand } from '../commands/install.js';
|
|
4
|
+
import { useCommand } from '../commands/use.js';
|
|
5
|
+
import { restoreCommand } from '../commands/restore.js';
|
|
6
|
+
import { listCommand } from '../commands/list.js';
|
|
7
|
+
const program = new Command();
|
|
8
|
+
program
|
|
9
|
+
.name('clawsouls')
|
|
10
|
+
.description('AI agent persona manager for OpenClaw')
|
|
11
|
+
.version('0.1.0');
|
|
12
|
+
program
|
|
13
|
+
.command('install <name>')
|
|
14
|
+
.description('Install a soul from the registry')
|
|
15
|
+
.option('-f, --force', 'Overwrite if already installed')
|
|
16
|
+
.action(installCommand);
|
|
17
|
+
program
|
|
18
|
+
.command('use <name>')
|
|
19
|
+
.description('Activate an installed soul (backs up current workspace)')
|
|
20
|
+
.action(useCommand);
|
|
21
|
+
program
|
|
22
|
+
.command('restore')
|
|
23
|
+
.description('Restore workspace from the latest backup')
|
|
24
|
+
.action(restoreCommand);
|
|
25
|
+
program
|
|
26
|
+
.command('list')
|
|
27
|
+
.alias('ls')
|
|
28
|
+
.description('List installed souls')
|
|
29
|
+
.action(listCommand);
|
|
30
|
+
program.parse();
|
|
31
|
+
//# sourceMappingURL=clawsouls.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clawsouls.js","sourceRoot":"","sources":["../../src/bin/clawsouls.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAElD,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;AAE9B,OAAO;KACJ,IAAI,CAAC,WAAW,CAAC;KACjB,WAAW,CAAC,uCAAuC,CAAC;KACpD,OAAO,CAAC,OAAO,CAAC,CAAC;AAEpB,OAAO;KACJ,OAAO,CAAC,gBAAgB,CAAC;KACzB,WAAW,CAAC,kCAAkC,CAAC;KAC/C,MAAM,CAAC,aAAa,EAAE,gCAAgC,CAAC;KACvD,MAAM,CAAC,cAAc,CAAC,CAAC;AAE1B,OAAO;KACJ,OAAO,CAAC,YAAY,CAAC;KACrB,WAAW,CAAC,yDAAyD,CAAC;KACtE,MAAM,CAAC,UAAU,CAAC,CAAC;AAEtB,OAAO;KACJ,OAAO,CAAC,SAAS,CAAC;KAClB,WAAW,CAAC,0CAA0C,CAAC;KACvD,MAAM,CAAC,cAAc,CAAC,CAAC;AAE1B,OAAO;KACJ,OAAO,CAAC,MAAM,CAAC;KACf,KAAK,CAAC,IAAI,CAAC;KACX,WAAW,CAAC,sBAAsB,CAAC;KACnC,MAAM,CAAC,WAAW,CAAC,CAAC;AAEvB,OAAO,CAAC,KAAK,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function initCommand(name?: string): Promise<void>;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
import { writeFileSync, mkdirSync, existsSync } from 'fs';
|
|
3
|
+
import { join } from 'path';
|
|
4
|
+
export async function initCommand(name) {
|
|
5
|
+
const soulName = name || 'my-soul';
|
|
6
|
+
const dir = join(process.cwd(), soulName);
|
|
7
|
+
if (existsSync(dir)) {
|
|
8
|
+
console.log(chalk.red(`Directory "${soulName}" already exists.`));
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
mkdirSync(dir, { recursive: true });
|
|
12
|
+
// clawsoul.json
|
|
13
|
+
const meta = {
|
|
14
|
+
name: soulName,
|
|
15
|
+
displayName: soulName.split('-').map(w => w[0].toUpperCase() + w.slice(1)).join(' '),
|
|
16
|
+
version: '1.0.0',
|
|
17
|
+
description: 'Describe your soul in one sentence.',
|
|
18
|
+
author: {
|
|
19
|
+
name: 'Your Name',
|
|
20
|
+
github: 'your-github',
|
|
21
|
+
},
|
|
22
|
+
license: 'Apache-2.0',
|
|
23
|
+
tags: [],
|
|
24
|
+
category: 'work/engineering',
|
|
25
|
+
compatibility: {
|
|
26
|
+
openclaw: '>=2026.2.0',
|
|
27
|
+
},
|
|
28
|
+
files: {
|
|
29
|
+
soul: 'SOUL.md',
|
|
30
|
+
identity: 'IDENTITY.md',
|
|
31
|
+
agents: 'AGENTS.md',
|
|
32
|
+
heartbeat: 'HEARTBEAT.md',
|
|
33
|
+
},
|
|
34
|
+
skills: [],
|
|
35
|
+
};
|
|
36
|
+
writeFileSync(join(dir, 'clawsoul.json'), JSON.stringify(meta, null, 2));
|
|
37
|
+
// SOUL.md
|
|
38
|
+
writeFileSync(join(dir, 'SOUL.md'), `# ${meta.displayName}
|
|
39
|
+
|
|
40
|
+
Describe who this AI persona is.
|
|
41
|
+
|
|
42
|
+
## Personality
|
|
43
|
+
|
|
44
|
+
- **Tone**:
|
|
45
|
+
- **Style**:
|
|
46
|
+
- **Philosophy**:
|
|
47
|
+
|
|
48
|
+
## Principles
|
|
49
|
+
|
|
50
|
+
1. ...
|
|
51
|
+
2. ...
|
|
52
|
+
3. ...
|
|
53
|
+
|
|
54
|
+
## Communication
|
|
55
|
+
|
|
56
|
+
- ...
|
|
57
|
+
|
|
58
|
+
## Boundaries
|
|
59
|
+
|
|
60
|
+
- ...
|
|
61
|
+
`);
|
|
62
|
+
// IDENTITY.md
|
|
63
|
+
writeFileSync(join(dir, 'IDENTITY.md'), `# ${meta.displayName}
|
|
64
|
+
|
|
65
|
+
- **Name:**
|
|
66
|
+
- **Creature:**
|
|
67
|
+
- **Vibe:**
|
|
68
|
+
- **Emoji:**
|
|
69
|
+
`);
|
|
70
|
+
// AGENTS.md
|
|
71
|
+
writeFileSync(join(dir, 'AGENTS.md'), `# ${meta.displayName} — Workflow
|
|
72
|
+
|
|
73
|
+
## Every Session
|
|
74
|
+
1. Read SOUL.md, USER.md, memory files
|
|
75
|
+
2. ...
|
|
76
|
+
|
|
77
|
+
## Work Rules
|
|
78
|
+
- ...
|
|
79
|
+
|
|
80
|
+
## Safety
|
|
81
|
+
- ...
|
|
82
|
+
|
|
83
|
+
## Heartbeats
|
|
84
|
+
- ...
|
|
85
|
+
`);
|
|
86
|
+
// HEARTBEAT.md
|
|
87
|
+
writeFileSync(join(dir, 'HEARTBEAT.md'), '# Heartbeat Checks\n# Add your periodic checks here\n');
|
|
88
|
+
// README.md
|
|
89
|
+
writeFileSync(join(dir, 'README.md'), `# ${meta.displayName}
|
|
90
|
+
|
|
91
|
+
Short description.
|
|
92
|
+
|
|
93
|
+
**Best for:** ...
|
|
94
|
+
|
|
95
|
+
**Personality:** ...
|
|
96
|
+
|
|
97
|
+
**Skills:** ...
|
|
98
|
+
`);
|
|
99
|
+
console.log();
|
|
100
|
+
console.log(chalk.green(`✅ Soul "${soulName}" created!`));
|
|
101
|
+
console.log();
|
|
102
|
+
console.log(` ${chalk.cyan('Edit:')} cd ${soulName} && edit SOUL.md`);
|
|
103
|
+
console.log(` ${chalk.cyan('Test:')} clawsouls use ${soulName} (after install)`);
|
|
104
|
+
console.log(` ${chalk.cyan('Publish:')} clawsouls publish (coming soon)`);
|
|
105
|
+
console.log();
|
|
106
|
+
}
|
|
107
|
+
//# sourceMappingURL=init.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,UAAU,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1
|
+
import chalk from 'chalk';
|
|
2
|
+
import ora from 'ora';
|
|
3
|
+
import { RegistryClient } from '../registry/client.js';
|
|
4
|
+
import { StorageManager } from '../storage/manager.js';
|
|
5
|
+
import { writeFileSync } from 'fs';
|
|
6
|
+
import { join } from 'path';
|
|
7
|
+
import { ensureDir } from '../utils/config.js';
|
|
8
|
+
export async function installCommand(nameWithVersion, options) {
|
|
9
|
+
const [name, version] = nameWithVersion.split('@');
|
|
10
|
+
const spinner = ora(`Installing soul "${name}"...`).start();
|
|
11
|
+
try {
|
|
12
|
+
const storage = new StorageManager();
|
|
13
|
+
const registry = new RegistryClient();
|
|
14
|
+
// Check if already installed
|
|
15
|
+
if (storage.isInstalled(name) && !options.force) {
|
|
16
|
+
spinner.fail(`Soul "${name}" is already installed. Use ${chalk.yellow('--force')} to overwrite.`);
|
|
17
|
+
process.exit(1);
|
|
18
|
+
}
|
|
19
|
+
// Fetch metadata
|
|
20
|
+
spinner.text = `Fetching "${name}" metadata...`;
|
|
21
|
+
const meta = await registry.getSoulMeta(name);
|
|
22
|
+
// Get file list and download each
|
|
23
|
+
spinner.text = `Downloading "${name}" files...`;
|
|
24
|
+
const fileList = await registry.getSoulFiles(name);
|
|
25
|
+
const files = new Map();
|
|
26
|
+
for (const filename of fileList) {
|
|
27
|
+
try {
|
|
28
|
+
const content = await registry.downloadFile(name, filename);
|
|
29
|
+
files.set(filename, content);
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
// Skip missing optional files
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
// Save to souls directory
|
|
36
|
+
spinner.text = `Saving to local storage...`;
|
|
37
|
+
const soulDir = storage.getSoulDir(name);
|
|
38
|
+
ensureDir(soulDir);
|
|
39
|
+
for (const [filename, content] of files) {
|
|
40
|
+
const filePath = join(soulDir, filename);
|
|
41
|
+
ensureDir(join(filePath, '..'));
|
|
42
|
+
writeFileSync(filePath, content, 'utf-8');
|
|
43
|
+
}
|
|
44
|
+
spinner.succeed(`Installed ${chalk.green(meta.displayName || name)} v${meta.version || '?'}\n` +
|
|
45
|
+
` ${chalk.dim(meta.description || '')}\n` +
|
|
46
|
+
` Run ${chalk.cyan(`clawsouls use ${name}`)} to activate.`);
|
|
47
|
+
}
|
|
48
|
+
catch (err) {
|
|
49
|
+
spinner.fail(err.message);
|
|
50
|
+
process.exit(1);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=install.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"install.js","sourceRoot":"","sources":["../../src/commands/install.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,GAAG,MAAM,KAAK,CAAC;AACtB,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,IAAI,CAAC;AACnC,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAE/C,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,eAAuB,EAAE,OAA4B;IACxF,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,eAAe,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACnD,MAAM,OAAO,GAAG,GAAG,CAAC,oBAAoB,IAAI,MAAM,CAAC,CAAC,KAAK,EAAE,CAAC;IAE5D,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,IAAI,cAAc,EAAE,CAAC;QACrC,MAAM,QAAQ,GAAG,IAAI,cAAc,EAAE,CAAC;QAEtC,6BAA6B;QAC7B,IAAI,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;YAChD,OAAO,CAAC,IAAI,CAAC,SAAS,IAAI,+BAA+B,KAAK,CA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CAAC,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC,KAAK,IAAI,CAAC,OAAO,IAAI,GAAG,IAAI;YAC9E,KAAK,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,IAAI,EAAE,CAAC,IAAI;YAC1C,SAAS,KAAK,CAAC,IAAI,CAAC,iBAAiB,IAAI,EAAE,CAAC,eAAe,CAC5D,CAAC;IACJ,CAAC;IAAC,OAAO,GAAQ,EAAE,CAAC;QAClB,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAC1B,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function listCommand(): Promise<void>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
import { StorageManager } from '../storage/manager.js';
|
|
3
|
+
export async function listCommand() {
|
|
4
|
+
const storage = new StorageManager();
|
|
5
|
+
const souls = storage.listInstalled();
|
|
6
|
+
if (souls.length === 0) {
|
|
7
|
+
console.log(chalk.dim('No souls installed.'));
|
|
8
|
+
console.log(` Run ${chalk.cyan('clawsouls install <name>')} to get started.`);
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
console.log(chalk.bold(`\n Installed Souls (${souls.length})\n`));
|
|
12
|
+
for (const soul of souls) {
|
|
13
|
+
console.log(` ${chalk.green(soul.displayName)} ${chalk.dim(`v${soul.version}`)}` +
|
|
14
|
+
` ${chalk.yellow(soul.category)}`);
|
|
15
|
+
if (soul.description) {
|
|
16
|
+
console.log(` ${chalk.dim(soul.description)}`);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
console.log();
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=list.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list.js","sourceRoot":"","sources":["../../src/commands/list.ts"],"names":[],"mappings":"AAA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
import { StorageManager } from '../storage/manager.js';
|
|
4
|
+
export async function restoreCommand() {
|
|
5
|
+
const spinner = ora('Restoring previous soul...').start();
|
|
6
|
+
try {
|
|
7
|
+
const storage = new StorageManager();
|
|
8
|
+
const restored = storage.restore();
|
|
9
|
+
if (!restored) {
|
|
10
|
+
spinner.fail('No backups found. Nothing to restore.');
|
|
11
|
+
process.exit(1);
|
|
12
|
+
}
|
|
13
|
+
spinner.succeed(`Restored from backup ${chalk.dim(restored)}\n` +
|
|
14
|
+
` ${chalk.yellow('⚠')} Restart your OpenClaw session for changes to take effect.`);
|
|
15
|
+
}
|
|
16
|
+
catch (err) {
|
|
17
|
+
spinner.fail(err.message);
|
|
18
|
+
process.exit(1);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=restore.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"restore.js","sourceRoot":"","sources":["../../src/commands/restore.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,GAAG,MAAM,KAAK,CAAC;AACtB,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEvD,MAAM,CAAC,KAAK,UAAU,cAAc;IAClC,MAAM,OAAO,GAAG,GAAG,CAAC,4BAA4B,CAAC,CAAC,KAAK,EAAE,CAAC;IAE1D,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,IAAI,cAAc,EAAE,CAAC;QACrC,MAAM,QAAQ,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;QAEnC,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,OAAO,CAAC,IAAI,CAAC,uCAAuC,CAAC,CAAC;YACtD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;QAED,OAAO,CAAC,OAAO,CACb,wBAAwB,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI;YAC/C,KAAK,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,6DAA6D,CACpF,CAAC;IACJ,CAAC;IAAC,OAAO,GAAQ,EAAE,CAAC;QAClB,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAC1B,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useCommand(name: string): Promise<void>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
import ora from 'ora';
|
|
3
|
+
import { StorageManager } from '../storage/manager.js';
|
|
4
|
+
export async function useCommand(name) {
|
|
5
|
+
const spinner = ora(`Switching to soul "${name}"...`).start();
|
|
6
|
+
try {
|
|
7
|
+
const storage = new StorageManager();
|
|
8
|
+
if (!storage.isInstalled(name)) {
|
|
9
|
+
spinner.fail(`Soul "${name}" is not installed.\n` +
|
|
10
|
+
` Run ${chalk.cyan(`clawsouls install ${name}`)} first.`);
|
|
11
|
+
process.exit(1);
|
|
12
|
+
}
|
|
13
|
+
// Backup current workspace
|
|
14
|
+
spinner.text = 'Backing up current workspace...';
|
|
15
|
+
const backupPath = storage.backupWorkspace();
|
|
16
|
+
// Apply soul
|
|
17
|
+
spinner.text = `Applying "${name}"...`;
|
|
18
|
+
storage.applySoul(name);
|
|
19
|
+
spinner.succeed(`Switched to ${chalk.green(name)}\n` +
|
|
20
|
+
` ${chalk.dim('Backup saved. Use')} ${chalk.cyan('clawsouls restore')} ${chalk.dim('to revert.')}\n` +
|
|
21
|
+
` ${chalk.yellow('⚠')} Restart your OpenClaw session for changes to take effect.`);
|
|
22
|
+
}
|
|
23
|
+
catch (err) {
|
|
24
|
+
spinner.fail(err.message);
|
|
25
|
+
process.exit(1);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=use.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use.js","sourceRoot":"","sources":["../../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QAC1B,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export interface SoulMeta {
|
|
2
|
+
name: string;
|
|
3
|
+
displayName: string;
|
|
4
|
+
version: string;
|
|
5
|
+
description: string;
|
|
6
|
+
category: string;
|
|
7
|
+
tags: string[];
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* MVP: GitHub raw URL 기반 레지스트리 + 로컬 경로 지원
|
|
11
|
+
* Phase 4 이후: API 서버로 전환
|
|
12
|
+
*/
|
|
13
|
+
export declare class RegistryClient {
|
|
14
|
+
private cdn;
|
|
15
|
+
private isLocal;
|
|
16
|
+
constructor();
|
|
17
|
+
/** Soul의 clawsoul.json 가져오기 */
|
|
18
|
+
getSoulMeta(name: string): Promise<SoulMeta>;
|
|
19
|
+
/** Soul 파일 다운로드 */
|
|
20
|
+
downloadFile(name: string, filename: string): Promise<string>;
|
|
21
|
+
/** Soul 파일 목록 (clawsoul.json의 files 필드 기반) */
|
|
22
|
+
getSoulFiles(name: string): Promise<string[]>;
|
|
23
|
+
private readFile;
|
|
24
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from 'fs';
|
|
2
|
+
import { join } from 'path';
|
|
3
|
+
import { getConfig } from '../utils/config.js';
|
|
4
|
+
/**
|
|
5
|
+
* MVP: GitHub raw URL 기반 레지스트리 + 로컬 경로 지원
|
|
6
|
+
* Phase 4 이후: API 서버로 전환
|
|
7
|
+
*/
|
|
8
|
+
export class RegistryClient {
|
|
9
|
+
cdn;
|
|
10
|
+
isLocal;
|
|
11
|
+
constructor() {
|
|
12
|
+
const config = getConfig();
|
|
13
|
+
this.cdn = config.cdn;
|
|
14
|
+
this.isLocal = !this.cdn.startsWith('http');
|
|
15
|
+
}
|
|
16
|
+
/** Soul의 clawsoul.json 가져오기 */
|
|
17
|
+
async getSoulMeta(name) {
|
|
18
|
+
const content = await this.readFile(name, 'clawsoul.json');
|
|
19
|
+
return JSON.parse(content);
|
|
20
|
+
}
|
|
21
|
+
/** Soul 파일 다운로드 */
|
|
22
|
+
async downloadFile(name, filename) {
|
|
23
|
+
return this.readFile(name, filename);
|
|
24
|
+
}
|
|
25
|
+
/** Soul 파일 목록 (clawsoul.json의 files 필드 기반) */
|
|
26
|
+
async getSoulFiles(name) {
|
|
27
|
+
const meta = await this.getSoulMeta(name);
|
|
28
|
+
const files = ['clawsoul.json', 'README.md'];
|
|
29
|
+
const fileMap = meta.files || {};
|
|
30
|
+
for (const path of Object.values(fileMap)) {
|
|
31
|
+
if (typeof path === 'string')
|
|
32
|
+
files.push(path);
|
|
33
|
+
}
|
|
34
|
+
return [...new Set(files)];
|
|
35
|
+
}
|
|
36
|
+
async readFile(name, filename) {
|
|
37
|
+
if (this.isLocal) {
|
|
38
|
+
const filePath = join(this.cdn, name, filename);
|
|
39
|
+
if (!existsSync(filePath)) {
|
|
40
|
+
throw new Error(`Soul "${name}" not found in registry`);
|
|
41
|
+
}
|
|
42
|
+
return readFileSync(filePath, 'utf-8');
|
|
43
|
+
}
|
|
44
|
+
const url = `${this.cdn}/${name}/${filename}`;
|
|
45
|
+
const res = await fetch(url);
|
|
46
|
+
if (!res.ok) {
|
|
47
|
+
if (res.status === 404) {
|
|
48
|
+
throw new Error(`Soul "${name}" not found in registry`);
|
|
49
|
+
}
|
|
50
|
+
throw new Error(`Registry error: ${res.status} ${res.statusText}`);
|
|
51
|
+
}
|
|
52
|
+
return res.text();
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/registry/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAC9C,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,O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nD,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACjB,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC;YAChD,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;gBAC1B,MAAM,IAAI,KAAK,CAAC,SAAS,IAAI,yBAAyB,CAAC,CAAC;YAC1D,CAAC;YACD,OAAO,YAAY,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QACzC,CAAC;QAED,MAAM,GAAG,GAAG,GAAG,IAAI,CAAC,GAAG,IAAI,IAAI,IAAI,QAAQ,EAAE,CAAC;QAC9C,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,GAAG,CAAC,CAAC;QAC7B,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC;YACZ,IAAI,GAAG,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;gBACvB,MAAM,IAAI,KAAK,CAAC,SAAS,IAAI,yBAAyB,CAAC,CAAC;YAC1D,CAAC;YACD,MAAM,IAAI,KAAK,CAAC,mBAAmB,GAAG,CAAC,MAAM,IAAI,GAAG,CAAC,UAAU,EAAE,CAAC,CAAC;QACrE,CAAC;QACD,OAAO,GAAG,CAAC,IAAI,EAAE,CAAC;IACpB,CAAC;CACF"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { ClawSoul } from '../utils/validate.js';
|
|
2
|
+
export declare class LocalStorage {
|
|
3
|
+
private soulsDir;
|
|
4
|
+
private workspace;
|
|
5
|
+
private backupDir;
|
|
6
|
+
constructor();
|
|
7
|
+
/** Soul이 로컬에 설치되어 있는지 확인 */
|
|
8
|
+
isInstalled(name: string): boolean;
|
|
9
|
+
/** 설치된 Soul 목록 */
|
|
10
|
+
listInstalled(): ClawSoul[];
|
|
11
|
+
/** Soul 파일을 로컬에 저장 */
|
|
12
|
+
saveSoulFile(name: string, filename: string, content: string): void;
|
|
13
|
+
/** 현재 workspace 파일 백업 */
|
|
14
|
+
backupWorkspace(): string;
|
|
15
|
+
/** Soul을 workspace에 적용 */
|
|
16
|
+
applySoul(name: string): void;
|
|
17
|
+
/** 최신 백업에서 복원 */
|
|
18
|
+
restoreFromBackup(): string | null;
|
|
19
|
+
/** Soul 디렉토리 경로 */
|
|
20
|
+
getSoulPath(name: string): string;
|
|
21
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { existsSync, readdirSync, readFileSync, writeFileSync, cpSync } from 'fs';
|
|
2
|
+
import { join } from 'path';
|
|
3
|
+
import { getConfig, ensureDir } from '../utils/config.js';
|
|
4
|
+
export class LocalStorage {
|
|
5
|
+
soulsDir;
|
|
6
|
+
workspace;
|
|
7
|
+
backupDir;
|
|
8
|
+
constructor() {
|
|
9
|
+
const config = getConfig();
|
|
10
|
+
this.soulsDir = config.soulsDir;
|
|
11
|
+
this.workspace = config.workspace;
|
|
12
|
+
this.backupDir = join(this.soulsDir, '_backup');
|
|
13
|
+
}
|
|
14
|
+
/** Soul이 로컬에 설치되어 있는지 확인 */
|
|
15
|
+
isInstalled(name) {
|
|
16
|
+
return existsSync(join(this.soulsDir, name, 'clawsoul.json'));
|
|
17
|
+
}
|
|
18
|
+
/** 설치된 Soul 목록 */
|
|
19
|
+
listInstalled() {
|
|
20
|
+
ensureDir(this.soulsDir);
|
|
21
|
+
const entries = readdirSync(this.soulsDir, { withFileTypes: true });
|
|
22
|
+
const souls = [];
|
|
23
|
+
for (const entry of entries) {
|
|
24
|
+
if (!entry.isDirectory() || entry.name.startsWith('_'))
|
|
25
|
+
continue;
|
|
26
|
+
const metaPath = join(this.soulsDir, entry.name, 'clawsoul.json');
|
|
27
|
+
if (existsSync(metaPath)) {
|
|
28
|
+
try {
|
|
29
|
+
const raw = readFileSync(metaPath, 'utf-8');
|
|
30
|
+
souls.push(JSON.parse(raw));
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
// skip invalid
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return souls;
|
|
38
|
+
}
|
|
39
|
+
/** Soul 파일을 로컬에 저장 */
|
|
40
|
+
saveSoulFile(name, filename, content) {
|
|
41
|
+
const dir = join(this.soulsDir, name);
|
|
42
|
+
ensureDir(dir);
|
|
43
|
+
writeFileSync(join(dir, filename), content, 'utf-8');
|
|
44
|
+
}
|
|
45
|
+
/** 현재 workspace 파일 백업 */
|
|
46
|
+
backupWorkspace() {
|
|
47
|
+
const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
|
|
48
|
+
const backupPath = join(this.backupDir, timestamp);
|
|
49
|
+
ensureDir(backupPath);
|
|
50
|
+
const filesToBackup = ['SOUL.md', 'IDENTITY.md', 'AGENTS.md', 'HEARTBEAT.md'];
|
|
51
|
+
for (const file of filesToBackup) {
|
|
52
|
+
const src = join(this.workspace, file);
|
|
53
|
+
if (existsSync(src)) {
|
|
54
|
+
cpSync(src, join(backupPath, file));
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return backupPath;
|
|
58
|
+
}
|
|
59
|
+
/** Soul을 workspace에 적용 */
|
|
60
|
+
applySoul(name) {
|
|
61
|
+
const soulDir = join(this.soulsDir, name);
|
|
62
|
+
const filesToApply = [
|
|
63
|
+
{ src: 'SOUL.md', dst: 'SOUL.md' },
|
|
64
|
+
{ src: 'IDENTITY.md', dst: 'IDENTITY.md' },
|
|
65
|
+
{ src: 'AGENTS.md', dst: 'AGENTS.md' },
|
|
66
|
+
{ src: 'HEARTBEAT.md', dst: 'HEARTBEAT.md' },
|
|
67
|
+
];
|
|
68
|
+
for (const { src, dst } of filesToApply) {
|
|
69
|
+
const srcPath = join(soulDir, src);
|
|
70
|
+
if (existsSync(srcPath)) {
|
|
71
|
+
cpSync(srcPath, join(this.workspace, dst));
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
/** 최신 백업에서 복원 */
|
|
76
|
+
restoreFromBackup() {
|
|
77
|
+
if (!existsSync(this.backupDir))
|
|
78
|
+
return null;
|
|
79
|
+
const backups = readdirSync(this.backupDir, { withFileTypes: true })
|
|
80
|
+
.filter(e => e.isDirectory())
|
|
81
|
+
.map(e => e.name)
|
|
82
|
+
.sort()
|
|
83
|
+
.reverse();
|
|
84
|
+
if (backups.length === 0)
|
|
85
|
+
return null;
|
|
86
|
+
const latest = join(this.backupDir, backups[0]);
|
|
87
|
+
const files = readdirSync(latest);
|
|
88
|
+
for (const file of files) {
|
|
89
|
+
cpSync(join(latest, file), join(this.workspace, file));
|
|
90
|
+
}
|
|
91
|
+
return backups[0];
|
|
92
|
+
}
|
|
93
|
+
/** Soul 디렉토리 경로 */
|
|
94
|
+
getSoulPath(name) {
|
|
95
|
+
return join(this.soulsDir, name);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=local.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"local.js","sourceRoot":"","sources":["../../src/storage/local.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,EAAa,MAAM,IAAI,CAAC;AAC7F,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAG1D,MAAM,OAAO,YAAY;IACf,QAAQ,CAAS;IACjB,SAAS,CAAS;IAClB,SAAS,CAAS;IAE1B;QACE,MAAM,MAAM,GAAG,SAAS,EAAE,CAAC;QAC3B,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;QAChC,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,SAAS,CAAC;QAClC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;IAClD,CAAC;IAED,4BAA4B;IAC5B,WAAW,CAAC,IAAY;QACtB,OAAO,UA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CAAC,SAAS,EAAE,GAAG,CAAC,CAAC,CAAC;YAC7C,CAAC;QACH,CAAC;IACH,CAAC;IAED,iBAAiB;IACjB,iBAAiB;QACf,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC;YAAE,OAAO,IAAI,CAAC;QAE7C,MAAM,OAAO,GAAG,WAAW,CAAC,IAAI,CAAC,SAAS,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC;aACjE,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;aAC5B,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;aAChB,IAAI,EAAE;aACN,OAAO,EAAE,CAAC;QAEb,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,IAAI,CAAC;QAEtC,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;QAChD,MAAM,KAAK,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC;QAClC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC;QACzD,CAAC;QACD,OAAO,OAAO,CAAC,CAAC,CAAC,CAAC;IACpB,CAAC;IAED,mBAAmB;IACnB,WAAW,CAAC,IAAY;QACtB,OAAO,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;IACnC,CAAC;CACF"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export interface InstalledSoul {
|
|
2
|
+
name: string;
|
|
3
|
+
displayName: string;
|
|
4
|
+
version: string;
|
|
5
|
+
description: string;
|
|
6
|
+
category: string;
|
|
7
|
+
path: string;
|
|
8
|
+
}
|
|
9
|
+
export declare class StorageManager {
|
|
10
|
+
private soulsDir;
|
|
11
|
+
private workspace;
|
|
12
|
+
private backupDir;
|
|
13
|
+
constructor();
|
|
14
|
+
/** List all installed souls */
|
|
15
|
+
listInstalled(): InstalledSoul[];
|
|
16
|
+
/** Check if a soul is installed */
|
|
17
|
+
isInstalled(name: string): boolean;
|
|
18
|
+
/** Get soul install directory */
|
|
19
|
+
getSoulDir(name: string): string;
|
|
20
|
+
/** Save downloaded soul files to souls dir */
|
|
21
|
+
saveSoul(name: string, files: Map<string, string>): void;
|
|
22
|
+
/** Backup current workspace files before applying a new soul */
|
|
23
|
+
backupWorkspace(): string;
|
|
24
|
+
/** Apply a soul to the workspace (copy soul files) */
|
|
25
|
+
applySoul(name: string): void;
|
|
26
|
+
/** Restore workspace from latest backup */
|
|
27
|
+
restore(): string | null;
|
|
28
|
+
/** List available backups */
|
|
29
|
+
listBackups(): string[];
|
|
30
|
+
private mapFileKey;
|
|
31
|
+
}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { existsSync, readdirSync, readFileSync, writeFileSync, copyFileSync } from 'fs';
|
|
2
|
+
import { join } from 'path';
|
|
3
|
+
import { getConfig, ensureDir } from '../utils/config.js';
|
|
4
|
+
/** Files that get copied to workspace on `use` */
|
|
5
|
+
const SOUL_FILES = ['SOUL.md', 'IDENTITY.md', 'AGENTS.md', 'HEARTBEAT.md'];
|
|
6
|
+
/** Files that are NEVER overwritten (personal data) */
|
|
7
|
+
const PROTECTED_FILES = ['USER.md', 'MEMORY.md', 'TOOLS.md'];
|
|
8
|
+
export class StorageManager {
|
|
9
|
+
soulsDir;
|
|
10
|
+
workspace;
|
|
11
|
+
backupDir;
|
|
12
|
+
constructor() {
|
|
13
|
+
const config = getConfig();
|
|
14
|
+
this.soulsDir = config.soulsDir;
|
|
15
|
+
this.workspace = config.workspace;
|
|
16
|
+
this.backupDir = join(this.soulsDir, '_backup');
|
|
17
|
+
}
|
|
18
|
+
/** List all installed souls */
|
|
19
|
+
listInstalled() {
|
|
20
|
+
ensureDir(this.soulsDir);
|
|
21
|
+
const entries = readdirSync(this.soulsDir, { withFileTypes: true });
|
|
22
|
+
const souls = [];
|
|
23
|
+
for (const entry of entries) {
|
|
24
|
+
if (!entry.isDirectory() || entry.name.startsWith('_'))
|
|
25
|
+
continue;
|
|
26
|
+
const manifestPath = join(this.soulsDir, entry.name, 'clawsoul.json');
|
|
27
|
+
if (!existsSync(manifestPath))
|
|
28
|
+
continue;
|
|
29
|
+
try {
|
|
30
|
+
const data = JSON.parse(readFileSync(manifestPath, 'utf-8'));
|
|
31
|
+
souls.push({
|
|
32
|
+
name: data.name || entry.name,
|
|
33
|
+
displayName: data.displayName || data.name || entry.name,
|
|
34
|
+
version: data.version || '0.0.0',
|
|
35
|
+
description: data.description || '',
|
|
36
|
+
category: data.category || 'general',
|
|
37
|
+
path: join(this.soulsDir, entry.name),
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
// Skip invalid manifests
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return souls;
|
|
45
|
+
}
|
|
46
|
+
/** Check if a soul is installed */
|
|
47
|
+
isInstalled(name) {
|
|
48
|
+
return existsSync(join(this.soulsDir, name, 'clawsoul.json'));
|
|
49
|
+
}
|
|
50
|
+
/** Get soul install directory */
|
|
51
|
+
getSoulDir(name) {
|
|
52
|
+
return join(this.soulsDir, name);
|
|
53
|
+
}
|
|
54
|
+
/** Save downloaded soul files to souls dir */
|
|
55
|
+
saveSoul(name, files) {
|
|
56
|
+
const dir = join(this.soulsDir, name);
|
|
57
|
+
ensureDir(dir);
|
|
58
|
+
for (const [filename, content] of files) {
|
|
59
|
+
const filePath = join(dir, filename);
|
|
60
|
+
const parentDir = join(filePath, '..');
|
|
61
|
+
ensureDir(parentDir);
|
|
62
|
+
writeFileSync(filePath, content, 'utf-8');
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
/** Backup current workspace files before applying a new soul */
|
|
66
|
+
backupWorkspace() {
|
|
67
|
+
const timestamp = new Date().toISOString().replace(/[:.]/g, '-').slice(0, 19);
|
|
68
|
+
const backupPath = join(this.backupDir, timestamp);
|
|
69
|
+
ensureDir(backupPath);
|
|
70
|
+
for (const file of SOUL_FILES) {
|
|
71
|
+
const src = join(this.workspace, file);
|
|
72
|
+
if (existsSync(src)) {
|
|
73
|
+
copyFileSync(src, join(backupPath, file));
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return backupPath;
|
|
77
|
+
}
|
|
78
|
+
/** Apply a soul to the workspace (copy soul files) */
|
|
79
|
+
applySoul(name) {
|
|
80
|
+
const soulDir = join(this.soulsDir, name);
|
|
81
|
+
if (!existsSync(soulDir)) {
|
|
82
|
+
throw new Error(`Soul "${name}" is not installed`);
|
|
83
|
+
}
|
|
84
|
+
const manifestPath = join(soulDir, 'clawsoul.json');
|
|
85
|
+
const manifest = JSON.parse(readFileSync(manifestPath, 'utf-8'));
|
|
86
|
+
const fileMap = manifest.files || {};
|
|
87
|
+
// Copy each mapped file to workspace
|
|
88
|
+
for (const [key, filename] of Object.entries(fileMap)) {
|
|
89
|
+
if (typeof filename !== 'string')
|
|
90
|
+
continue;
|
|
91
|
+
const src = join(soulDir, filename);
|
|
92
|
+
if (!existsSync(src))
|
|
93
|
+
continue;
|
|
94
|
+
// Map soul file keys to workspace filenames
|
|
95
|
+
const targetName = this.mapFileKey(key, filename);
|
|
96
|
+
if (!targetName)
|
|
97
|
+
continue;
|
|
98
|
+
if (PROTECTED_FILES.includes(targetName))
|
|
99
|
+
continue;
|
|
100
|
+
copyFileSync(src, join(this.workspace, targetName));
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
/** Restore workspace from latest backup */
|
|
104
|
+
restore() {
|
|
105
|
+
if (!existsSync(this.backupDir))
|
|
106
|
+
return null;
|
|
107
|
+
const backups = readdirSync(this.backupDir, { withFileTypes: true })
|
|
108
|
+
.filter(e => e.isDirectory() && !e.name.startsWith('.'))
|
|
109
|
+
.map(e => e.name)
|
|
110
|
+
.sort()
|
|
111
|
+
.reverse();
|
|
112
|
+
if (backups.length === 0)
|
|
113
|
+
return null;
|
|
114
|
+
const latest = join(this.backupDir, backups[0]);
|
|
115
|
+
const files = readdirSync(latest);
|
|
116
|
+
for (const file of files) {
|
|
117
|
+
copyFileSync(join(latest, file), join(this.workspace, file));
|
|
118
|
+
}
|
|
119
|
+
return backups[0];
|
|
120
|
+
}
|
|
121
|
+
/** List available backups */
|
|
122
|
+
listBackups() {
|
|
123
|
+
if (!existsSync(this.backupDir))
|
|
124
|
+
return [];
|
|
125
|
+
return readdirSync(this.backupDir, { withFileTypes: true })
|
|
126
|
+
.filter(e => e.isDirectory())
|
|
127
|
+
.map(e => e.name)
|
|
128
|
+
.sort()
|
|
129
|
+
.reverse();
|
|
130
|
+
}
|
|
131
|
+
mapFileKey(key, filename) {
|
|
132
|
+
const map = {
|
|
133
|
+
soul: 'SOUL.md',
|
|
134
|
+
identity: 'IDENTITY.md',
|
|
135
|
+
agents: 'AGENTS.md',
|
|
136
|
+
heartbeat: 'HEARTBEAT.md',
|
|
137
|
+
};
|
|
138
|
+
return map[key] || null;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
//# sourceMappingURL=manager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manager.js","sourceRoot":"","sources":["../../src/storage/manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,aAAa,EAAE,YAAY,EAAa,MAAM,IAAI,CAAC;AACnG,OAAO,EAAE,IAAI,EAAY,MAAM,MAAM,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAG1D,kDAAkD;AAClD,MAAM,UAAU,GAAG,CAAC,SAAS,EAAE,aAAa,EAAE,WAAW,EAAE,cAAc,CAAC,CAAC;AAE3E,uDAAuD;AACvD,MAAM,eAAe,GAAG,CAAC,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,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC;YAAE,OAAO,EAAE,CAAC;QAC3C,OAAO,WAAW,CAAC,IAAI,CAAC,SAAS,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC;aACxD,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;aAC5B,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;aAChB,IAAI,EAAE;aACN,OAAO,EAAE,CAAC;IACf,CAAC;IAEO,UAAU,CAAC,GAAW,EAAE,QAAgB;QAC9C,MAAM,GAAG,GAA2B;YAClC,IAAI,EAAE,SAAS;YACf,QAAQ,EAAE,aAAa;YACvB,MAAM,EAAE,WAAW;YACnB,SAAS,EAAE,cAAc;SAC1B,CAAC;QACF,OAAO,GAAG,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC;IAC1B,CAAC;CACF"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface ClawSoulsConfig {
|
|
2
|
+
registry: string;
|
|
3
|
+
cdn: string;
|
|
4
|
+
workspace: string;
|
|
5
|
+
soulsDir: string;
|
|
6
|
+
auth?: {
|
|
7
|
+
token?: string;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
export declare function getConfig(): ClawSoulsConfig;
|
|
11
|
+
export declare function saveConfig(config: Partial<ClawSoulsConfig>): void;
|
|
12
|
+
export declare function ensureDir(dir: string): void;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { existsSync, readFileSync, writeFileSync, mkdirSync } from 'fs';
|
|
2
|
+
import { join } from 'path';
|
|
3
|
+
import { homedir } from 'os';
|
|
4
|
+
const CONFIG_DIR = join(homedir(), '.clawsouls');
|
|
5
|
+
const CONFIG_FILE = join(CONFIG_DIR, 'config.json');
|
|
6
|
+
const DEFAULT_CONFIG = {
|
|
7
|
+
registry: 'https://api.clawsouls.ai',
|
|
8
|
+
cdn: process.env.CLAWSOULS_CDN || 'https://raw.githubusercontent.com/clawsouls/souls/main',
|
|
9
|
+
workspace: join(homedir(), '.openclaw', 'workspace'),
|
|
10
|
+
soulsDir: join(homedir(), '.openclaw', 'souls'),
|
|
11
|
+
};
|
|
12
|
+
export function getConfig() {
|
|
13
|
+
if (existsSync(CONFIG_FILE)) {
|
|
14
|
+
try {
|
|
15
|
+
const raw = readFileSync(CONFIG_FILE, 'utf-8');
|
|
16
|
+
return { ...DEFAULT_CONFIG, ...JSON.parse(raw) };
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
return DEFAULT_CONFIG;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return DEFAULT_CONFIG;
|
|
23
|
+
}
|
|
24
|
+
export function saveConfig(config) {
|
|
25
|
+
if (!existsSync(CONFIG_DIR)) {
|
|
26
|
+
mkdirSync(CONFIG_DIR, { recursive: true });
|
|
27
|
+
}
|
|
28
|
+
const current = getConfig();
|
|
29
|
+
const merged = { ...current, ...config };
|
|
30
|
+
writeFileSync(CONFIG_FILE, JSON.stringify(merged, null, 2));
|
|
31
|
+
}
|
|
32
|
+
export function ensureDir(dir) {
|
|
33
|
+
if (!existsSync(dir)) {
|
|
34
|
+
mkdirSync(dir, { recursive: true });
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/utils/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AACxE,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC;AAY7B,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,EAAE,EAAE,YAAY,CAAC,CAAC;AACjD,MAAM,WAAW,GAAG,IAAI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,CAAC;IACtC,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const ClawSoulSchema: z.ZodObject<{
|
|
3
|
+
name: z.ZodString;
|
|
4
|
+
displayName: z.ZodString;
|
|
5
|
+
version: z.ZodString;
|
|
6
|
+
description: z.ZodString;
|
|
7
|
+
author: z.ZodObject<{
|
|
8
|
+
name: z.ZodString;
|
|
9
|
+
github: z.ZodOptional<z.ZodString>;
|
|
10
|
+
}, z.core.$strip>;
|
|
11
|
+
license: z.ZodString;
|
|
12
|
+
tags: z.ZodArray<z.ZodString>;
|
|
13
|
+
category: z.ZodString;
|
|
14
|
+
compatibility: z.ZodOptional<z.ZodObject<{
|
|
15
|
+
openclaw: z.ZodOptional<z.ZodString>;
|
|
16
|
+
models: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
17
|
+
}, z.core.$strip>>;
|
|
18
|
+
files: z.ZodObject<{
|
|
19
|
+
soul: z.ZodString;
|
|
20
|
+
identity: z.ZodOptional<z.ZodString>;
|
|
21
|
+
agents: z.ZodOptional<z.ZodString>;
|
|
22
|
+
heartbeat: z.ZodOptional<z.ZodString>;
|
|
23
|
+
userTemplate: z.ZodOptional<z.ZodString>;
|
|
24
|
+
avatar: z.ZodOptional<z.ZodString>;
|
|
25
|
+
}, z.core.$strip>;
|
|
26
|
+
skills: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
27
|
+
repository: z.ZodOptional<z.ZodString>;
|
|
28
|
+
}, z.core.$strip>;
|
|
29
|
+
export type ClawSoul = z.infer<typeof ClawSoulSchema>;
|
|
30
|
+
export declare function validateClawSoul(data: unknown): ClawSoul;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export const ClawSoulSchema = z.object({
|
|
3
|
+
name: z.string().regex(/^[a-z0-9-]+$/, 'Must be kebab-case'),
|
|
4
|
+
displayName: z.string().min(1),
|
|
5
|
+
version: z.string().regex(/^\d+\.\d+\.\d+$/, 'Must be semver'),
|
|
6
|
+
description: z.string().max(160),
|
|
7
|
+
author: z.object({
|
|
8
|
+
name: z.string(),
|
|
9
|
+
github: z.string().optional(),
|
|
10
|
+
}),
|
|
11
|
+
license: z.string(),
|
|
12
|
+
tags: z.array(z.string()).max(10),
|
|
13
|
+
category: z.string(),
|
|
14
|
+
compatibility: z.object({
|
|
15
|
+
openclaw: z.string().optional(),
|
|
16
|
+
models: z.array(z.string()).optional(),
|
|
17
|
+
}).optional(),
|
|
18
|
+
files: z.object({
|
|
19
|
+
soul: z.string(),
|
|
20
|
+
identity: z.string().optional(),
|
|
21
|
+
agents: z.string().optional(),
|
|
22
|
+
heartbeat: z.string().optional(),
|
|
23
|
+
userTemplate: z.string().optional(),
|
|
24
|
+
avatar: z.string().optional(),
|
|
25
|
+
}),
|
|
26
|
+
skills: z.array(z.string()).optional(),
|
|
27
|
+
repository: z.string().url().optional(),
|
|
28
|
+
});
|
|
29
|
+
export function validateClawSoul(data) {
|
|
30
|
+
return ClawSoulSchema.parse(data);
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=validate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate.js","sourceRoot":"","sources":["../../src/utils/validate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAC,MAAM,CAAC;IACrC,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,cAAc,EAAE,oBAAoB,CAAC;IAC5D,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC9B,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,iBAAiB,EAAE,gBAAgB,CAAC;IAC9D,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,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AO,cAAc,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;AACpC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,10 +1,48 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clawsouls",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "AI agent persona sharing platform
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "CLI for ClawSouls — AI agent persona sharing platform",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"clawsouls": "dist/bin/clawsouls.js"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"build": "tsc",
|
|
11
|
+
"dev": "tsc --watch",
|
|
12
|
+
"start": "node dist/bin/clawsouls.js",
|
|
13
|
+
"lint": "tsc --noEmit"
|
|
14
|
+
},
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "git+https://github.com/clawsouls/clawsouls-cli.git"
|
|
18
|
+
},
|
|
19
|
+
"keywords": [
|
|
20
|
+
"ai",
|
|
21
|
+
"persona",
|
|
22
|
+
"agent",
|
|
23
|
+
"openclaw",
|
|
24
|
+
"soul",
|
|
25
|
+
"cli"
|
|
26
|
+
],
|
|
8
27
|
"author": "TomLeeLive",
|
|
9
|
-
"
|
|
28
|
+
"license": "Apache-2.0",
|
|
29
|
+
"type": "module",
|
|
30
|
+
"engines": {
|
|
31
|
+
"node": ">=22.0.0"
|
|
32
|
+
},
|
|
33
|
+
"files": [
|
|
34
|
+
"dist/**/*"
|
|
35
|
+
],
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"chalk": "^5.6.2",
|
|
38
|
+
"commander": "^14.0.3",
|
|
39
|
+
"ora": "^9.3.0",
|
|
40
|
+
"tar": "^7.5.7",
|
|
41
|
+
"zod": "^4.3.6"
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"@types/node": "^25.2.3",
|
|
45
|
+
"@types/tar": "^6.1.13",
|
|
46
|
+
"typescript": "^5.9.3"
|
|
47
|
+
}
|
|
10
48
|
}
|
package/index.js
DELETED