create-egregore 0.3.10 → 0.3.11
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/bin/cli.js +35 -9
- package/lib/setup.js +24 -1
- package/package.json +1 -1
package/bin/cli.js
CHANGED
|
@@ -117,13 +117,22 @@ async function interactiveFlow(api) {
|
|
|
117
117
|
// 3. Build choices
|
|
118
118
|
const choices = [];
|
|
119
119
|
|
|
120
|
-
// Orgs with egregore → join
|
|
120
|
+
// Orgs with egregore → show each instance to join + option to set up another
|
|
121
121
|
for (const org of orgsData.orgs) {
|
|
122
122
|
if (org.has_egregore) {
|
|
123
|
+
for (const inst of org.instances || []) {
|
|
124
|
+
choices.push({
|
|
125
|
+
label: `${org.name || org.login} — ${inst.org_name || inst.repo_name}`,
|
|
126
|
+
description: "Join existing",
|
|
127
|
+
action: "join",
|
|
128
|
+
login: org.login,
|
|
129
|
+
repo_name: inst.repo_name,
|
|
130
|
+
});
|
|
131
|
+
}
|
|
123
132
|
choices.push({
|
|
124
|
-
label: org.name || org.login
|
|
125
|
-
description: "
|
|
126
|
-
action: "
|
|
133
|
+
label: `${org.name || org.login} — new instance`,
|
|
134
|
+
description: "Set up another",
|
|
135
|
+
action: "setup",
|
|
127
136
|
login: org.login,
|
|
128
137
|
});
|
|
129
138
|
}
|
|
@@ -141,13 +150,23 @@ async function interactiveFlow(api) {
|
|
|
141
150
|
}
|
|
142
151
|
}
|
|
143
152
|
|
|
144
|
-
// Personal account
|
|
153
|
+
// Personal account — show join for each existing instance + setup for new
|
|
145
154
|
if (orgsData.personal.has_egregore) {
|
|
155
|
+
for (const inst of orgsData.personal.instances || []) {
|
|
156
|
+
choices.push({
|
|
157
|
+
label: `${orgsData.user.login} (personal) — ${inst.org_name || inst.repo_name}`,
|
|
158
|
+
description: "Join existing",
|
|
159
|
+
action: "join",
|
|
160
|
+
login: orgsData.user.login,
|
|
161
|
+
repo_name: inst.repo_name,
|
|
162
|
+
});
|
|
163
|
+
}
|
|
146
164
|
choices.push({
|
|
147
|
-
label: `${orgsData.user.login} (personal)`,
|
|
148
|
-
description: "
|
|
149
|
-
action: "
|
|
165
|
+
label: `${orgsData.user.login} (personal) — new instance`,
|
|
166
|
+
description: "Set up another",
|
|
167
|
+
action: "setup",
|
|
150
168
|
login: orgsData.user.login,
|
|
169
|
+
is_personal: true,
|
|
151
170
|
});
|
|
152
171
|
} else {
|
|
153
172
|
choices.push({
|
|
@@ -180,6 +199,10 @@ async function setupFlow(api, githubToken, choice) {
|
|
|
180
199
|
const orgName = await ui.prompt(`Organization display name [${choice.login}]:`);
|
|
181
200
|
const name = orgName || choice.login;
|
|
182
201
|
|
|
202
|
+
// Instance name — determines repo names (egregore-{instance}, {instance}-memory)
|
|
203
|
+
const instanceInput = await ui.prompt(`Instance name (e.g. "ops", "research") [leave blank for default]:`);
|
|
204
|
+
const instanceName = instanceInput || undefined;
|
|
205
|
+
|
|
183
206
|
// Repo picker — show org repos for selection
|
|
184
207
|
let selectedRepos = [];
|
|
185
208
|
try {
|
|
@@ -201,6 +224,7 @@ async function setupFlow(api, githubToken, choice) {
|
|
|
201
224
|
org_name: name,
|
|
202
225
|
is_personal: choice.is_personal || false,
|
|
203
226
|
repos: selectedRepos,
|
|
227
|
+
instance_name: instanceName,
|
|
204
228
|
});
|
|
205
229
|
s.stop("Setup complete on GitHub");
|
|
206
230
|
|
|
@@ -220,10 +244,12 @@ async function setupFlow(api, githubToken, choice) {
|
|
|
220
244
|
}
|
|
221
245
|
|
|
222
246
|
async function joinFlow(api, githubToken, choice) {
|
|
223
|
-
const
|
|
247
|
+
const displayName = choice.repo_name ? `${choice.login} (${choice.repo_name})` : choice.login;
|
|
248
|
+
const s = ui.spinner(`Joining ${ui.bold(displayName)}...`);
|
|
224
249
|
try {
|
|
225
250
|
const result = await api.joinOrg(githubToken, {
|
|
226
251
|
github_org: choice.login,
|
|
252
|
+
repo_name: choice.repo_name,
|
|
227
253
|
});
|
|
228
254
|
s.stop("Joined");
|
|
229
255
|
|
package/lib/setup.js
CHANGED
|
@@ -20,7 +20,7 @@ function run(cmd, opts = {}) {
|
|
|
20
20
|
* @param {string} targetDir - where to install (default: cwd)
|
|
21
21
|
*/
|
|
22
22
|
async function install(data, ui, targetDir) {
|
|
23
|
-
const { fork_url, memory_url, github_token, org_name, github_org, slug, api_key, repos = [], telegram_group_link } = data;
|
|
23
|
+
const { fork_url, memory_url, github_token, org_name, github_org, slug, api_key, repos = [], telegram_group_link, github_username, github_name } = data;
|
|
24
24
|
const base = targetDir || process.cwd();
|
|
25
25
|
|
|
26
26
|
// Directory name from fork URL (what git clone would use), e.g. "egregore-core"
|
|
@@ -52,6 +52,16 @@ async function install(data, ui, targetDir) {
|
|
|
52
52
|
}
|
|
53
53
|
ui.success("Cloned egregore");
|
|
54
54
|
|
|
55
|
+
// Set repo-local git identity from GitHub user (not machine-global config)
|
|
56
|
+
if (github_username) {
|
|
57
|
+
try {
|
|
58
|
+
run(`git config user.name "${github_name || github_username}"`, { cwd: egregoreDir });
|
|
59
|
+
run(`git config user.email "${github_username}@users.noreply.github.com"`, { cwd: egregoreDir });
|
|
60
|
+
} catch {
|
|
61
|
+
// Non-fatal
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
55
65
|
// 2. Clone memory
|
|
56
66
|
ui.step(2, totalSteps, "Cloning shared memory...");
|
|
57
67
|
if (fs.existsSync(memoryDir)) {
|
|
@@ -87,6 +97,19 @@ async function install(data, ui, targetDir) {
|
|
|
87
97
|
fs.writeFileSync(envPath, envLines.join("\n") + "\n", { mode: 0o600 });
|
|
88
98
|
ui.success("Credentials saved");
|
|
89
99
|
|
|
100
|
+
// 4b. Save identity to .egregore-state.json (so session-start.sh knows who this is)
|
|
101
|
+
const statePath = path.join(egregoreDir, ".egregore-state.json");
|
|
102
|
+
let state = {};
|
|
103
|
+
if (fs.existsSync(statePath)) {
|
|
104
|
+
try { state = JSON.parse(fs.readFileSync(statePath, "utf-8")); } catch {}
|
|
105
|
+
}
|
|
106
|
+
if (github_username) {
|
|
107
|
+
state.github_username = github_username;
|
|
108
|
+
state.github_name = github_name || github_username;
|
|
109
|
+
}
|
|
110
|
+
state.onboarding_complete = true;
|
|
111
|
+
fs.writeFileSync(statePath, JSON.stringify(state, null, 2) + "\n");
|
|
112
|
+
|
|
90
113
|
// 5. Register instance + shell alias
|
|
91
114
|
ui.step(5, totalSteps, "Registering instance...");
|
|
92
115
|
registerInstance(forkDirName, org_name, egregoreDir);
|