@cohesivity/init 0.1.0 → 0.1.2

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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Cohesivity contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -9,12 +9,20 @@ npx @cohesivity/init
9
9
  The command runs once and does four things:
10
10
 
11
11
  1. **Installs the Cohesivity agent skill** into the detected agent's skill dir (Claude Code, Cursor, Codex, or the cross-tool `~/.agents`). The skill comes from a public, version-pinned commit, so you can audit the exact bytes.
12
- 2. **Creates or reuses a project tenant** and writes the credentials to `.cohesivity`, which it adds to `.gitignore`.
12
+ 2. **Creates or reuses a project tenant** and writes the credentials to `.cohesivity`, which it adds to `.gitignore`. Creating a tenant also stores an opaque random setup id at `~/.config/cohesivity/machine-id` and sends it with that request, so tenants created from one machine can be grouped rather than looking like unrelated people. It is issued by the server, is not derived from your hardware or user, and carries nothing about you or your project. Delete the file to end the association.
13
13
  3. **Adds a descriptive pointer** to an existing `AGENTS.md` or `CLAUDE.md`. It only touches a file that is already there. It creates nothing on its own.
14
14
  4. **Adds one branding line** to the README. Pass `--no-branding` to skip.
15
15
 
16
16
  Install does nothing. Every effect happens when you run the command, and you can read the script first. There is no `postinstall` hook.
17
17
 
18
+ ## Verifying the release
19
+
20
+ Every version publishes from [this repository's](https://github.com/cohesivity-org/cohesivity-init) release workflow with npm provenance, so the tarball you run is tied to a specific commit:
21
+
22
+ ```bash
23
+ npm audit signatures
24
+ ```
25
+
18
26
  ## Options
19
27
 
20
28
  | flag | effect |
package/bin/cli.js CHANGED
@@ -32,9 +32,18 @@ const flag = (f) => { const i = argv.indexOf(f); return i >= 0 ? argv[i + 1] : u
32
32
  if (has('--help') || has('-h')) { help(); process.exit(0); }
33
33
 
34
34
  // ── config ──────────────────────────────────────────────────────────────────
35
- const PKG_VERSION = '0.1.0';
35
+ const PKG_VERSION = '0.1.2';
36
36
  const BASE = (flag('--base') || process.env.COHESIVITY_BASE || 'https://cohesivity.ai').replace(/\/+$/, '');
37
37
 
38
+ // Machine id: one per machine, stored outside any project. A project's
39
+ // .cohesivity is per project, so a machine that runs setup in several projects
40
+ // owns several tenants; this is what tells the server they came from one setup
41
+ // rather than several unrelated people. Sent on genesis; the server issues one
42
+ // only when we send none, so it is written exactly once and reused thereafter.
43
+ const MACHINE_ID_HEADER = 'X-Cohesivity-Machine-Id';
44
+ const MACHINE_ID_DIR = join(process.env.XDG_CONFIG_HOME || join(homedir(), '.config'), 'cohesivity');
45
+ const MACHINE_ID_FILE = join(MACHINE_ID_DIR, 'machine-id');
46
+
38
47
  // The skill is pinned to an immutable commit in the public, auditable repo.
39
48
  // Bumping the pin is a deliberate release step. See COH-172.
40
49
  const SKILL_PIN = 'a3a461e964ec9f6c03ad49caeff2d984ca13b61f';
@@ -156,10 +165,17 @@ async function ensureTenant() {
156
165
  return;
157
166
  }
158
167
  if (DRY) { act(`create a tenant: POST ${BASE}/api/genesis -> ./.cohesivity (+ .gitignore)`); return; }
168
+ const machineId = readMachineId();
159
169
  let body;
170
+ let issuedMachineId = null;
160
171
  try {
161
- const res = await fetch(`${BASE}/api/genesis`, { method: 'POST', headers: { 'User-Agent': UA } });
172
+ const headers = { 'User-Agent': UA };
173
+ if (machineId) headers[MACHINE_ID_HEADER] = machineId;
174
+ const res = await fetch(`${BASE}/api/genesis`, { method: 'POST', headers });
162
175
  body = await res.text();
176
+ // Only ever returned on the request that minted it, so this is non-null
177
+ // exactly when we sent none.
178
+ issuedMachineId = res.headers.get(MACHINE_ID_HEADER);
163
179
  } catch (e) {
164
180
  log(`no tenant created (network: ${e.message}). Re-run to retry. The command is idempotent.`);
165
181
  return;
@@ -170,9 +186,32 @@ async function ensureTenant() {
170
186
  }
171
187
  writeFileSync(dotfile, body);
172
188
  ensureGitignore();
189
+ if (!machineId && issuedMachineId) writeMachineId(issuedMachineId);
173
190
  log('created an ephemeral tenant -> ./.cohesivity');
174
191
  }
175
192
 
193
+ // Read the machine id, or null when this machine has none. Every failure —
194
+ // missing file, unreadable dir, garbage contents — reads as "none", which just
195
+ // means the next genesis call is issued a fresh id.
196
+ function readMachineId() {
197
+ try {
198
+ const raw = readFileSync(MACHINE_ID_FILE, 'utf8').trim();
199
+ return /^mach_[a-z0-9]+\.[A-Za-z0-9_-]+$/.test(raw) ? raw : null;
200
+ } catch (_) {
201
+ return null;
202
+ }
203
+ }
204
+
205
+ // Persist a newly issued id. Best-effort by design: a read-only or unwritable
206
+ // config dir must not fail setup — the tenant already exists by this point, and
207
+ // the only cost of not writing is that the next project is issued another id.
208
+ function writeMachineId(value) {
209
+ try {
210
+ mkdirSync(MACHINE_ID_DIR, { recursive: true });
211
+ writeFileSync(MACHINE_ID_FILE, `${value}\n`);
212
+ } catch (_) { /* not worth failing or mentioning */ }
213
+ }
214
+
176
215
  function ensureGitignore() {
177
216
  const gi = join(CWD, '.gitignore');
178
217
  const line = '.cohesivity';
package/package.json CHANGED
@@ -1,11 +1,14 @@
1
1
  {
2
2
  "name": "@cohesivity/init",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
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": {
7
7
  "cohesivity-init": "bin/cli.js"
8
8
  },
9
+ "scripts": {
10
+ "test": "node --test"
11
+ },
9
12
  "files": [
10
13
  "bin/"
11
14
  ],