@primitive.ai/prim 0.1.0-alpha.62 → 0.1.0-alpha.63
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/{chunk-I3HIPAIR.js → chunk-CPX3BUOC.js} +7 -4
- package/dist/{chunk-S4LFRVGD.js → chunk-HIMWM526.js} +1 -1
- package/dist/{chunk-R4CUX6FY.js → chunk-KHZNYEUV.js} +1 -1
- package/dist/{chunk-LOGW54W5.js → chunk-WNIY6Z6N.js} +1 -1
- package/dist/{chunk-YITJ2H3B.js → chunk-WS3MCNFD.js} +1 -1
- package/dist/daemon/server.js +343 -44
- package/dist/hooks/post-commit.js +2 -2
- package/dist/hooks/post-tool-use.js +2 -2
- package/dist/hooks/pre-commit.js +2 -2
- package/dist/hooks/pre-tool-use.js +1 -1
- package/dist/hooks/prim-hook.js +3 -3
- package/dist/hooks/session-start.js +8 -4
- package/dist/index.js +186 -126
- package/dist/statusline-main.js +50 -40
- package/package.json +1 -1
package/dist/statusline-main.js
CHANGED
|
@@ -26,10 +26,10 @@ import { dirname, join } from "path";
|
|
|
26
26
|
|
|
27
27
|
// src/client.ts
|
|
28
28
|
var DEFAULT_API_URL = "https://api.getprimitive.ai";
|
|
29
|
-
function loadEnvFile() {
|
|
29
|
+
function loadEnvFile(cwd = process.cwd()) {
|
|
30
30
|
const envVars = {};
|
|
31
31
|
for (const file of [".env.local", ".env"]) {
|
|
32
|
-
const filePath = resolve(
|
|
32
|
+
const filePath = resolve(cwd, file);
|
|
33
33
|
if (!existsSync2(filePath)) continue;
|
|
34
34
|
const content = readFileSync2(filePath, "utf-8");
|
|
35
35
|
for (const line of content.split("\n")) {
|
|
@@ -48,8 +48,11 @@ var TOKEN_EXPIRES_PATH = join2(dirname2(TOKEN_FILE_PATH), "token_expires_at");
|
|
|
48
48
|
var TERMINAL_REFRESH_PATH = join2(dirname2(TOKEN_FILE_PATH), "refresh_terminal");
|
|
49
49
|
var CREDENTIAL_LOCK_PATH = join2(dirname2(TOKEN_FILE_PATH), "credentials.lock");
|
|
50
50
|
function getSiteUrl() {
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
return getSiteUrlForCwd(process.cwd(), process.env.PRIM_API_URL);
|
|
52
|
+
}
|
|
53
|
+
function getSiteUrlForCwd(cwd, primApiUrl) {
|
|
54
|
+
if (primApiUrl) return primApiUrl;
|
|
55
|
+
return loadEnvFile(cwd).PRIM_API_URL ?? DEFAULT_API_URL;
|
|
53
56
|
}
|
|
54
57
|
|
|
55
58
|
// src/daemon/client.ts
|
|
@@ -273,15 +276,54 @@ function formatTeammatesWithArea(teammates, cap) {
|
|
|
273
276
|
);
|
|
274
277
|
}
|
|
275
278
|
|
|
279
|
+
// src/lib/statusline-render.ts
|
|
280
|
+
var STATUSLINE_NAME_CAP = 3;
|
|
281
|
+
function formatStatusline(version, snapshot, resolveIngestionStatus) {
|
|
282
|
+
if (!snapshot) {
|
|
283
|
+
return `primitive ${version} (daemon: down)`;
|
|
284
|
+
}
|
|
285
|
+
if (snapshot.healthy === false) {
|
|
286
|
+
if (snapshot.needsReauth) {
|
|
287
|
+
return `primitive ${version} (daemon: paused \xB7 run \`prim auth login\`)`;
|
|
288
|
+
}
|
|
289
|
+
if (snapshot.ingestion?.healthy === false) {
|
|
290
|
+
const pending = snapshot.ingestion.pendingCount;
|
|
291
|
+
const qualifier = snapshot.ingestion.pendingSampled ? "at least " : "";
|
|
292
|
+
return `primitive ${version} (daemon: degraded \xB7 delivery: stalled${typeof pending === "number" ? ` \xB7 ${qualifier}${String(pending)} pending` : ""})`;
|
|
293
|
+
}
|
|
294
|
+
if (snapshot.heartbeat?.healthy === false) {
|
|
295
|
+
return `primitive ${version} (daemon: degraded \xB7 presence: unavailable)`;
|
|
296
|
+
}
|
|
297
|
+
return `primitive ${version} (daemon: starting)`;
|
|
298
|
+
}
|
|
299
|
+
const ingestionStatus = resolveIngestionStatus();
|
|
300
|
+
if (snapshot.envMismatch) {
|
|
301
|
+
return `primitive ${version} (daemon: live, Decision ingestion ${ingestionStatus} \xB7 presence: other env)`;
|
|
302
|
+
}
|
|
303
|
+
if (snapshot.presenceStale) {
|
|
304
|
+
return `primitive ${version} (daemon: live, Decision ingestion ${ingestionStatus} \xB7 presence: stale)`;
|
|
305
|
+
}
|
|
306
|
+
let team;
|
|
307
|
+
if (snapshot.onlineTeammates !== void 0) {
|
|
308
|
+
team = `team: ${formatTeammatesWithArea(snapshot.onlineTeammates, STATUSLINE_NAME_CAP)}`;
|
|
309
|
+
} else if (snapshot.onlineNames !== void 0) {
|
|
310
|
+
team = `team: ${formatTeammates(snapshot.onlineNames, STATUSLINE_NAME_CAP)}`;
|
|
311
|
+
} else if (typeof snapshot.onlineCount === "number") {
|
|
312
|
+
team = `team: ${String(snapshot.onlineCount)} online`;
|
|
313
|
+
} else {
|
|
314
|
+
team = "team: \u2014";
|
|
315
|
+
}
|
|
316
|
+
return `primitive ${version} (daemon: live, Decision ingestion ${ingestionStatus} \xB7 ${team})`;
|
|
317
|
+
}
|
|
318
|
+
|
|
276
319
|
// src/commands/statusline.ts
|
|
277
320
|
var STATUSLINE_TIMEOUT_MS = 200;
|
|
278
|
-
var STATUSLINE_NAME_CAP = 3;
|
|
279
321
|
function readPackageVersion() {
|
|
280
322
|
try {
|
|
281
323
|
const here = dirname5(fileURLToPath2(import.meta.url));
|
|
282
324
|
const candidates = [
|
|
283
|
-
//
|
|
284
|
-
//
|
|
325
|
+
// Schema-v2 runtimes staged a manifest beside this standalone bundle.
|
|
326
|
+
// Keep resolving it while those legacy launchers transition to schema v3.
|
|
285
327
|
resolve3(here, "manifest.json"),
|
|
286
328
|
resolve3(here, "../../package.json"),
|
|
287
329
|
resolve3(here, "../package.json")
|
|
@@ -316,40 +358,8 @@ async function renderStatusline() {
|
|
|
316
358
|
);
|
|
317
359
|
if (!snapshot) {
|
|
318
360
|
debug("daemon snapshot missing");
|
|
319
|
-
return `primitive ${version} (daemon: down)`;
|
|
320
|
-
}
|
|
321
|
-
if (snapshot.healthy === false) {
|
|
322
|
-
if (snapshot.needsReauth) {
|
|
323
|
-
return `primitive ${version} (daemon: paused \xB7 run \`prim auth login\`)`;
|
|
324
|
-
}
|
|
325
|
-
if (snapshot.ingestion?.healthy === false) {
|
|
326
|
-
const pending = snapshot.ingestion.pendingCount;
|
|
327
|
-
const qualifier = snapshot.ingestion.pendingSampled ? "at least " : "";
|
|
328
|
-
return `primitive ${version} (daemon: degraded \xB7 delivery: stalled${typeof pending === "number" ? ` \xB7 ${qualifier}${String(pending)} pending` : ""})`;
|
|
329
|
-
}
|
|
330
|
-
if (snapshot.heartbeat?.healthy === false) {
|
|
331
|
-
return `primitive ${version} (daemon: degraded \xB7 presence: unavailable)`;
|
|
332
|
-
}
|
|
333
|
-
return `primitive ${version} (daemon: starting)`;
|
|
334
361
|
}
|
|
335
|
-
|
|
336
|
-
if (snapshot.envMismatch) {
|
|
337
|
-
return `primitive ${version} (daemon: live, Decision ingestion ${ingestionStatus} \xB7 presence: other env)`;
|
|
338
|
-
}
|
|
339
|
-
if (snapshot.presenceStale) {
|
|
340
|
-
return `primitive ${version} (daemon: live, Decision ingestion ${ingestionStatus} \xB7 presence: stale)`;
|
|
341
|
-
}
|
|
342
|
-
let team;
|
|
343
|
-
if (snapshot.onlineTeammates !== void 0) {
|
|
344
|
-
team = `team: ${formatTeammatesWithArea(snapshot.onlineTeammates, STATUSLINE_NAME_CAP)}`;
|
|
345
|
-
} else if (snapshot.onlineNames !== void 0) {
|
|
346
|
-
team = `team: ${formatTeammates(snapshot.onlineNames, STATUSLINE_NAME_CAP)}`;
|
|
347
|
-
} else if (typeof snapshot.onlineCount === "number") {
|
|
348
|
-
team = `team: ${String(snapshot.onlineCount)} online`;
|
|
349
|
-
} else {
|
|
350
|
-
team = "team: \u2014";
|
|
351
|
-
}
|
|
352
|
-
return `primitive ${version} (daemon: live, Decision ingestion ${ingestionStatus} \xB7 ${team})`;
|
|
362
|
+
return formatStatusline(version, snapshot, () => decisionIngestionStatus(process.cwd()));
|
|
353
363
|
}
|
|
354
364
|
|
|
355
365
|
// src/statusline-main.ts
|
package/package.json
CHANGED