@cohesivity/init 0.3.2 → 0.3.3
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 +13 -5
- package/package.json +1 -1
package/bin/cli.js
CHANGED
|
@@ -34,14 +34,16 @@ const flag = (f) => { const i = argv.indexOf(f); return i >= 0 ? argv[i + 1] : u
|
|
|
34
34
|
if (has('--help') || has('-h')) { help(); process.exit(0); }
|
|
35
35
|
|
|
36
36
|
// ── config ──────────────────────────────────────────────────────────────────
|
|
37
|
-
const PKG_VERSION = '0.3.
|
|
37
|
+
const PKG_VERSION = '0.3.3';
|
|
38
38
|
const BASE = (flag('--base') || process.env.COHESIVITY_BASE || 'https://cohesivity.ai').replace(/\/+$/, '');
|
|
39
39
|
|
|
40
40
|
// Machine id: one per machine, stored outside any project. A project's
|
|
41
41
|
// .cohesivity is per project, so a machine that runs setup in several projects
|
|
42
42
|
// owns several tenants; this is what tells the server they came from one setup
|
|
43
43
|
// rather than several unrelated people. Sent on genesis; the server issues one
|
|
44
|
-
//
|
|
44
|
+
// whenever it cannot verify what we sent — none at all, or an id gone stale
|
|
45
|
+
// because the signing secret rotated or the file was corrupted — and whatever
|
|
46
|
+
// it issues replaces what is on disk. Steady state is written once and reused.
|
|
45
47
|
const MACHINE_ID_HEADER = 'X-Cohesivity-Machine-Id';
|
|
46
48
|
const MACHINE_ID_DIR = join(process.env.XDG_CONFIG_HOME || join(homedir(), '.config'), 'cohesivity');
|
|
47
49
|
const MACHINE_ID_FILE = join(MACHINE_ID_DIR, 'machine-id');
|
|
@@ -186,8 +188,10 @@ async function ensureTenant() {
|
|
|
186
188
|
if (machineId) headers[MACHINE_ID_HEADER] = machineId;
|
|
187
189
|
const res = await fetch(`${BASE}/api/genesis`, { method: 'POST', headers });
|
|
188
190
|
body = await res.text();
|
|
189
|
-
//
|
|
190
|
-
//
|
|
191
|
+
// Returned on any request that MINTED an id, which is when we sent none
|
|
192
|
+
// *or* when the id we sent no longer verifies (secret rotated, file
|
|
193
|
+
// corrupted). It is not "non-null exactly when we sent none" — assuming
|
|
194
|
+
// that is what left a machine pinned to a dead id forever.
|
|
191
195
|
issuedMachineId = res.headers.get(MACHINE_ID_HEADER);
|
|
192
196
|
} catch (e) {
|
|
193
197
|
log(`no tenant created (network: ${e.message}). Re-run to retry. The command is idempotent.`);
|
|
@@ -199,7 +203,11 @@ async function ensureTenant() {
|
|
|
199
203
|
}
|
|
200
204
|
writeFileSync(dotfile, body);
|
|
201
205
|
ensureGitignore();
|
|
202
|
-
|
|
206
|
+
// Store whatever the server issued. Its presence already means "we minted
|
|
207
|
+
// this for you", so gating on `!machineId` as well dropped every replacement
|
|
208
|
+
// a machine with a stale id was handed: it re-minted on every genesis, kept
|
|
209
|
+
// none of them, and each project became its own machine row.
|
|
210
|
+
if (issuedMachineId) writeMachineId(issuedMachineId);
|
|
203
211
|
log('created an ephemeral tenant -> ./.cohesivity');
|
|
204
212
|
}
|
|
205
213
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cohesivity/init",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.3",
|
|
4
4
|
"description": "Set up Cohesivity in a project: install the agent skill, create a managed backend tenant, write the project config. Run with `npx @cohesivity/init`.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|