eversince 0.2.3 → 0.2.4
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/dist/commands/init.js +32 -9
- package/package.json +2 -2
package/dist/commands/init.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { existsSync } from 'node:fs';
|
|
2
|
-
import { readFile, writeFile, mkdir, copyFile, access, rename } from 'node:fs/promises';
|
|
2
|
+
import { readFile, writeFile, mkdir, copyFile, access, rename, stat } from 'node:fs/promises';
|
|
3
3
|
import { join, dirname } from 'node:path';
|
|
4
4
|
import { homedir } from 'node:os';
|
|
5
5
|
import { discoverAuthorizationServer } from '../auth/oauth.js';
|
|
@@ -56,8 +56,9 @@ function manualFor(agent, mcpUrl) {
|
|
|
56
56
|
}
|
|
57
57
|
async function writeAtomic(path, text) {
|
|
58
58
|
await mkdir(dirname(path), { recursive: true });
|
|
59
|
+
const mode = await stat(path).then((s) => s.mode & 0o777, () => 0o600);
|
|
59
60
|
const temp = `${path}.eversince-${process.pid}.tmp`;
|
|
60
|
-
await writeFile(temp, text);
|
|
61
|
+
await writeFile(temp, text, { mode });
|
|
61
62
|
await rename(temp, path);
|
|
62
63
|
}
|
|
63
64
|
function skillTargets(scope) {
|
|
@@ -125,7 +126,18 @@ async function backup(path) {
|
|
|
125
126
|
await copyFile(path, target);
|
|
126
127
|
return target;
|
|
127
128
|
}
|
|
128
|
-
|
|
129
|
+
function pointsHere(url, mcpUrl, baseUrl) {
|
|
130
|
+
const bare = (u) => u.replace(/\/+$/, '');
|
|
131
|
+
if (bare(url) === bare(mcpUrl))
|
|
132
|
+
return true;
|
|
133
|
+
try {
|
|
134
|
+
return new URL(url).origin === new URL(baseUrl).origin;
|
|
135
|
+
}
|
|
136
|
+
catch {
|
|
137
|
+
return false;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
async function writeMcpEntry(target, mcpUrl, baseUrl, dryRun) {
|
|
129
141
|
const entry = { type: 'http', url: mcpUrl };
|
|
130
142
|
let current = {};
|
|
131
143
|
const had = await exists(target.path);
|
|
@@ -146,16 +158,18 @@ async function writeMcpEntry(target, mcpUrl, dryRun) {
|
|
|
146
158
|
const merged = existing && typeof existing === 'object'
|
|
147
159
|
? { ...entry, ...existing }
|
|
148
160
|
: entry;
|
|
161
|
+
const keptUrl = merged.url;
|
|
162
|
+
const elsewhere = typeof keptUrl === 'string' && !pointsHere(keptUrl, mcpUrl, baseUrl) ? { points_to: keptUrl } : {};
|
|
149
163
|
if (existing && JSON.stringify(existing) === JSON.stringify(merged)) {
|
|
150
|
-
return { agent: target.agent, path: target.path, action: 'unchanged' };
|
|
164
|
+
return { agent: target.agent, path: target.path, action: 'unchanged', ...elsewhere };
|
|
151
165
|
}
|
|
152
166
|
if (dryRun) {
|
|
153
|
-
return { agent: target.agent, path: target.path, action: had ? 'updated' : 'created' };
|
|
167
|
+
return { agent: target.agent, path: target.path, action: had ? 'updated' : 'created', ...elsewhere };
|
|
154
168
|
}
|
|
155
169
|
const saved = had ? await backup(target.path) : undefined;
|
|
156
170
|
servers[SERVER_KEY] = merged;
|
|
157
171
|
await writeAtomic(target.path, `${JSON.stringify({ ...current, [target.key]: servers }, null, 2)}\n`);
|
|
158
|
-
return { agent: target.agent, path: target.path, action: had ? 'updated' : 'created', backup: saved };
|
|
172
|
+
return { agent: target.agent, path: target.path, action: had ? 'updated' : 'created', backup: saved, ...elsewhere };
|
|
159
173
|
}
|
|
160
174
|
async function writeSkill(target, body, force, dryRun) {
|
|
161
175
|
if (await exists(target.path)) {
|
|
@@ -277,10 +291,12 @@ export async function init(argv, connection, mode) {
|
|
|
277
291
|
const offerApp = !app;
|
|
278
292
|
const changes = [];
|
|
279
293
|
const skipped = [];
|
|
294
|
+
const entries = [];
|
|
280
295
|
if (doMcp) {
|
|
281
296
|
for (const target of jsonTargets(scope, agent)) {
|
|
282
|
-
|
|
297
|
+
entries.push(await writeMcpEntry(target, mcpUrl, baseUrl, dryRun));
|
|
283
298
|
}
|
|
299
|
+
changes.push(...entries);
|
|
284
300
|
skipped.push(...manualFor(agent, mcpUrl));
|
|
285
301
|
}
|
|
286
302
|
if (doSkills) {
|
|
@@ -289,7 +305,8 @@ export async function init(argv, connection, mode) {
|
|
|
289
305
|
changes.push(await writeSkill(target, body, argv.force === true, dryRun));
|
|
290
306
|
}
|
|
291
307
|
}
|
|
292
|
-
|
|
308
|
+
const connected = !(entries.length > 0 && entries.every((entry) => entry.points_to));
|
|
309
|
+
if (!dryRun && connected) {
|
|
293
310
|
const wrote = changes.filter((c) => c.action !== 'unchanged').map((c) => c.agent);
|
|
294
311
|
const named = agent
|
|
295
312
|
? agent === 'claude-code' || agent === 'cursor' || agent === 'codex'
|
|
@@ -315,11 +332,13 @@ export async function init(argv, connection, mode) {
|
|
|
315
332
|
}
|
|
316
333
|
}
|
|
317
334
|
}
|
|
318
|
-
printResult(mode, { venue: 'cloud', scope, mcp_url: mcpUrl, dry_run: dryRun, changes, manual: skipped, ...(offerApp ? { desktop_app: GET_THE_APP } : {}) }, () => {
|
|
335
|
+
printResult(mode, { venue: 'cloud', scope, mcp_url: mcpUrl, dry_run: dryRun, connected, changes, manual: skipped, ...(offerApp ? { desktop_app: GET_THE_APP } : {}) }, () => {
|
|
319
336
|
for (const change of changes) {
|
|
320
337
|
line(`${change.action.padEnd(10)}${change.path}`);
|
|
321
338
|
if (change.backup)
|
|
322
339
|
note(` previous copy: ${change.backup}`);
|
|
340
|
+
if (change.points_to)
|
|
341
|
+
note(` its ${SERVER_KEY} entry points to ${change.points_to}, not ${mcpUrl}. Remove the entry and run init again to connect here.`);
|
|
323
342
|
}
|
|
324
343
|
for (const item of skipped) {
|
|
325
344
|
line();
|
|
@@ -330,6 +349,10 @@ export async function init(argv, connection, mode) {
|
|
|
330
349
|
line('Dry run. Nothing was written.');
|
|
331
350
|
return;
|
|
332
351
|
}
|
|
352
|
+
if (!connected) {
|
|
353
|
+
line(`Not connected to ${hostOf(baseUrl)}: the entry already there points elsewhere.`);
|
|
354
|
+
return;
|
|
355
|
+
}
|
|
333
356
|
line(`Connected to ${hostOf(baseUrl)}. Restart any running agent to pick it up.`);
|
|
334
357
|
note('The agent authorises its own MCP connection; it does not use the CLI credential.');
|
|
335
358
|
if (offerApp)
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eversince",
|
|
3
|
-
"version": "0.2.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.2.4",
|
|
4
|
+
"description": "The Eversince CLI. Eversince is the media workspace for agents: connect an agent, call any tool, move files and follow jobs from a shell.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
7
7
|
"eversince": "dist/index.js"
|