botrun-msync 0.1.0 → 0.2.0
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/README.md +23 -23
- package/package.json +1 -1
- package/src/bin.mjs +4 -4
- package/src/commands/memory/sync.mjs +1 -1
- package/src/config.mjs +3 -3
package/README.md
CHANGED
|
@@ -39,7 +39,7 @@ A **scope** is a logical name that maps to a git repo. Each agent can have multi
|
|
|
39
39
|
```bash
|
|
40
40
|
npx botrun-msync config add-scope my-notes \
|
|
41
41
|
--repo github.com/org/my-memory \
|
|
42
|
-
--token-env
|
|
42
|
+
--token-env BMS_TOKEN_NOTES \
|
|
43
43
|
--description "Personal research notes" \
|
|
44
44
|
--access readwrite
|
|
45
45
|
```
|
|
@@ -53,27 +53,27 @@ Different scopes can point to different repos. Permissions are controlled by Git
|
|
|
53
53
|
# Read-write token for personal repo
|
|
54
54
|
npx botrun-msync config add-scope director \
|
|
55
55
|
--repo github.com/org/director-memory \
|
|
56
|
-
--token-env
|
|
56
|
+
--token-env BMS_TOKEN_DIRECTOR \
|
|
57
57
|
--description "Director personal research" \
|
|
58
58
|
--access readwrite
|
|
59
59
|
|
|
60
60
|
# Read-only token for team repos
|
|
61
61
|
npx botrun-msync config add-scope team1 \
|
|
62
62
|
--repo github.com/org/team1-memory \
|
|
63
|
-
--token-env
|
|
63
|
+
--token-env BMS_TOKEN_TEAMS \
|
|
64
64
|
--description "Team 1 memory" \
|
|
65
65
|
--access readonly
|
|
66
66
|
|
|
67
67
|
npx botrun-msync config add-scope team2 \
|
|
68
68
|
--repo github.com/org/team2-memory \
|
|
69
|
-
--token-env
|
|
69
|
+
--token-env BMS_TOKEN_TEAMS \
|
|
70
70
|
--description "Team 2 memory" \
|
|
71
71
|
--access readonly
|
|
72
72
|
```
|
|
73
73
|
|
|
74
74
|
Create separate GitHub Fine-grained PATs with different permissions:
|
|
75
|
-
- `
|
|
76
|
-
- `
|
|
75
|
+
- `BMS_TOKEN_DIRECTOR` → Contents: Read and write (only `director-memory` repo)
|
|
76
|
+
- `BMS_TOKEN_TEAMS` → Contents: Read-only (only `team1-memory` + `team2-memory` repos)
|
|
77
77
|
|
|
78
78
|
This way, even if a user modifies the config, they can't write to repos their token doesn't allow.
|
|
79
79
|
|
|
@@ -84,7 +84,7 @@ This way, even if a user modifies the config, they can't write to repos their to
|
|
|
84
84
|
All `bms` data lives under a single base directory:
|
|
85
85
|
|
|
86
86
|
```
|
|
87
|
-
~/.botrun/
|
|
87
|
+
~/.botrun/bms/ ← default base path
|
|
88
88
|
├── config.json ← scope definitions
|
|
89
89
|
└── data/
|
|
90
90
|
├── my-notes/ ← git clone of my-notes scope
|
|
@@ -95,31 +95,31 @@ All `bms` data lives under a single base directory:
|
|
|
95
95
|
Override with CLI option or environment variable:
|
|
96
96
|
|
|
97
97
|
```bash
|
|
98
|
-
npx botrun-msync --
|
|
99
|
-
|
|
98
|
+
npx botrun-msync --bms-path /tmp/test-bms memory init # CLI option (highest priority)
|
|
99
|
+
BMS_PATH=/custom/path npx botrun-msync memory init # environment variable
|
|
100
100
|
```
|
|
101
101
|
|
|
102
|
-
Priority: `--
|
|
102
|
+
Priority: `--bms-path` > `BMS_PATH` > `~/.botrun/bms/`
|
|
103
103
|
|
|
104
104
|
### Config File
|
|
105
105
|
|
|
106
|
-
Located at `<
|
|
106
|
+
Located at `<BMS_PATH>/config.json` (default: `~/.botrun/bms/config.json`).
|
|
107
107
|
|
|
108
|
-
Override config path independently with: `
|
|
108
|
+
Override config path independently with: `BMS_CONFIG=/path/to/config.json`
|
|
109
109
|
|
|
110
110
|
```json
|
|
111
111
|
{
|
|
112
112
|
"scopes": {
|
|
113
113
|
"my-notes": {
|
|
114
114
|
"repo": "github.com/org/member1-memory",
|
|
115
|
-
"token_env": "
|
|
115
|
+
"token_env": "BMS_TOKEN_NOTES",
|
|
116
116
|
"description": "Personal research notes",
|
|
117
117
|
"access": "readwrite"
|
|
118
118
|
},
|
|
119
119
|
"team1": {
|
|
120
120
|
"repo": "github.com/org/team1-memory",
|
|
121
121
|
"branch": "dev",
|
|
122
|
-
"token_env": "
|
|
122
|
+
"token_env": "BMS_TOKEN_TEAMS",
|
|
123
123
|
"description": "Team 1 memory",
|
|
124
124
|
"access": "readonly"
|
|
125
125
|
}
|
|
@@ -148,8 +148,8 @@ npx botrun-msync config show
|
|
|
148
148
|
|
|
149
149
|
| Variable | Purpose |
|
|
150
150
|
|----------|---------|
|
|
151
|
-
| `
|
|
152
|
-
| `
|
|
151
|
+
| `BMS_PATH` | Base directory for all bms data (default: `~/.botrun/bms`) |
|
|
152
|
+
| `BMS_CONFIG` | Config file path (overrides `<BMS_PATH>/config.json`) |
|
|
153
153
|
|
|
154
154
|
Each scope's token is configured via `--token-env`, which points to an environment variable name. There are no global token variables — every scope must declare its own.
|
|
155
155
|
|
|
@@ -157,13 +157,13 @@ Each scope's token is configured via `--token-env`, which points to an environme
|
|
|
157
157
|
|
|
158
158
|
### `npx botrun-msync memory init`
|
|
159
159
|
|
|
160
|
-
Clones all configured scope repos to `<
|
|
160
|
+
Clones all configured scope repos to `<BMS_PATH>/data/<scope-name>/`. If already cloned, pulls latest.
|
|
161
161
|
|
|
162
162
|
```json
|
|
163
163
|
{
|
|
164
164
|
"scopes": {
|
|
165
|
-
"my-notes": { "local": "/root/.botrun/
|
|
166
|
-
"team1": { "local": "/root/.botrun/
|
|
165
|
+
"my-notes": { "local": "/root/.botrun/bms/data/my-notes" },
|
|
166
|
+
"team1": { "local": "/root/.botrun/bms/data/team1" }
|
|
167
167
|
}
|
|
168
168
|
}
|
|
169
169
|
```
|
|
@@ -179,13 +179,13 @@ Lists all scopes with their repo, description, access, and local filesystem path
|
|
|
179
179
|
"repo": "github.com/org/member1-memory",
|
|
180
180
|
"description": "Personal research notes",
|
|
181
181
|
"access": "readwrite",
|
|
182
|
-
"local": "/root/.botrun/
|
|
182
|
+
"local": "/root/.botrun/bms/data/my-notes"
|
|
183
183
|
},
|
|
184
184
|
"team1": {
|
|
185
185
|
"repo": "github.com/org/team1-memory",
|
|
186
186
|
"description": "Team 1 memory",
|
|
187
187
|
"access": "readonly",
|
|
188
|
-
"local": "/root/.botrun/
|
|
188
|
+
"local": "/root/.botrun/bms/data/team1"
|
|
189
189
|
}
|
|
190
190
|
}
|
|
191
191
|
}
|
|
@@ -216,7 +216,7 @@ npx botrun-msync memory --help
|
|
|
216
216
|
|
|
217
217
|
```
|
|
218
218
|
VM starts
|
|
219
|
-
→ npx botrun-msync memory init # clone repos to <
|
|
219
|
+
→ npx botrun-msync memory init # clone repos to <BMS_PATH>/data/
|
|
220
220
|
→ agent reads/writes files # using native tools (Read, Write, grep)
|
|
221
221
|
→ npx botrun-msync memory sync # push changes
|
|
222
222
|
VM destroyed
|
|
@@ -226,7 +226,7 @@ VM destroyed
|
|
|
226
226
|
|
|
227
227
|
```bash
|
|
228
228
|
npm install
|
|
229
|
-
npm test
|
|
229
|
+
npm test
|
|
230
230
|
```
|
|
231
231
|
|
|
232
232
|
## License
|
package/package.json
CHANGED
package/src/bin.mjs
CHANGED
|
@@ -27,13 +27,13 @@ const program = new Command();
|
|
|
27
27
|
program
|
|
28
28
|
.name('bms')
|
|
29
29
|
.description('Git-backed memory sync for agents')
|
|
30
|
-
.version('0.
|
|
30
|
+
.version('0.2.0')
|
|
31
31
|
.helpCommand(false)
|
|
32
|
-
.option('--
|
|
32
|
+
.option('--bms-path <path>', 'Base directory for all bms data')
|
|
33
33
|
.configureHelp({ formatHelp: (cmd) => JSON.stringify(jsonHelp(cmd), null, 2) })
|
|
34
34
|
.hook('preAction', (thisCommand) => {
|
|
35
|
-
const
|
|
36
|
-
if (
|
|
35
|
+
const bmsPath = thisCommand.opts().bmsPath;
|
|
36
|
+
if (bmsPath) process.env.BMS_PATH = bmsPath;
|
|
37
37
|
});
|
|
38
38
|
|
|
39
39
|
// --- config ---
|
|
@@ -37,7 +37,7 @@ export async function syncMemory(options = {}) {
|
|
|
37
37
|
const status = await gitExec(['-C', cloneDir, 'status', '--porcelain']);
|
|
38
38
|
if (status) {
|
|
39
39
|
await gitExec(['-C', cloneDir, 'add', '-A']);
|
|
40
|
-
await gitExec(['-C', cloneDir, 'commit', '-m', `
|
|
40
|
+
await gitExec(['-C', cloneDir, 'commit', '-m', `bms: update ${name} memories`]);
|
|
41
41
|
await gitExec(['-C', cloneDir, 'push']);
|
|
42
42
|
didPush = true;
|
|
43
43
|
}
|
package/src/config.mjs
CHANGED
|
@@ -2,14 +2,14 @@ import { readFile, writeFile, mkdir } from 'node:fs/promises';
|
|
|
2
2
|
import { homedir } from 'node:os';
|
|
3
3
|
import { join, dirname } from 'node:path';
|
|
4
4
|
|
|
5
|
-
const DEFAULT_BASE_PATH = join(homedir(), '.botrun', '
|
|
5
|
+
const DEFAULT_BASE_PATH = join(homedir(), '.botrun', 'bms');
|
|
6
6
|
|
|
7
7
|
export function getBasePath() {
|
|
8
|
-
return process.env.
|
|
8
|
+
return process.env.BMS_PATH || DEFAULT_BASE_PATH;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
export function getConfigPath() {
|
|
12
|
-
return process.env.
|
|
12
|
+
return process.env.BMS_CONFIG || join(getBasePath(), 'config.json');
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
export async function loadConfig(configPath = getConfigPath()) {
|