ccjk 13.3.23 → 13.5.0
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/chunks/auto-bootstrap.mjs +2 -2
- package/dist/chunks/auto-fix.mjs +52 -1
- package/dist/chunks/ccjk-agents.mjs +1 -1
- package/dist/chunks/ccjk-all.mjs +5 -5
- package/dist/chunks/ccjk-hooks.mjs +4 -3
- package/dist/chunks/ccjk-mcp.mjs +1 -1
- package/dist/chunks/ccjk-setup.mjs +3 -3
- package/dist/chunks/ccjk-skills.mjs +3 -2
- package/dist/chunks/ccr.mjs +1 -1
- package/dist/chunks/claude-code-config-manager.mjs +76 -25
- package/dist/chunks/claude-code-incremental-manager.mjs +7 -4
- package/dist/chunks/config2.mjs +33 -16
- package/dist/chunks/constants.mjs +2 -2
- package/dist/chunks/doctor.mjs +1 -1
- package/dist/chunks/init.mjs +2 -2
- package/dist/chunks/mcp.mjs +2 -2
- package/dist/chunks/menu-hierarchical.mjs +1 -1
- package/dist/chunks/notification.mjs +5 -5
- package/dist/chunks/onboarding-wizard.mjs +1 -1
- package/dist/chunks/package.mjs +1 -1
- package/dist/chunks/plugin.mjs +2 -2
- package/dist/chunks/quick-provider.mjs +6 -1
- package/dist/chunks/remote.mjs +2 -2
- package/dist/chunks/skills-sync.mjs +3 -3
- package/dist/chunks/slash-commands.mjs +1 -1
- package/dist/chunks/status.mjs +26 -0
- package/dist/index.d.mts +241 -60
- package/dist/index.d.ts +241 -60
- package/dist/index.mjs +15 -354
- package/dist/shared/{ccjk.eIn-g1yI.mjs → ccjk.BBizCO6_.mjs} +3 -2
- package/dist/shared/{ccjk.CLUL0pAV.mjs → ccjk.C3YuTovw.mjs} +177 -16
- package/dist/shared/{ccjk.BtB1e5jm.mjs → ccjk.D0g2ABGg.mjs} +3 -3
- package/dist/shared/{ccjk.DRfdq6yl.mjs → ccjk.DypYla6I.mjs} +2 -1
- package/package.json +1 -1
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import { c as consola, o as ofetch } from './ccjk.
|
|
2
|
-
import fs__default, { readFileSync } from 'node:fs';
|
|
3
|
-
import path__default, {
|
|
1
|
+
import { c as consola, o as ofetch } from './ccjk.DypYla6I.mjs';
|
|
2
|
+
import fs__default, { existsSync, readFileSync, mkdirSync, writeFileSync } from 'node:fs';
|
|
3
|
+
import path__default, { join, dirname } from 'node:path';
|
|
4
|
+
import { homedir } from 'node:os';
|
|
4
5
|
import { fileURLToPath } from 'node:url';
|
|
5
6
|
import { randomUUID } from 'node:crypto';
|
|
7
|
+
import { CLOUD_ENDPOINTS } from '../chunks/constants.mjs';
|
|
6
8
|
|
|
7
9
|
const defaults = Object.freeze({
|
|
8
10
|
ignoreUnknown: false,
|
|
@@ -924,29 +926,97 @@ try {
|
|
|
924
926
|
} catch {
|
|
925
927
|
}
|
|
926
928
|
const API_PREFIX = "/api/v1";
|
|
927
|
-
const HEALTH_PATH =
|
|
929
|
+
const HEALTH_PATH = `${API_PREFIX}/health`;
|
|
930
|
+
const CLIENT_USAGE_STATE_DIR = join(homedir(), ".ccjk");
|
|
931
|
+
const CLIENT_USAGE_STATE_FILE = join(CLIENT_USAGE_STATE_DIR, "cloud-client-identity.json");
|
|
928
932
|
class CloudClient {
|
|
929
933
|
fetch;
|
|
930
934
|
config;
|
|
935
|
+
identity;
|
|
931
936
|
constructor(config) {
|
|
932
937
|
this.config = {
|
|
933
938
|
timeout: 1e4,
|
|
934
939
|
enableRetry: true,
|
|
935
940
|
maxRetries: 3,
|
|
936
941
|
enableTelemetry: true,
|
|
942
|
+
enableUsageAnalytics: true,
|
|
943
|
+
autoHandshake: true,
|
|
937
944
|
...config
|
|
938
945
|
};
|
|
946
|
+
this.identity = this.resolveIdentity();
|
|
939
947
|
this.fetch = ofetch.create({
|
|
940
948
|
baseURL: this.config.baseURL,
|
|
941
949
|
timeout: this.config.timeout,
|
|
942
|
-
headers:
|
|
943
|
-
"User-Agent": `CCJK/${this.config.version || CCJK_VERSION}`,
|
|
944
|
-
...this.config.apiKey && { Authorization: `Bearer ${this.config.apiKey}` }
|
|
945
|
-
},
|
|
950
|
+
headers: this.getDefaultHeaders(),
|
|
946
951
|
retry: this.config.enableRetry ? this.config.maxRetries : 0,
|
|
947
952
|
retryDelay: (context) => this.calculateRetryDelay(context.options.retry || 0)
|
|
948
953
|
});
|
|
949
954
|
}
|
|
955
|
+
getDefaultHeaders() {
|
|
956
|
+
const headers = {
|
|
957
|
+
"User-Agent": `CCJK/${this.identity.clientVersion}`,
|
|
958
|
+
"X-CCJK-Version": this.identity.clientVersion,
|
|
959
|
+
"X-Anonymous-User-Id": this.identity.anonymousUserId
|
|
960
|
+
};
|
|
961
|
+
if (this.config.apiKey) {
|
|
962
|
+
headers.Authorization = `Bearer ${this.config.apiKey}`;
|
|
963
|
+
}
|
|
964
|
+
if (this.identity.deviceToken) {
|
|
965
|
+
headers["X-Device-Token"] = this.identity.deviceToken;
|
|
966
|
+
}
|
|
967
|
+
return headers;
|
|
968
|
+
}
|
|
969
|
+
resolveIdentity() {
|
|
970
|
+
const storedIdentity = this.loadOrCreateStoredIdentity();
|
|
971
|
+
const clientVersion = this.config.version || CCJK_VERSION;
|
|
972
|
+
return {
|
|
973
|
+
anonymousUserId: this.config.anonymousUserId || storedIdentity.anonymousUserId,
|
|
974
|
+
deviceId: this.config.deviceId || storedIdentity.deviceId,
|
|
975
|
+
clientVersion,
|
|
976
|
+
platform: this.config.platform || process.platform,
|
|
977
|
+
deviceToken: this.config.deviceToken
|
|
978
|
+
};
|
|
979
|
+
}
|
|
980
|
+
loadOrCreateStoredIdentity() {
|
|
981
|
+
try {
|
|
982
|
+
if (existsSync(CLIENT_USAGE_STATE_FILE)) {
|
|
983
|
+
const stored = JSON.parse(readFileSync(CLIENT_USAGE_STATE_FILE, "utf-8"));
|
|
984
|
+
if (stored.anonymousUserId && stored.deviceId) {
|
|
985
|
+
return {
|
|
986
|
+
anonymousUserId: stored.anonymousUserId,
|
|
987
|
+
deviceId: stored.deviceId
|
|
988
|
+
};
|
|
989
|
+
}
|
|
990
|
+
}
|
|
991
|
+
} catch (error) {
|
|
992
|
+
consola.debug("Failed to read stored cloud client identity:", error);
|
|
993
|
+
}
|
|
994
|
+
const generated = {
|
|
995
|
+
anonymousUserId: process.env.CCJK_ANONYMOUS_USER_ID || randomUUID(),
|
|
996
|
+
deviceId: process.env.CCJK_DEVICE_ID || randomUUID()
|
|
997
|
+
};
|
|
998
|
+
try {
|
|
999
|
+
mkdirSync(CLIENT_USAGE_STATE_DIR, { recursive: true });
|
|
1000
|
+
writeFileSync(CLIENT_USAGE_STATE_FILE, JSON.stringify(generated, null, 2));
|
|
1001
|
+
} catch (error) {
|
|
1002
|
+
consola.debug("Failed to persist cloud client identity:", error);
|
|
1003
|
+
}
|
|
1004
|
+
return generated;
|
|
1005
|
+
}
|
|
1006
|
+
buildAnalyticsPayload(payload) {
|
|
1007
|
+
return {
|
|
1008
|
+
deviceId: payload?.deviceId || this.identity.deviceId,
|
|
1009
|
+
platform: payload?.platform || this.identity.platform,
|
|
1010
|
+
clientVersion: payload?.clientVersion || this.identity.clientVersion,
|
|
1011
|
+
...payload
|
|
1012
|
+
};
|
|
1013
|
+
}
|
|
1014
|
+
canSendUsageAnalytics() {
|
|
1015
|
+
return this.config.enableUsageAnalytics !== false;
|
|
1016
|
+
}
|
|
1017
|
+
getIdentity() {
|
|
1018
|
+
return { ...this.identity };
|
|
1019
|
+
}
|
|
950
1020
|
/**
|
|
951
1021
|
* Calculate retry delay with exponential backoff
|
|
952
1022
|
*/
|
|
@@ -1101,11 +1171,24 @@ class CloudClient {
|
|
|
1101
1171
|
* @returns Usage report response
|
|
1102
1172
|
*/
|
|
1103
1173
|
async reportUsage(report) {
|
|
1174
|
+
if (!this.canSendUsageAnalytics()) {
|
|
1175
|
+
return {
|
|
1176
|
+
success: false,
|
|
1177
|
+
requestId: "",
|
|
1178
|
+
message: "Usage analytics disabled"
|
|
1179
|
+
};
|
|
1180
|
+
}
|
|
1104
1181
|
try {
|
|
1105
1182
|
consola.debug("Reporting usage:", report.metricType);
|
|
1183
|
+
const payload = {
|
|
1184
|
+
...report,
|
|
1185
|
+
deviceId: report.deviceId || this.identity.deviceId,
|
|
1186
|
+
platform: report.platform || this.identity.platform,
|
|
1187
|
+
clientVersion: report.clientVersion || report.ccjkVersion || this.identity.clientVersion
|
|
1188
|
+
};
|
|
1106
1189
|
const response = await this.fetch(`${API_PREFIX}/usage/current`, {
|
|
1107
1190
|
method: "POST",
|
|
1108
|
-
body:
|
|
1191
|
+
body: payload,
|
|
1109
1192
|
timeout: 5e3
|
|
1110
1193
|
// 5s timeout - telemetry should be fast
|
|
1111
1194
|
});
|
|
@@ -1146,14 +1229,12 @@ class CloudClient {
|
|
|
1146
1229
|
*/
|
|
1147
1230
|
updateConfig(config) {
|
|
1148
1231
|
this.config = { ...this.config, ...config };
|
|
1149
|
-
|
|
1232
|
+
this.identity = this.resolveIdentity();
|
|
1233
|
+
if (config.baseURL || config.timeout || config.apiKey || config.version || config.deviceToken || config.anonymousUserId || config.deviceId || config.platform) {
|
|
1150
1234
|
this.fetch = ofetch.create({
|
|
1151
1235
|
baseURL: this.config.baseURL,
|
|
1152
1236
|
timeout: this.config.timeout,
|
|
1153
|
-
headers:
|
|
1154
|
-
"User-Agent": `CCJK/${this.config.version || CCJK_VERSION}`,
|
|
1155
|
-
...this.config.apiKey && { Authorization: `Bearer ${this.config.apiKey}` }
|
|
1156
|
-
},
|
|
1237
|
+
headers: this.getDefaultHeaders(),
|
|
1157
1238
|
retry: this.config.enableRetry ? this.config.maxRetries : 0,
|
|
1158
1239
|
retryDelay: (context) => this.calculateRetryDelay(context.options.retry || 0)
|
|
1159
1240
|
});
|
|
@@ -1165,10 +1246,76 @@ class CloudClient {
|
|
|
1165
1246
|
getConfig() {
|
|
1166
1247
|
return { ...this.config };
|
|
1167
1248
|
}
|
|
1249
|
+
async registerDevice(payload) {
|
|
1250
|
+
if (!this.canSendUsageAnalytics()) {
|
|
1251
|
+
return {
|
|
1252
|
+
success: false,
|
|
1253
|
+
message: "Usage analytics disabled"
|
|
1254
|
+
};
|
|
1255
|
+
}
|
|
1256
|
+
try {
|
|
1257
|
+
return await this.fetch("/device/register", {
|
|
1258
|
+
method: "POST",
|
|
1259
|
+
body: this.buildAnalyticsPayload(payload),
|
|
1260
|
+
timeout: 5e3
|
|
1261
|
+
});
|
|
1262
|
+
} catch (error) {
|
|
1263
|
+
consola.debug("Failed to register device (non-blocking):", error);
|
|
1264
|
+
return {
|
|
1265
|
+
success: false,
|
|
1266
|
+
requestId: "",
|
|
1267
|
+
message: error instanceof Error ? error.message : "Unknown error"
|
|
1268
|
+
};
|
|
1269
|
+
}
|
|
1270
|
+
}
|
|
1271
|
+
async handshake(payload) {
|
|
1272
|
+
if (!this.canSendUsageAnalytics()) {
|
|
1273
|
+
return {
|
|
1274
|
+
success: false,
|
|
1275
|
+
message: "Usage analytics disabled"
|
|
1276
|
+
};
|
|
1277
|
+
}
|
|
1278
|
+
try {
|
|
1279
|
+
return await this.fetch(`${API_PREFIX}/handshake`, {
|
|
1280
|
+
method: "POST",
|
|
1281
|
+
body: this.buildAnalyticsPayload(payload),
|
|
1282
|
+
timeout: 5e3
|
|
1283
|
+
});
|
|
1284
|
+
} catch (error) {
|
|
1285
|
+
consola.debug("Failed to send handshake (non-blocking):", error);
|
|
1286
|
+
return {
|
|
1287
|
+
success: false,
|
|
1288
|
+
requestId: "",
|
|
1289
|
+
message: error instanceof Error ? error.message : "Unknown error"
|
|
1290
|
+
};
|
|
1291
|
+
}
|
|
1292
|
+
}
|
|
1293
|
+
async syncClientUsage(payload) {
|
|
1294
|
+
if (!this.canSendUsageAnalytics()) {
|
|
1295
|
+
return {
|
|
1296
|
+
success: false,
|
|
1297
|
+
message: "Usage analytics disabled"
|
|
1298
|
+
};
|
|
1299
|
+
}
|
|
1300
|
+
try {
|
|
1301
|
+
return await this.fetch(`${API_PREFIX}/sync`, {
|
|
1302
|
+
method: "POST",
|
|
1303
|
+
body: this.buildAnalyticsPayload(payload),
|
|
1304
|
+
timeout: 5e3
|
|
1305
|
+
});
|
|
1306
|
+
} catch (error) {
|
|
1307
|
+
consola.debug("Failed to sync client usage (non-blocking):", error);
|
|
1308
|
+
return {
|
|
1309
|
+
success: false,
|
|
1310
|
+
requestId: "",
|
|
1311
|
+
message: error instanceof Error ? error.message : "Unknown error"
|
|
1312
|
+
};
|
|
1313
|
+
}
|
|
1314
|
+
}
|
|
1168
1315
|
}
|
|
1169
1316
|
function createCloudClient(config) {
|
|
1170
1317
|
return new CloudClient({
|
|
1171
|
-
baseURL:
|
|
1318
|
+
baseURL: CLOUD_ENDPOINTS.MAIN.BASE_URL,
|
|
1172
1319
|
timeout: 1e4,
|
|
1173
1320
|
version: CCJK_VERSION,
|
|
1174
1321
|
enableCache: true,
|
|
@@ -1336,7 +1483,7 @@ class TelemetryReporter {
|
|
|
1336
1483
|
constructor(client, config = {}) {
|
|
1337
1484
|
this.client = client;
|
|
1338
1485
|
this.config = { ...DEFAULT_TELEMETRY_CONFIG, ...config };
|
|
1339
|
-
this.userId = this.config.userId || this.generateUserId();
|
|
1486
|
+
this.userId = this.config.userId || this.client.getIdentity().anonymousUserId || this.generateUserId();
|
|
1340
1487
|
if (this.config.enabled) {
|
|
1341
1488
|
this.startFlushTimer();
|
|
1342
1489
|
}
|
|
@@ -1577,6 +1724,11 @@ function initializeTelemetry(client, config) {
|
|
|
1577
1724
|
});
|
|
1578
1725
|
}
|
|
1579
1726
|
globalTelemetry = new TelemetryReporter(client, config);
|
|
1727
|
+
if (client.getConfig().autoHandshake !== false && client.getConfig().enableUsageAnalytics !== false) {
|
|
1728
|
+
client.handshake().catch((error) => {
|
|
1729
|
+
consola.debug("Failed to send startup handshake (non-blocking):", error);
|
|
1730
|
+
});
|
|
1731
|
+
}
|
|
1580
1732
|
return globalTelemetry;
|
|
1581
1733
|
}
|
|
1582
1734
|
function getTelemetry() {
|
|
@@ -1679,6 +1831,15 @@ class FallbackCloudClient {
|
|
|
1679
1831
|
async reportUsage(report) {
|
|
1680
1832
|
return this.client.reportUsage(report);
|
|
1681
1833
|
}
|
|
1834
|
+
async registerDevice(payload) {
|
|
1835
|
+
return this.client.registerDevice(payload);
|
|
1836
|
+
}
|
|
1837
|
+
async handshake(payload) {
|
|
1838
|
+
return this.client.handshake(payload);
|
|
1839
|
+
}
|
|
1840
|
+
async syncClientUsage(payload) {
|
|
1841
|
+
return this.client.syncClientUsage(payload);
|
|
1842
|
+
}
|
|
1682
1843
|
/**
|
|
1683
1844
|
* Health check (no fallback)
|
|
1684
1845
|
*/
|
|
@@ -44,13 +44,13 @@ const ROUTE_MAP = {
|
|
|
44
44
|
},
|
|
45
45
|
// Notification endpoints (remote API)
|
|
46
46
|
"notifications.bind": {
|
|
47
|
-
v1: "/bind/use"
|
|
47
|
+
v1: "/api/v1/bind/use"
|
|
48
48
|
},
|
|
49
49
|
"notifications.send": {
|
|
50
|
-
v1: "/notify"
|
|
50
|
+
v1: "/api/v1/notify"
|
|
51
51
|
},
|
|
52
52
|
"notifications.poll": {
|
|
53
|
-
v1: "/reply/poll"
|
|
53
|
+
v1: "/api/v1/reply/poll"
|
|
54
54
|
}
|
|
55
55
|
};
|
|
56
56
|
class CloudApiGateway {
|
|
@@ -2,6 +2,7 @@ import { promises, existsSync } from 'node:fs';
|
|
|
2
2
|
import posix from '../chunks/index8.mjs';
|
|
3
3
|
import { glob } from 'tinyglobby';
|
|
4
4
|
import { p as parse } from './ccjk.BBtCGd_g.mjs';
|
|
5
|
+
import { CLOUD_ENDPOINTS } from '../chunks/constants.mjs';
|
|
5
6
|
|
|
6
7
|
const LogLevels = {
|
|
7
8
|
fatal: 0,
|
|
@@ -3667,7 +3668,7 @@ class TemplatesClient {
|
|
|
3667
3668
|
language;
|
|
3668
3669
|
logger = consola.withTag("templates-client");
|
|
3669
3670
|
constructor(config = {}) {
|
|
3670
|
-
this.baseURL = config.baseURL ||
|
|
3671
|
+
this.baseURL = config.baseURL || CLOUD_ENDPOINTS.MAIN.BASE_URL;
|
|
3671
3672
|
this.language = config.language || "en";
|
|
3672
3673
|
this.fetch = ofetch.create({
|
|
3673
3674
|
baseURL: this.baseURL,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ccjk",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "13.
|
|
4
|
+
"version": "13.5.0",
|
|
5
5
|
"packageManager": "pnpm@10.17.1",
|
|
6
6
|
"description": "Turn Claude Code into a production-ready AI dev environment with one-command setup, persistent memory, MCP automation, cloud sync, and zero-config browser workflows.",
|
|
7
7
|
"author": {
|