ccjk 12.0.7 → 12.0.8
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/package.json +1 -1
- package/dist/chunks/agent-teams.mjs +0 -136
- package/dist/chunks/agent.mjs +0 -1439
- package/dist/chunks/agents.mjs +0 -3778
- package/dist/chunks/api-cli.mjs +0 -132
- package/dist/chunks/api-providers.mjs +0 -129
- package/dist/chunks/api.mjs +0 -112
- package/dist/chunks/auto-bootstrap.mjs +0 -358
- package/dist/chunks/auto-init.mjs +0 -7584
- package/dist/chunks/auto-updater.mjs +0 -410
- package/dist/chunks/banner.mjs +0 -188
- package/dist/chunks/bash.mjs +0 -187
- package/dist/chunks/boost.mjs +0 -397
- package/dist/chunks/ccjk-agents.mjs +0 -414
- package/dist/chunks/ccjk-all.mjs +0 -1028
- package/dist/chunks/ccjk-config.mjs +0 -261
- package/dist/chunks/ccjk-hooks.mjs +0 -1074
- package/dist/chunks/ccjk-mcp.mjs +0 -761
- package/dist/chunks/ccjk-setup.mjs +0 -763
- package/dist/chunks/ccjk-skills.mjs +0 -514
- package/dist/chunks/ccr.mjs +0 -98
- package/dist/chunks/ccu.mjs +0 -40
- package/dist/chunks/check-updates.mjs +0 -108
- package/dist/chunks/claude-code-config-manager.mjs +0 -750
- package/dist/chunks/claude-code-incremental-manager.mjs +0 -623
- package/dist/chunks/claude-config.mjs +0 -236
- package/dist/chunks/claude-wrapper.mjs +0 -85
- package/dist/chunks/cleanup-migration.mjs +0 -20
- package/dist/chunks/cli-hook.mjs +0 -2285
- package/dist/chunks/cloud-sync.mjs +0 -29
- package/dist/chunks/codex-config-switch.mjs +0 -451
- package/dist/chunks/codex-provider-manager.mjs +0 -236
- package/dist/chunks/codex-uninstaller.mjs +0 -404
- package/dist/chunks/codex.mjs +0 -2077
- package/dist/chunks/commands.mjs +0 -108
- package/dist/chunks/commands2.mjs +0 -413
- package/dist/chunks/commit.mjs +0 -138
- package/dist/chunks/completion.mjs +0 -515
- package/dist/chunks/config-consolidator.mjs +0 -172
- package/dist/chunks/config-switch.mjs +0 -317
- package/dist/chunks/config.mjs +0 -379
- package/dist/chunks/config2.mjs +0 -477
- package/dist/chunks/config3.mjs +0 -470
- package/dist/chunks/constants.mjs +0 -133
- package/dist/chunks/context-loader.mjs +0 -343
- package/dist/chunks/context.mjs +0 -372
- package/dist/chunks/convoy-manager.mjs +0 -880
- package/dist/chunks/dashboard.mjs +0 -476
- package/dist/chunks/doctor.mjs +0 -964
- package/dist/chunks/evolution.mjs +0 -382
- package/dist/chunks/features.mjs +0 -698
- package/dist/chunks/fish.mjs +0 -181
- package/dist/chunks/fs-operations.mjs +0 -192
- package/dist/chunks/health-alerts.mjs +0 -304
- package/dist/chunks/health-check.mjs +0 -532
- package/dist/chunks/help.mjs +0 -340
- package/dist/chunks/hook-installer.mjs +0 -45
- package/dist/chunks/index.mjs +0 -24
- package/dist/chunks/index10.mjs +0 -1171
- package/dist/chunks/index11.mjs +0 -1008
- package/dist/chunks/index12.mjs +0 -193
- package/dist/chunks/index13.mjs +0 -218
- package/dist/chunks/index14.mjs +0 -663
- package/dist/chunks/index2.mjs +0 -19
- package/dist/chunks/index3.mjs +0 -19092
- package/dist/chunks/index4.mjs +0 -8
- package/dist/chunks/index5.mjs +0 -7600
- package/dist/chunks/index6.mjs +0 -171
- package/dist/chunks/index7.mjs +0 -3583
- package/dist/chunks/index8.mjs +0 -19
- package/dist/chunks/index9.mjs +0 -616
- package/dist/chunks/init.mjs +0 -1606
- package/dist/chunks/installer.mjs +0 -690
- package/dist/chunks/installer2.mjs +0 -179
- package/dist/chunks/interview.mjs +0 -2927
- package/dist/chunks/json-config.mjs +0 -60
- package/dist/chunks/linux.mjs +0 -3863
- package/dist/chunks/macos.mjs +0 -69
- package/dist/chunks/main.mjs +0 -635
- package/dist/chunks/manager.mjs +0 -1048
- package/dist/chunks/marketplace.mjs +0 -949
- package/dist/chunks/mcp-cli.mjs +0 -204
- package/dist/chunks/mcp-performance.mjs +0 -187
- package/dist/chunks/mcp.mjs +0 -1231
- package/dist/chunks/menu.mjs +0 -652
- package/dist/chunks/metrics-display.mjs +0 -153
- package/dist/chunks/migrator.mjs +0 -178
- package/dist/chunks/monitor.mjs +0 -1856
- package/dist/chunks/notification.mjs +0 -1864
- package/dist/chunks/onboarding.mjs +0 -385
- package/dist/chunks/package.mjs +0 -3
- package/dist/chunks/paradigm.mjs +0 -74
- package/dist/chunks/permission-manager.mjs +0 -132
- package/dist/chunks/permissions.mjs +0 -265
- package/dist/chunks/persistence-manager.mjs +0 -794
- package/dist/chunks/persistence.mjs +0 -667
- package/dist/chunks/platform.mjs +0 -391
- package/dist/chunks/plugin.mjs +0 -1936
- package/dist/chunks/powershell.mjs +0 -213
- package/dist/chunks/prompts.mjs +0 -241
- package/dist/chunks/providers.mjs +0 -260
- package/dist/chunks/quick-actions.mjs +0 -320
- package/dist/chunks/quick-provider.mjs +0 -682
- package/dist/chunks/quick-setup.mjs +0 -412
- package/dist/chunks/remote.mjs +0 -497
- package/dist/chunks/session.mjs +0 -878
- package/dist/chunks/sessions.mjs +0 -106
- package/dist/chunks/silent-updater.mjs +0 -396
- package/dist/chunks/simple-config.mjs +0 -98
- package/dist/chunks/skill.mjs +0 -117
- package/dist/chunks/skill2.mjs +0 -9003
- package/dist/chunks/skills-sync.mjs +0 -6460
- package/dist/chunks/skills.mjs +0 -567
- package/dist/chunks/slash-commands.mjs +0 -207
- package/dist/chunks/smart-defaults.mjs +0 -412
- package/dist/chunks/smart-guide.mjs +0 -194
- package/dist/chunks/startup.mjs +0 -487
- package/dist/chunks/stats.mjs +0 -410
- package/dist/chunks/status.mjs +0 -289
- package/dist/chunks/team.mjs +0 -63
- package/dist/chunks/thinking.mjs +0 -626
- package/dist/chunks/trace.mjs +0 -57
- package/dist/chunks/uninstall.mjs +0 -849
- package/dist/chunks/update.mjs +0 -167
- package/dist/chunks/upgrade-manager.mjs +0 -204
- package/dist/chunks/version-checker.mjs +0 -881
- package/dist/chunks/vim.mjs +0 -903
- package/dist/chunks/windows.mjs +0 -14
- package/dist/chunks/workflows.mjs +0 -633
- package/dist/chunks/wsl.mjs +0 -129
- package/dist/chunks/zero-config.mjs +0 -374
- package/dist/chunks/zsh.mjs +0 -182
- package/dist/cli.d.mts +0 -1
- package/dist/cli.d.ts +0 -1
- package/dist/cli.mjs +0 -2199
- package/dist/i18n/locales/en/agent-teams.json +0 -18
- package/dist/i18n/locales/en/agentBrowser.json +0 -79
- package/dist/i18n/locales/en/agents.json +0 -135
- package/dist/i18n/locales/en/api.json +0 -63
- package/dist/i18n/locales/en/ccjk-agents.json +0 -33
- package/dist/i18n/locales/en/ccjk-all.json +0 -23
- package/dist/i18n/locales/en/ccjk-skills.json +0 -22
- package/dist/i18n/locales/en/ccjk.json +0 -276
- package/dist/i18n/locales/en/ccr.json +0 -65
- package/dist/i18n/locales/en/claude-md.json +0 -73
- package/dist/i18n/locales/en/cli.json +0 -152
- package/dist/i18n/locales/en/cloud-setup.json +0 -31
- package/dist/i18n/locales/en/cloud-sync.json +0 -147
- package/dist/i18n/locales/en/cloud.json +0 -40
- package/dist/i18n/locales/en/cloudPlugins.json +0 -118
- package/dist/i18n/locales/en/codex.json +0 -127
- package/dist/i18n/locales/en/cometix.json +0 -29
- package/dist/i18n/locales/en/common.json +0 -68
- package/dist/i18n/locales/en/config.json +0 -108
- package/dist/i18n/locales/en/configuration.json +0 -226
- package/dist/i18n/locales/en/context.json +0 -85
- package/dist/i18n/locales/en/dashboard.json +0 -78
- package/dist/i18n/locales/en/errors.json +0 -26
- package/dist/i18n/locales/en/evolution.json +0 -54
- package/dist/i18n/locales/en/hooks.json +0 -74
- package/dist/i18n/locales/en/hooksSync.json +0 -133
- package/dist/i18n/locales/en/installation.json +0 -83
- package/dist/i18n/locales/en/interview.json +0 -104
- package/dist/i18n/locales/en/language.json +0 -19
- package/dist/i18n/locales/en/lsp.json +0 -78
- package/dist/i18n/locales/en/marketplace.json +0 -116
- package/dist/i18n/locales/en/mcp.json +0 -178
- package/dist/i18n/locales/en/memory.json +0 -92
- package/dist/i18n/locales/en/menu.json +0 -143
- package/dist/i18n/locales/en/multi-config.json +0 -79
- package/dist/i18n/locales/en/notification.json +0 -307
- package/dist/i18n/locales/en/permissions.json +0 -95
- package/dist/i18n/locales/en/persistence.json +0 -127
- package/dist/i18n/locales/en/plugins.json +0 -146
- package/dist/i18n/locales/en/quick-actions.json +0 -78
- package/dist/i18n/locales/en/registry.json +0 -54
- package/dist/i18n/locales/en/remote.json +0 -93
- package/dist/i18n/locales/en/sandbox.json +0 -44
- package/dist/i18n/locales/en/setup.json +0 -44
- package/dist/i18n/locales/en/shencha.json +0 -14
- package/dist/i18n/locales/en/skills.json +0 -100
- package/dist/i18n/locales/en/skillsSync.json +0 -74
- package/dist/i18n/locales/en/smartGuide.json +0 -49
- package/dist/i18n/locales/en/stats.json +0 -20
- package/dist/i18n/locales/en/subagent.json +0 -69
- package/dist/i18n/locales/en/superpowers.json +0 -117
- package/dist/i18n/locales/en/team.json +0 -7
- package/dist/i18n/locales/en/thinking.json +0 -65
- package/dist/i18n/locales/en/tools.json +0 -42
- package/dist/i18n/locales/en/uninstall.json +0 -56
- package/dist/i18n/locales/en/updater.json +0 -29
- package/dist/i18n/locales/en/vim.json +0 -169
- package/dist/i18n/locales/en/workflow.json +0 -55
- package/dist/i18n/locales/en/workspace.json +0 -108
- package/dist/i18n/locales/zh-CN/agent-teams.json +0 -18
- package/dist/i18n/locales/zh-CN/agentBrowser.json +0 -79
- package/dist/i18n/locales/zh-CN/agents.json +0 -135
- package/dist/i18n/locales/zh-CN/api.json +0 -63
- package/dist/i18n/locales/zh-CN/ccjk-agents.json +0 -33
- package/dist/i18n/locales/zh-CN/ccjk-all.json +0 -23
- package/dist/i18n/locales/zh-CN/ccjk-skills.json +0 -22
- package/dist/i18n/locales/zh-CN/ccjk.json +0 -276
- package/dist/i18n/locales/zh-CN/ccr.json +0 -65
- package/dist/i18n/locales/zh-CN/claude-md.json +0 -73
- package/dist/i18n/locales/zh-CN/cli.json +0 -152
- package/dist/i18n/locales/zh-CN/cloud-setup.json +0 -31
- package/dist/i18n/locales/zh-CN/cloud-sync.json +0 -147
- package/dist/i18n/locales/zh-CN/cloud.json +0 -40
- package/dist/i18n/locales/zh-CN/cloudPlugins.json +0 -118
- package/dist/i18n/locales/zh-CN/codex.json +0 -127
- package/dist/i18n/locales/zh-CN/cometix.json +0 -29
- package/dist/i18n/locales/zh-CN/common.json +0 -68
- package/dist/i18n/locales/zh-CN/config.json +0 -108
- package/dist/i18n/locales/zh-CN/configuration.json +0 -224
- package/dist/i18n/locales/zh-CN/context.json +0 -85
- package/dist/i18n/locales/zh-CN/dashboard.json +0 -78
- package/dist/i18n/locales/zh-CN/errors.json +0 -26
- package/dist/i18n/locales/zh-CN/evolution.json +0 -54
- package/dist/i18n/locales/zh-CN/hooks.json +0 -74
- package/dist/i18n/locales/zh-CN/hooksSync.json +0 -133
- package/dist/i18n/locales/zh-CN/installation.json +0 -83
- package/dist/i18n/locales/zh-CN/interview.json +0 -104
- package/dist/i18n/locales/zh-CN/language.json +0 -19
- package/dist/i18n/locales/zh-CN/lsp.json +0 -78
- package/dist/i18n/locales/zh-CN/marketplace.json +0 -116
- package/dist/i18n/locales/zh-CN/mcp.json +0 -178
- package/dist/i18n/locales/zh-CN/memory.json +0 -92
- package/dist/i18n/locales/zh-CN/menu.json +0 -143
- package/dist/i18n/locales/zh-CN/multi-config.json +0 -79
- package/dist/i18n/locales/zh-CN/notification.json +0 -307
- package/dist/i18n/locales/zh-CN/permissions.json +0 -95
- package/dist/i18n/locales/zh-CN/persistence.json +0 -127
- package/dist/i18n/locales/zh-CN/plugins.json +0 -146
- package/dist/i18n/locales/zh-CN/quick-actions.json +0 -78
- package/dist/i18n/locales/zh-CN/registry.json +0 -54
- package/dist/i18n/locales/zh-CN/remote.json +0 -93
- package/dist/i18n/locales/zh-CN/sandbox.json +0 -44
- package/dist/i18n/locales/zh-CN/setup.json +0 -44
- package/dist/i18n/locales/zh-CN/shencha.json +0 -14
- package/dist/i18n/locales/zh-CN/skills.json +0 -100
- package/dist/i18n/locales/zh-CN/skillsSync.json +0 -74
- package/dist/i18n/locales/zh-CN/smartGuide.json +0 -49
- package/dist/i18n/locales/zh-CN/stats.json +0 -20
- package/dist/i18n/locales/zh-CN/subagent.json +0 -69
- package/dist/i18n/locales/zh-CN/superpowers.json +0 -117
- package/dist/i18n/locales/zh-CN/team.json +0 -7
- package/dist/i18n/locales/zh-CN/thinking.json +0 -65
- package/dist/i18n/locales/zh-CN/tools.json +0 -42
- package/dist/i18n/locales/zh-CN/uninstall.json +0 -56
- package/dist/i18n/locales/zh-CN/updater.json +0 -29
- package/dist/i18n/locales/zh-CN/vim.json +0 -169
- package/dist/i18n/locales/zh-CN/workflow.json +0 -55
- package/dist/i18n/locales/zh-CN/workspace.json +0 -108
- package/dist/index.d.mts +0 -5295
- package/dist/index.d.ts +0 -5295
- package/dist/index.mjs +0 -4941
- package/dist/shared/ccjk.B364Fu0N.mjs +0 -1819
- package/dist/shared/ccjk.BAGoDD49.mjs +0 -36
- package/dist/shared/ccjk.BBtCGd_g.mjs +0 -899
- package/dist/shared/ccjk.BFQ7yr5S.mjs +0 -16
- package/dist/shared/ccjk.BFxsJM0k.mjs +0 -599
- package/dist/shared/ccjk.BIxuVL3_.mjs +0 -25
- package/dist/shared/ccjk.BRZ9ww8S.mjs +0 -142
- package/dist/shared/ccjk.BoApaI4j.mjs +0 -28
- package/dist/shared/ccjk.BrPUmTqm.mjs +0 -266
- package/dist/shared/ccjk.BtB1e5jm.mjs +0 -171
- package/dist/shared/ccjk.BwfbSKN2.mjs +0 -1051
- package/dist/shared/ccjk.BxSmJ8B7.mjs +0 -243
- package/dist/shared/ccjk.Bx_rmYfN.mjs +0 -69
- package/dist/shared/ccjk.C2jHOZVP.mjs +0 -52
- package/dist/shared/ccjk.CL4Yat0G.mjs +0 -303
- package/dist/shared/ccjk.COweQ1RR.mjs +0 -5
- package/dist/shared/ccjk.CePkJq2S.mjs +0 -223
- package/dist/shared/ccjk.CfKKcvWy.mjs +0 -126
- package/dist/shared/ccjk.Cjgrln_h.mjs +0 -297
- package/dist/shared/ccjk.Cjj8SVrn.mjs +0 -54
- package/dist/shared/ccjk.CxpGa6MC.mjs +0 -2724
- package/dist/shared/ccjk.D5MFQT7w.mjs +0 -400
- package/dist/shared/ccjk.D6ycHbak.mjs +0 -270
- package/dist/shared/ccjk.D8ZLYSZZ.mjs +0 -299
- package/dist/shared/ccjk.DG_o24cZ.mjs +0 -88
- package/dist/shared/ccjk.DLLw-h4Y.mjs +0 -460
- package/dist/shared/ccjk.DOwtZMk8.mjs +0 -4019
- package/dist/shared/ccjk.DS7UESmF.mjs +0 -2451
- package/dist/shared/ccjk.DTdjs-qK.mjs +0 -1447
- package/dist/shared/ccjk.DXRAZcix.mjs +0 -66
- package/dist/shared/ccjk.DsYaCCx4.mjs +0 -317
- package/dist/shared/ccjk.J8YiPsOw.mjs +0 -259
- package/dist/shared/ccjk.KfSWcGlE.mjs +0 -38
- package/dist/shared/ccjk.RyizuzOI.mjs +0 -21
- package/dist/shared/ccjk.SPoXMvZD.mjs +0 -1242
- package/dist/shared/ccjk.T_cX87dY.mjs +0 -15
- package/dist/shared/ccjk.UIvifqNE.mjs +0 -1486
- package/dist/shared/ccjk._dESH4Rk.mjs +0 -111
- package/dist/shared/ccjk.bQ7Dh1g4.mjs +0 -249
- package/dist/shared/ccjk.c-ETfBZ_.mjs +0 -617
- package/dist/shared/ccjk.gDEDGD_t.mjs +0 -38
- package/dist/shared/ccjk.hoqrwWdN.mjs +0 -333
- package/dist/shared/ccjk.waa2ikKJ.mjs +0 -351
|
@@ -1,400 +0,0 @@
|
|
|
1
|
-
import { existsSync, readdirSync, statSync, readFileSync } from 'node:fs';
|
|
2
|
-
import { CLAUDE_AGENTS_DIR, SETTINGS_FILE, CCJK_SKILLS_DIR } from '../chunks/constants.mjs';
|
|
3
|
-
import { j as join } from './ccjk.bQ7Dh1g4.mjs';
|
|
4
|
-
import process__default from 'node:process';
|
|
5
|
-
|
|
6
|
-
const agentsCheck = {
|
|
7
|
-
name: "Agents",
|
|
8
|
-
weight: 4,
|
|
9
|
-
async check() {
|
|
10
|
-
try {
|
|
11
|
-
if (!existsSync(CLAUDE_AGENTS_DIR)) {
|
|
12
|
-
return {
|
|
13
|
-
name: this.name,
|
|
14
|
-
status: "warn",
|
|
15
|
-
score: 30,
|
|
16
|
-
weight: this.weight,
|
|
17
|
-
message: "No agents directory",
|
|
18
|
-
fix: "Create agents for specialized tasks",
|
|
19
|
-
command: "ccjk ccjk:agents --list"
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
const files = readdirSync(CLAUDE_AGENTS_DIR).filter((f) => f.endsWith(".md"));
|
|
23
|
-
const agentCount = files.length;
|
|
24
|
-
if (agentCount === 0) {
|
|
25
|
-
return {
|
|
26
|
-
name: this.name,
|
|
27
|
-
status: "warn",
|
|
28
|
-
score: 30,
|
|
29
|
-
weight: this.weight,
|
|
30
|
-
message: "No agents configured",
|
|
31
|
-
fix: "Create agents for your project",
|
|
32
|
-
command: "ccjk ccjk:agents"
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
const score = Math.min(100, 40 + agentCount * 15);
|
|
36
|
-
return {
|
|
37
|
-
name: this.name,
|
|
38
|
-
status: score >= 60 ? "pass" : "warn",
|
|
39
|
-
score,
|
|
40
|
-
weight: this.weight,
|
|
41
|
-
message: `${agentCount} agent${agentCount > 1 ? "s" : ""} configured`,
|
|
42
|
-
details: files.slice(0, 5).map((f) => ` ${f.replace(".md", "")}`)
|
|
43
|
-
};
|
|
44
|
-
} catch {
|
|
45
|
-
return { name: this.name, status: "fail", score: 0, weight: this.weight, message: "Failed to read agents" };
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
const claudeMdCheck = {
|
|
51
|
-
name: "CLAUDE.md",
|
|
52
|
-
weight: 7,
|
|
53
|
-
async check() {
|
|
54
|
-
const cwd = process.cwd();
|
|
55
|
-
const claudeMdPath = join(cwd, "CLAUDE.md");
|
|
56
|
-
try {
|
|
57
|
-
if (!existsSync(claudeMdPath)) {
|
|
58
|
-
return {
|
|
59
|
-
name: this.name,
|
|
60
|
-
status: "fail",
|
|
61
|
-
score: 0,
|
|
62
|
-
weight: this.weight,
|
|
63
|
-
message: "No CLAUDE.md in project root",
|
|
64
|
-
fix: "Create CLAUDE.md for project-specific AI instructions",
|
|
65
|
-
command: "ccjk init --smart"
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
const stat = statSync(claudeMdPath);
|
|
69
|
-
const content = readFileSync(claudeMdPath, "utf-8");
|
|
70
|
-
const lines = content.split("\n").length;
|
|
71
|
-
const sizeKb = Math.round(stat.size / 1024);
|
|
72
|
-
const hasHeaders = (content.match(/^#{1,3}\s/gm) || []).length;
|
|
73
|
-
const hasCodeBlocks = (content.match(/```/g) || []).length / 2;
|
|
74
|
-
const hasBuildCommands = /build|test|lint|dev/i.test(content);
|
|
75
|
-
let score = 40;
|
|
76
|
-
if (lines > 20) score += 15;
|
|
77
|
-
if (hasHeaders >= 3) score += 15;
|
|
78
|
-
if (hasCodeBlocks >= 1) score += 10;
|
|
79
|
-
if (hasBuildCommands) score += 20;
|
|
80
|
-
score = Math.min(100, score);
|
|
81
|
-
return {
|
|
82
|
-
name: this.name,
|
|
83
|
-
status: score >= 60 ? "pass" : "warn",
|
|
84
|
-
score,
|
|
85
|
-
weight: this.weight,
|
|
86
|
-
message: `${lines} lines, ${sizeKb}KB`,
|
|
87
|
-
details: [
|
|
88
|
-
` Sections: ${hasHeaders}`,
|
|
89
|
-
` Code blocks: ${Math.floor(hasCodeBlocks)}`,
|
|
90
|
-
` Build info: ${hasBuildCommands ? "yes" : "no"}`
|
|
91
|
-
],
|
|
92
|
-
...score < 80 && { fix: "Enrich CLAUDE.md with more project context", command: "ccjk init --smart" }
|
|
93
|
-
};
|
|
94
|
-
} catch {
|
|
95
|
-
return { name: this.name, status: "fail", score: 0, weight: this.weight, message: "Failed to read CLAUDE.md" };
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
const mcpCheck = {
|
|
101
|
-
name: "MCP Services",
|
|
102
|
-
weight: 8,
|
|
103
|
-
async check() {
|
|
104
|
-
try {
|
|
105
|
-
if (!existsSync(SETTINGS_FILE)) {
|
|
106
|
-
return {
|
|
107
|
-
name: this.name,
|
|
108
|
-
status: "fail",
|
|
109
|
-
score: 0,
|
|
110
|
-
weight: this.weight,
|
|
111
|
-
message: "No settings.json found",
|
|
112
|
-
fix: "Run ccjk init to create settings",
|
|
113
|
-
command: "ccjk init"
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
const settings = JSON.parse(readFileSync(SETTINGS_FILE, "utf-8"));
|
|
117
|
-
const mcpServers = settings.mcpServers || {};
|
|
118
|
-
const serverCount = Object.keys(mcpServers).length;
|
|
119
|
-
if (serverCount === 0) {
|
|
120
|
-
return {
|
|
121
|
-
name: this.name,
|
|
122
|
-
status: "fail",
|
|
123
|
-
score: 0,
|
|
124
|
-
weight: this.weight,
|
|
125
|
-
message: "No MCP services configured",
|
|
126
|
-
fix: "Install MCP services for enhanced capabilities",
|
|
127
|
-
command: "ccjk ccjk:mcp"
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
|
-
const essentialServices = ["context7"];
|
|
131
|
-
const hasEssentials = essentialServices.filter(
|
|
132
|
-
(s) => Object.keys(mcpServers).some((k) => k.toLowerCase().includes(s))
|
|
133
|
-
);
|
|
134
|
-
const score = Math.min(100, serverCount * 20 + hasEssentials.length * 20);
|
|
135
|
-
const status = score >= 60 ? "pass" : "warn";
|
|
136
|
-
const details = Object.keys(mcpServers).map((name) => ` ${name}`);
|
|
137
|
-
return {
|
|
138
|
-
name: this.name,
|
|
139
|
-
status,
|
|
140
|
-
score,
|
|
141
|
-
weight: this.weight,
|
|
142
|
-
message: `${serverCount} service${serverCount > 1 ? "s" : ""} active`,
|
|
143
|
-
details,
|
|
144
|
-
...score < 80 && { fix: "Add more MCP services", command: "ccjk ccjk:mcp" }
|
|
145
|
-
};
|
|
146
|
-
} catch {
|
|
147
|
-
return {
|
|
148
|
-
name: this.name,
|
|
149
|
-
status: "fail",
|
|
150
|
-
score: 0,
|
|
151
|
-
weight: this.weight,
|
|
152
|
-
message: "Failed to read MCP configuration",
|
|
153
|
-
command: "ccjk doctor"
|
|
154
|
-
};
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
};
|
|
158
|
-
|
|
159
|
-
const modelCheck = {
|
|
160
|
-
name: "Default Model",
|
|
161
|
-
weight: 5,
|
|
162
|
-
async check() {
|
|
163
|
-
try {
|
|
164
|
-
if (!existsSync(SETTINGS_FILE)) {
|
|
165
|
-
return {
|
|
166
|
-
name: this.name,
|
|
167
|
-
status: "fail",
|
|
168
|
-
score: 0,
|
|
169
|
-
weight: this.weight,
|
|
170
|
-
message: "No settings file",
|
|
171
|
-
command: "ccjk init"
|
|
172
|
-
};
|
|
173
|
-
}
|
|
174
|
-
const settings = JSON.parse(readFileSync(SETTINGS_FILE, "utf-8"));
|
|
175
|
-
const hasModel = settings.model || settings.defaultModel || settings.preferredModel;
|
|
176
|
-
const hasApiKey = settings.apiKey || settings.env?.ANTHROPIC_API_KEY || process__default.env.ANTHROPIC_API_KEY;
|
|
177
|
-
if (!hasApiKey) {
|
|
178
|
-
return {
|
|
179
|
-
name: this.name,
|
|
180
|
-
status: "warn",
|
|
181
|
-
score: 40,
|
|
182
|
-
weight: this.weight,
|
|
183
|
-
message: "No API key configured (using default)",
|
|
184
|
-
fix: "Configure API for direct access",
|
|
185
|
-
command: "ccjk menu",
|
|
186
|
-
details: [" Using Claude Code default API"]
|
|
187
|
-
};
|
|
188
|
-
}
|
|
189
|
-
return {
|
|
190
|
-
name: this.name,
|
|
191
|
-
status: "pass",
|
|
192
|
-
score: hasModel ? 100 : 70,
|
|
193
|
-
weight: this.weight,
|
|
194
|
-
message: hasModel ? `Model: ${hasModel}` : "API configured (default model)"
|
|
195
|
-
};
|
|
196
|
-
} catch {
|
|
197
|
-
return { name: this.name, status: "fail", score: 0, weight: this.weight, message: "Failed to read model config" };
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
};
|
|
201
|
-
|
|
202
|
-
const INVALID_PERMISSION_NAMES = /* @__PURE__ */ new Set([
|
|
203
|
-
"AllowEdit",
|
|
204
|
-
"AllowWrite",
|
|
205
|
-
"AllowRead",
|
|
206
|
-
"AllowExec",
|
|
207
|
-
"AllowCreateProcess",
|
|
208
|
-
"AllowKillProcess",
|
|
209
|
-
"AllowNetworkAccess",
|
|
210
|
-
"AllowFileSystemAccess",
|
|
211
|
-
"AllowShellAccess",
|
|
212
|
-
"AllowHttpAccess"
|
|
213
|
-
]);
|
|
214
|
-
function isValidPermission(perm) {
|
|
215
|
-
if (INVALID_PERMISSION_NAMES.has(perm)) return false;
|
|
216
|
-
if (["mcp__.*", "mcp__*", "mcp__(*)"].includes(perm)) return false;
|
|
217
|
-
return true;
|
|
218
|
-
}
|
|
219
|
-
const permissionsCheck = {
|
|
220
|
-
name: "Permissions",
|
|
221
|
-
weight: 3,
|
|
222
|
-
async check() {
|
|
223
|
-
try {
|
|
224
|
-
if (!existsSync(SETTINGS_FILE)) {
|
|
225
|
-
return {
|
|
226
|
-
name: this.name,
|
|
227
|
-
status: "warn",
|
|
228
|
-
score: 30,
|
|
229
|
-
weight: this.weight,
|
|
230
|
-
message: "No settings file",
|
|
231
|
-
command: "ccjk init"
|
|
232
|
-
};
|
|
233
|
-
}
|
|
234
|
-
const settings = JSON.parse(readFileSync(SETTINGS_FILE, "utf-8"));
|
|
235
|
-
const allowedTools = settings.permissions?.allow || [];
|
|
236
|
-
if (allowedTools.length === 0) {
|
|
237
|
-
return {
|
|
238
|
-
name: this.name,
|
|
239
|
-
status: "warn",
|
|
240
|
-
score: 40,
|
|
241
|
-
weight: this.weight,
|
|
242
|
-
message: "No tool permissions configured",
|
|
243
|
-
fix: "Configure permissions to reduce prompts",
|
|
244
|
-
command: "ccjk menu"
|
|
245
|
-
};
|
|
246
|
-
}
|
|
247
|
-
const invalidPerms = allowedTools.filter((p) => !isValidPermission(p));
|
|
248
|
-
const validPerms = allowedTools.filter((p) => isValidPermission(p));
|
|
249
|
-
if (invalidPerms.length > 0) {
|
|
250
|
-
return {
|
|
251
|
-
name: this.name,
|
|
252
|
-
status: "warn",
|
|
253
|
-
score: 50,
|
|
254
|
-
weight: this.weight,
|
|
255
|
-
message: `${invalidPerms.length} invalid permission(s) found (${validPerms.length} valid)`,
|
|
256
|
-
fix: "Run ccjk init to repair permissions",
|
|
257
|
-
command: "ccjk init"
|
|
258
|
-
};
|
|
259
|
-
}
|
|
260
|
-
const score = Math.min(100, 60 + validPerms.length * 2);
|
|
261
|
-
return {
|
|
262
|
-
name: this.name,
|
|
263
|
-
status: "pass",
|
|
264
|
-
score,
|
|
265
|
-
weight: this.weight,
|
|
266
|
-
message: `${validPerms.length} valid permission${validPerms.length > 1 ? "s" : ""} configured`
|
|
267
|
-
};
|
|
268
|
-
} catch {
|
|
269
|
-
return { name: this.name, status: "fail", score: 0, weight: this.weight, message: "Failed to read permissions" };
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
};
|
|
273
|
-
|
|
274
|
-
const skillsCheck = {
|
|
275
|
-
name: "Skills",
|
|
276
|
-
weight: 6,
|
|
277
|
-
async check() {
|
|
278
|
-
try {
|
|
279
|
-
if (!existsSync(CCJK_SKILLS_DIR)) {
|
|
280
|
-
return {
|
|
281
|
-
name: this.name,
|
|
282
|
-
status: "warn",
|
|
283
|
-
score: 20,
|
|
284
|
-
weight: this.weight,
|
|
285
|
-
message: "No skills directory found",
|
|
286
|
-
fix: "Install skills to enhance Claude Code",
|
|
287
|
-
command: "ccjk ccjk:skills"
|
|
288
|
-
};
|
|
289
|
-
}
|
|
290
|
-
const files = readdirSync(CCJK_SKILLS_DIR).filter((f) => f.endsWith(".md"));
|
|
291
|
-
const skillCount = files.length;
|
|
292
|
-
if (skillCount === 0) {
|
|
293
|
-
return {
|
|
294
|
-
name: this.name,
|
|
295
|
-
status: "warn",
|
|
296
|
-
score: 20,
|
|
297
|
-
weight: this.weight,
|
|
298
|
-
message: "No skills installed",
|
|
299
|
-
fix: "Install skills based on your project",
|
|
300
|
-
command: "ccjk ccjk:skills"
|
|
301
|
-
};
|
|
302
|
-
}
|
|
303
|
-
const score = Math.min(100, 30 + skillCount * 10);
|
|
304
|
-
return {
|
|
305
|
-
name: this.name,
|
|
306
|
-
status: score >= 60 ? "pass" : "warn",
|
|
307
|
-
score,
|
|
308
|
-
weight: this.weight,
|
|
309
|
-
message: `${skillCount} skill${skillCount > 1 ? "s" : ""} installed`,
|
|
310
|
-
details: files.slice(0, 8).map((f) => ` ${f.replace(".md", "")}`),
|
|
311
|
-
...skillCount < 5 && { fix: "Install more project-specific skills", command: "ccjk ccjk:skills" }
|
|
312
|
-
};
|
|
313
|
-
} catch {
|
|
314
|
-
return { name: this.name, status: "fail", score: 0, weight: this.weight, message: "Failed to read skills" };
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
};
|
|
318
|
-
|
|
319
|
-
const DEFAULT_CHECKS = [
|
|
320
|
-
mcpCheck,
|
|
321
|
-
skillsCheck,
|
|
322
|
-
claudeMdCheck,
|
|
323
|
-
modelCheck,
|
|
324
|
-
agentsCheck,
|
|
325
|
-
permissionsCheck
|
|
326
|
-
];
|
|
327
|
-
function calculateGrade(score) {
|
|
328
|
-
if (score >= 95) return "S";
|
|
329
|
-
if (score >= 80) return "A";
|
|
330
|
-
if (score >= 65) return "B";
|
|
331
|
-
if (score >= 50) return "C";
|
|
332
|
-
if (score >= 30) return "D";
|
|
333
|
-
return "F";
|
|
334
|
-
}
|
|
335
|
-
function generateRecommendations(results) {
|
|
336
|
-
const recs = [];
|
|
337
|
-
for (const r of results) {
|
|
338
|
-
if (r.status === "fail" && r.command) {
|
|
339
|
-
recs.push({
|
|
340
|
-
priority: "high",
|
|
341
|
-
title: `Fix: ${r.name}`,
|
|
342
|
-
description: r.fix || r.message,
|
|
343
|
-
command: r.command,
|
|
344
|
-
category: mapCategory(r.name)
|
|
345
|
-
});
|
|
346
|
-
} else if (r.status === "warn" && r.command) {
|
|
347
|
-
recs.push({
|
|
348
|
-
priority: "medium",
|
|
349
|
-
title: `Improve: ${r.name}`,
|
|
350
|
-
description: r.fix || r.message,
|
|
351
|
-
command: r.command,
|
|
352
|
-
category: mapCategory(r.name)
|
|
353
|
-
});
|
|
354
|
-
}
|
|
355
|
-
}
|
|
356
|
-
const priorityOrder = { high: 0, medium: 1, low: 2 };
|
|
357
|
-
recs.sort((a, b) => priorityOrder[a.priority] - priorityOrder[b.priority]);
|
|
358
|
-
return recs;
|
|
359
|
-
}
|
|
360
|
-
function mapCategory(name) {
|
|
361
|
-
const lower = name.toLowerCase();
|
|
362
|
-
if (lower.includes("mcp")) return "mcp";
|
|
363
|
-
if (lower.includes("skill")) return "skills";
|
|
364
|
-
if (lower.includes("agent")) return "agents";
|
|
365
|
-
if (lower.includes("model") || lower.includes("api")) return "model";
|
|
366
|
-
if (lower.includes("sync")) return "sync";
|
|
367
|
-
if (lower.includes("perm")) return "permissions";
|
|
368
|
-
return "general";
|
|
369
|
-
}
|
|
370
|
-
async function runHealthCheck(checks) {
|
|
371
|
-
const activeChecks = checks || DEFAULT_CHECKS;
|
|
372
|
-
const results = [];
|
|
373
|
-
const promises = activeChecks.map(async (check) => {
|
|
374
|
-
try {
|
|
375
|
-
return await check.check();
|
|
376
|
-
} catch {
|
|
377
|
-
return {
|
|
378
|
-
name: check.name,
|
|
379
|
-
status: "fail",
|
|
380
|
-
score: 0,
|
|
381
|
-
weight: check.weight,
|
|
382
|
-
message: "Check failed unexpectedly"
|
|
383
|
-
};
|
|
384
|
-
}
|
|
385
|
-
});
|
|
386
|
-
const settled = await Promise.all(promises);
|
|
387
|
-
results.push(...settled);
|
|
388
|
-
const totalWeight = results.reduce((sum, r) => sum + r.weight, 0);
|
|
389
|
-
const weightedSum = results.reduce((sum, r) => sum + r.score * r.weight, 0);
|
|
390
|
-
const totalScore = totalWeight > 0 ? Math.round(weightedSum / totalWeight) : 0;
|
|
391
|
-
return {
|
|
392
|
-
totalScore,
|
|
393
|
-
grade: calculateGrade(totalScore),
|
|
394
|
-
results,
|
|
395
|
-
recommendations: generateRecommendations(results),
|
|
396
|
-
timestamp: Date.now()
|
|
397
|
-
};
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
export { runHealthCheck as r };
|
|
@@ -1,270 +0,0 @@
|
|
|
1
|
-
const DEFAULT_TIMEOUT = 3e4;
|
|
2
|
-
const DEFAULT_RETRY_ATTEMPTS = 3;
|
|
3
|
-
const DEFAULT_RETRY_DELAY = 1e3;
|
|
4
|
-
class CloudApiClient {
|
|
5
|
-
baseUrl;
|
|
6
|
-
timeout;
|
|
7
|
-
authToken;
|
|
8
|
-
userAgent;
|
|
9
|
-
retry;
|
|
10
|
-
/**
|
|
11
|
-
* Create a new CloudApiClient instance
|
|
12
|
-
*
|
|
13
|
-
* @param config - Client configuration
|
|
14
|
-
*/
|
|
15
|
-
constructor(config) {
|
|
16
|
-
this.baseUrl = config.baseUrl.replace(/\/$/, "");
|
|
17
|
-
this.timeout = config.timeout || DEFAULT_TIMEOUT;
|
|
18
|
-
this.authToken = config.authToken;
|
|
19
|
-
this.userAgent = config.userAgent || "CCJK-Client/1.0";
|
|
20
|
-
this.retry = config.retry || {
|
|
21
|
-
maxAttempts: DEFAULT_RETRY_ATTEMPTS,
|
|
22
|
-
delay: DEFAULT_RETRY_DELAY
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
// ==========================================================================
|
|
26
|
-
// Configuration Methods
|
|
27
|
-
// ==========================================================================
|
|
28
|
-
/**
|
|
29
|
-
* Set authentication token
|
|
30
|
-
*
|
|
31
|
-
* @param token - Authentication token
|
|
32
|
-
*/
|
|
33
|
-
setAuthToken(token) {
|
|
34
|
-
this.authToken = token;
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Clear authentication token
|
|
38
|
-
*/
|
|
39
|
-
clearAuthToken() {
|
|
40
|
-
this.authToken = void 0;
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Get current base URL
|
|
44
|
-
*/
|
|
45
|
-
getBaseUrl() {
|
|
46
|
-
return this.baseUrl;
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Update base URL
|
|
50
|
-
*
|
|
51
|
-
* @param url - New base URL
|
|
52
|
-
*/
|
|
53
|
-
setBaseUrl(url) {
|
|
54
|
-
this.baseUrl = url.replace(/\/$/, "");
|
|
55
|
-
}
|
|
56
|
-
// ==========================================================================
|
|
57
|
-
// Request Methods
|
|
58
|
-
// ==========================================================================
|
|
59
|
-
/**
|
|
60
|
-
* Make an HTTP request to the cloud service
|
|
61
|
-
*
|
|
62
|
-
* @param path - API endpoint path (e.g., '/plugins/recommend')
|
|
63
|
-
* @param options - Request options
|
|
64
|
-
* @returns API response
|
|
65
|
-
*
|
|
66
|
-
* @example
|
|
67
|
-
* ```typescript
|
|
68
|
-
* const response = await client.request<{ data: string }>('/api/endpoint', {
|
|
69
|
-
* method: 'POST',
|
|
70
|
-
* body: { key: 'value' },
|
|
71
|
-
* timeout: 5000
|
|
72
|
-
* })
|
|
73
|
-
* ```
|
|
74
|
-
*/
|
|
75
|
-
async request(path, options) {
|
|
76
|
-
const maxAttempts = options.retry?.maxAttempts || this.retry.maxAttempts;
|
|
77
|
-
const retryDelay = options.retry?.delay || this.retry.delay;
|
|
78
|
-
let lastError = null;
|
|
79
|
-
for (let attempt = 1; attempt <= maxAttempts; attempt++) {
|
|
80
|
-
try {
|
|
81
|
-
return await this.executeRequest(path, options);
|
|
82
|
-
} catch (error) {
|
|
83
|
-
lastError = error instanceof Error ? error : new Error(String(error));
|
|
84
|
-
if (attempt === maxAttempts || this.isClientError(lastError)) {
|
|
85
|
-
break;
|
|
86
|
-
}
|
|
87
|
-
await this.sleep(retryDelay * attempt);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
return {
|
|
91
|
-
success: false,
|
|
92
|
-
error: lastError?.message || "Request failed",
|
|
93
|
-
code: "REQUEST_FAILED"
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* Execute a single HTTP request
|
|
98
|
-
*
|
|
99
|
-
* @private
|
|
100
|
-
*/
|
|
101
|
-
async executeRequest(path, options) {
|
|
102
|
-
const url = this.buildUrl(path, options.query);
|
|
103
|
-
const timeout = options.timeout || this.timeout;
|
|
104
|
-
const controller = new AbortController();
|
|
105
|
-
const timeoutId = setTimeout(() => controller.abort(), timeout);
|
|
106
|
-
try {
|
|
107
|
-
const headers = this.buildHeaders(options);
|
|
108
|
-
const response = await fetch(url, {
|
|
109
|
-
method: options.method,
|
|
110
|
-
headers,
|
|
111
|
-
body: options.body ? JSON.stringify(options.body) : void 0,
|
|
112
|
-
signal: controller.signal
|
|
113
|
-
});
|
|
114
|
-
clearTimeout(timeoutId);
|
|
115
|
-
const data = await response.json();
|
|
116
|
-
if (!response.ok) {
|
|
117
|
-
const errorMsg = typeof data.error === "object" && data.error !== null ? data.error.message || JSON.stringify(data.error) : data.error || `HTTP ${response.status}: ${response.statusText}`;
|
|
118
|
-
const errorCode = typeof data.error === "object" && data.error !== null ? data.error.code || data.code : data.code;
|
|
119
|
-
return {
|
|
120
|
-
success: false,
|
|
121
|
-
error: errorMsg,
|
|
122
|
-
code: errorCode || `HTTP_${response.status}`
|
|
123
|
-
};
|
|
124
|
-
}
|
|
125
|
-
return {
|
|
126
|
-
...data,
|
|
127
|
-
success: true
|
|
128
|
-
};
|
|
129
|
-
} catch (error) {
|
|
130
|
-
clearTimeout(timeoutId);
|
|
131
|
-
if (error instanceof Error) {
|
|
132
|
-
if (error.name === "AbortError") {
|
|
133
|
-
return {
|
|
134
|
-
success: false,
|
|
135
|
-
error: "Request timeout",
|
|
136
|
-
code: "TIMEOUT"
|
|
137
|
-
};
|
|
138
|
-
}
|
|
139
|
-
return {
|
|
140
|
-
success: false,
|
|
141
|
-
error: error.message,
|
|
142
|
-
code: "NETWORK_ERROR"
|
|
143
|
-
};
|
|
144
|
-
}
|
|
145
|
-
return {
|
|
146
|
-
success: false,
|
|
147
|
-
error: String(error),
|
|
148
|
-
code: "UNKNOWN_ERROR"
|
|
149
|
-
};
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
// ==========================================================================
|
|
153
|
-
// Convenience Methods
|
|
154
|
-
// ==========================================================================
|
|
155
|
-
/**
|
|
156
|
-
* Make a GET request
|
|
157
|
-
*
|
|
158
|
-
* @param path - API endpoint path
|
|
159
|
-
* @param query - Query parameters
|
|
160
|
-
* @param options - Additional request options
|
|
161
|
-
* @returns API response
|
|
162
|
-
*/
|
|
163
|
-
async get(path, query, options) {
|
|
164
|
-
return this.request(path, {
|
|
165
|
-
method: "GET",
|
|
166
|
-
query,
|
|
167
|
-
...options
|
|
168
|
-
});
|
|
169
|
-
}
|
|
170
|
-
/**
|
|
171
|
-
* Make a POST request
|
|
172
|
-
*
|
|
173
|
-
* @param path - API endpoint path
|
|
174
|
-
* @param body - Request body
|
|
175
|
-
* @param options - Additional request options
|
|
176
|
-
* @returns API response
|
|
177
|
-
*/
|
|
178
|
-
async post(path, body, options) {
|
|
179
|
-
return this.request(path, {
|
|
180
|
-
method: "POST",
|
|
181
|
-
body,
|
|
182
|
-
...options
|
|
183
|
-
});
|
|
184
|
-
}
|
|
185
|
-
/**
|
|
186
|
-
* Make a PUT request
|
|
187
|
-
*
|
|
188
|
-
* @param path - API endpoint path
|
|
189
|
-
* @param body - Request body
|
|
190
|
-
* @param options - Additional request options
|
|
191
|
-
* @returns API response
|
|
192
|
-
*/
|
|
193
|
-
async put(path, body, options) {
|
|
194
|
-
return this.request(path, {
|
|
195
|
-
method: "PUT",
|
|
196
|
-
body,
|
|
197
|
-
...options
|
|
198
|
-
});
|
|
199
|
-
}
|
|
200
|
-
/**
|
|
201
|
-
* Make a DELETE request
|
|
202
|
-
*
|
|
203
|
-
* @param path - API endpoint path
|
|
204
|
-
* @param options - Additional request options
|
|
205
|
-
* @returns API response
|
|
206
|
-
*/
|
|
207
|
-
async delete(path, options) {
|
|
208
|
-
return this.request(path, {
|
|
209
|
-
method: "DELETE",
|
|
210
|
-
...options
|
|
211
|
-
});
|
|
212
|
-
}
|
|
213
|
-
// ==========================================================================
|
|
214
|
-
// Helper Methods
|
|
215
|
-
// ==========================================================================
|
|
216
|
-
/**
|
|
217
|
-
* Build full URL with query parameters
|
|
218
|
-
*
|
|
219
|
-
* @private
|
|
220
|
-
*/
|
|
221
|
-
buildUrl(path, query) {
|
|
222
|
-
const url = `${this.baseUrl}${path}`;
|
|
223
|
-
if (!query || Object.keys(query).length === 0) {
|
|
224
|
-
return url;
|
|
225
|
-
}
|
|
226
|
-
const params = new URLSearchParams();
|
|
227
|
-
for (const [key, value] of Object.entries(query)) {
|
|
228
|
-
params.append(key, String(value));
|
|
229
|
-
}
|
|
230
|
-
return `${url}?${params.toString()}`;
|
|
231
|
-
}
|
|
232
|
-
/**
|
|
233
|
-
* Build request headers
|
|
234
|
-
*
|
|
235
|
-
* @private
|
|
236
|
-
*/
|
|
237
|
-
buildHeaders(options) {
|
|
238
|
-
const headers = {
|
|
239
|
-
"Content-Type": "application/json",
|
|
240
|
-
"User-Agent": this.userAgent,
|
|
241
|
-
...options.headers
|
|
242
|
-
};
|
|
243
|
-
const token = options.authToken || this.authToken;
|
|
244
|
-
if (token) {
|
|
245
|
-
headers.Authorization = `Bearer ${token}`;
|
|
246
|
-
}
|
|
247
|
-
return headers;
|
|
248
|
-
}
|
|
249
|
-
/**
|
|
250
|
-
* Check if error is a client error (4xx)
|
|
251
|
-
*
|
|
252
|
-
* @private
|
|
253
|
-
*/
|
|
254
|
-
isClientError(error) {
|
|
255
|
-
return error.message.includes("HTTP 4");
|
|
256
|
-
}
|
|
257
|
-
/**
|
|
258
|
-
* Sleep for specified milliseconds
|
|
259
|
-
*
|
|
260
|
-
* @private
|
|
261
|
-
*/
|
|
262
|
-
sleep(ms) {
|
|
263
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
function createApiClient(config) {
|
|
267
|
-
return new CloudApiClient(config);
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
export { CloudApiClient as C, createApiClient as c };
|