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,142 +0,0 @@
|
|
|
1
|
-
import fs__default, { promises } from 'node:fs';
|
|
2
|
-
import path__default from 'node:path';
|
|
3
|
-
import process__default from 'node:process';
|
|
4
|
-
import { globby } from 'globby';
|
|
5
|
-
|
|
6
|
-
function isPathInside(childPath, parentPath) {
|
|
7
|
-
const relation = path__default.relative(parentPath, childPath);
|
|
8
|
-
|
|
9
|
-
return Boolean(
|
|
10
|
-
relation &&
|
|
11
|
-
relation !== '..' &&
|
|
12
|
-
!relation.startsWith(`..${path__default.sep}`) &&
|
|
13
|
-
relation !== path__default.resolve(childPath)
|
|
14
|
-
);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
async function trash(paths, options = {}) {
|
|
18
|
-
paths = [paths].flat().map(String);
|
|
19
|
-
|
|
20
|
-
const {glob = true} = options;
|
|
21
|
-
|
|
22
|
-
if (glob) {
|
|
23
|
-
// Normalize '/**' patterns to their base directory
|
|
24
|
-
const patterns = paths.map(pattern => {
|
|
25
|
-
const isNegated = pattern.startsWith('!');
|
|
26
|
-
const body = isNegated ? pattern.slice(1) : pattern;
|
|
27
|
-
const normalized = body.endsWith('/**') ? path__default.dirname(body) : body;
|
|
28
|
-
return isNegated ? '!' + normalized : normalized;
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
const matches = await globby(patterns, {
|
|
32
|
-
expandDirectories: false,
|
|
33
|
-
onlyFiles: false,
|
|
34
|
-
followSymbolicLinks: false,
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
// Include literal paths that exist
|
|
38
|
-
const literals = await Promise.all(paths.map(async p => {
|
|
39
|
-
try {
|
|
40
|
-
await fs__default.promises.lstat(p);
|
|
41
|
-
return p;
|
|
42
|
-
} catch {
|
|
43
|
-
return null;
|
|
44
|
-
}
|
|
45
|
-
}));
|
|
46
|
-
|
|
47
|
-
paths = [...new Set([...matches, ...literals.filter(Boolean)])];
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
// Filter out nested paths and resolve
|
|
51
|
-
const pathChecks = await Promise.all(paths.map(async filePath => {
|
|
52
|
-
// Skip if nested in another path
|
|
53
|
-
if (paths.some(p => p !== filePath && isPathInside(filePath, p))) {
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
try {
|
|
58
|
-
await fs__default.promises.lstat(filePath);
|
|
59
|
-
return path__default.resolve(filePath);
|
|
60
|
-
} catch (error) {
|
|
61
|
-
// Ignore non-existent paths
|
|
62
|
-
if (error.code !== 'ENOENT') {
|
|
63
|
-
throw error;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}));
|
|
67
|
-
|
|
68
|
-
const resolvedPaths = pathChecks.filter(Boolean);
|
|
69
|
-
|
|
70
|
-
if (resolvedPaths.length === 0) {
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
const {default: trashFunction} = await platformSpecificImplementation();
|
|
75
|
-
return trashFunction(resolvedPaths);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
// We use static imports so it can be statically analyzed.
|
|
79
|
-
async function platformSpecificImplementation() {
|
|
80
|
-
switch (process__default.platform) {
|
|
81
|
-
case 'darwin': {
|
|
82
|
-
return import('../chunks/macos.mjs');
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
case 'win32': {
|
|
86
|
-
return import('../chunks/windows.mjs');
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
case 'linux': {
|
|
90
|
-
const {isWsl} = await import('../chunks/index13.mjs');
|
|
91
|
-
if (isWsl) {
|
|
92
|
-
return import('../chunks/wsl.mjs');
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
return import('../chunks/linux.mjs');
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
default: {
|
|
99
|
-
return import('../chunks/linux.mjs');
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
async function pathExists(p) {
|
|
105
|
-
try {
|
|
106
|
-
await promises.access(p);
|
|
107
|
-
return true;
|
|
108
|
-
} catch {
|
|
109
|
-
return false;
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
async function moveToTrash(paths) {
|
|
113
|
-
const pathArray = Array.isArray(paths) ? paths : [paths];
|
|
114
|
-
const results = [];
|
|
115
|
-
for (const path of pathArray) {
|
|
116
|
-
try {
|
|
117
|
-
const exists = await pathExists(path);
|
|
118
|
-
if (!exists) {
|
|
119
|
-
results.push({
|
|
120
|
-
success: false,
|
|
121
|
-
path,
|
|
122
|
-
error: "Path does not exist"
|
|
123
|
-
});
|
|
124
|
-
continue;
|
|
125
|
-
}
|
|
126
|
-
await trash(path);
|
|
127
|
-
results.push({
|
|
128
|
-
success: true,
|
|
129
|
-
path
|
|
130
|
-
});
|
|
131
|
-
} catch (error) {
|
|
132
|
-
results.push({
|
|
133
|
-
success: false,
|
|
134
|
-
path,
|
|
135
|
-
error: error.message || "Unknown error occurred"
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
return results;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
export { moveToTrash as m };
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { webcrypto } from 'node:crypto';
|
|
2
|
-
|
|
3
|
-
const urlAlphabet =
|
|
4
|
-
'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict';
|
|
5
|
-
|
|
6
|
-
const POOL_SIZE_MULTIPLIER = 128;
|
|
7
|
-
let pool, poolOffset;
|
|
8
|
-
function fillPool(bytes) {
|
|
9
|
-
if (!pool || pool.length < bytes) {
|
|
10
|
-
pool = Buffer.allocUnsafe(bytes * POOL_SIZE_MULTIPLIER);
|
|
11
|
-
webcrypto.getRandomValues(pool);
|
|
12
|
-
poolOffset = 0;
|
|
13
|
-
} else if (poolOffset + bytes > pool.length) {
|
|
14
|
-
webcrypto.getRandomValues(pool);
|
|
15
|
-
poolOffset = 0;
|
|
16
|
-
}
|
|
17
|
-
poolOffset += bytes;
|
|
18
|
-
}
|
|
19
|
-
function nanoid(size = 21) {
|
|
20
|
-
fillPool((size |= 0));
|
|
21
|
-
let id = '';
|
|
22
|
-
for (let i = poolOffset - size; i < poolOffset; i++) {
|
|
23
|
-
id += urlAlphabet[pool[i] & 63];
|
|
24
|
-
}
|
|
25
|
-
return id
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export { nanoid as n };
|
|
@@ -1,266 +0,0 @@
|
|
|
1
|
-
import { execSync } from 'node:child_process';
|
|
2
|
-
import { existsSync, readFileSync } from 'node:fs';
|
|
3
|
-
import process__default from 'node:process';
|
|
4
|
-
import { j as join } from './ccjk.bQ7Dh1g4.mjs';
|
|
5
|
-
|
|
6
|
-
function scanProject(cwd) {
|
|
7
|
-
const root = cwd || process__default.cwd();
|
|
8
|
-
const pkg = readPackageJson(root);
|
|
9
|
-
const language = detectLanguage(root, pkg);
|
|
10
|
-
const secondaryLanguages = detectSecondaryLanguages(root, pkg, language);
|
|
11
|
-
return {
|
|
12
|
-
language,
|
|
13
|
-
secondaryLanguages,
|
|
14
|
-
framework: detectFramework(root, pkg),
|
|
15
|
-
testRunner: detectTestRunner(root, pkg),
|
|
16
|
-
packageManager: detectPackageManager(root),
|
|
17
|
-
linter: detectLinter(root, pkg),
|
|
18
|
-
formatter: detectFormatter(root, pkg),
|
|
19
|
-
database: detectDatabase(root),
|
|
20
|
-
runtime: detectRuntime(),
|
|
21
|
-
isMonorepo: detectMonorepo(root, pkg),
|
|
22
|
-
usesConventionalCommits: detectConventionalCommits(root, pkg),
|
|
23
|
-
hasGitHooks: detectGitHooks(root, pkg),
|
|
24
|
-
hasDocker: existsSync(join(root, "Dockerfile")) || existsSync(join(root, "docker-compose.yml")) || existsSync(join(root, "docker-compose.yaml")),
|
|
25
|
-
hasCI: detectCI(root),
|
|
26
|
-
root
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
function readPackageJson(root) {
|
|
30
|
-
const p = join(root, "package.json");
|
|
31
|
-
if (!existsSync(p)) return null;
|
|
32
|
-
try {
|
|
33
|
-
return JSON.parse(readFileSync(p, "utf-8"));
|
|
34
|
-
} catch {
|
|
35
|
-
return null;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
function hasDep(pkg, name) {
|
|
39
|
-
if (!pkg) return false;
|
|
40
|
-
return !!(pkg.dependencies?.[name] || pkg.devDependencies?.[name] || pkg.peerDependencies?.[name]);
|
|
41
|
-
}
|
|
42
|
-
function detectLanguage(root, pkg) {
|
|
43
|
-
if (existsSync(join(root, "tsconfig.json")) || hasDep(pkg, "typescript")) {
|
|
44
|
-
return "typescript";
|
|
45
|
-
}
|
|
46
|
-
if (existsSync(join(root, "pyproject.toml")) || existsSync(join(root, "setup.py")) || existsSync(join(root, "requirements.txt")) || existsSync(join(root, "Pipfile"))) {
|
|
47
|
-
return "python";
|
|
48
|
-
}
|
|
49
|
-
if (existsSync(join(root, "go.mod"))) {
|
|
50
|
-
return "go";
|
|
51
|
-
}
|
|
52
|
-
if (existsSync(join(root, "Cargo.toml"))) {
|
|
53
|
-
return "rust";
|
|
54
|
-
}
|
|
55
|
-
if (existsSync(join(root, "pom.xml")) || existsSync(join(root, "build.gradle")) || existsSync(join(root, "build.gradle.kts"))) {
|
|
56
|
-
return "java";
|
|
57
|
-
}
|
|
58
|
-
if (existsSync(join(root, "Gemfile"))) {
|
|
59
|
-
return "ruby";
|
|
60
|
-
}
|
|
61
|
-
if (existsSync(join(root, "composer.json"))) {
|
|
62
|
-
return "php";
|
|
63
|
-
}
|
|
64
|
-
if (existsSync(join(root, "Package.swift"))) {
|
|
65
|
-
return "swift";
|
|
66
|
-
}
|
|
67
|
-
if (existsSync(join(root, "*.csproj")) || existsSync(join(root, "*.sln"))) {
|
|
68
|
-
return "csharp";
|
|
69
|
-
}
|
|
70
|
-
if (pkg) {
|
|
71
|
-
return "javascript";
|
|
72
|
-
}
|
|
73
|
-
return "unknown";
|
|
74
|
-
}
|
|
75
|
-
function detectSecondaryLanguages(root, pkg, primary) {
|
|
76
|
-
const langs = [];
|
|
77
|
-
const checks = [
|
|
78
|
-
["typescript", () => existsSync(join(root, "tsconfig.json")) || hasDep(pkg, "typescript")],
|
|
79
|
-
["javascript", () => !!pkg],
|
|
80
|
-
["python", () => existsSync(join(root, "pyproject.toml")) || existsSync(join(root, "requirements.txt"))],
|
|
81
|
-
["go", () => existsSync(join(root, "go.mod"))],
|
|
82
|
-
["rust", () => existsSync(join(root, "Cargo.toml"))]
|
|
83
|
-
];
|
|
84
|
-
for (const [lang, check] of checks) {
|
|
85
|
-
if (lang !== primary && check()) langs.push(lang);
|
|
86
|
-
}
|
|
87
|
-
return langs;
|
|
88
|
-
}
|
|
89
|
-
function detectFramework(root, pkg) {
|
|
90
|
-
if (!pkg) {
|
|
91
|
-
if (existsSync(join(root, "pyproject.toml"))) {
|
|
92
|
-
const content = safeRead(join(root, "pyproject.toml"));
|
|
93
|
-
if (content.includes("fastapi")) return "fastapi";
|
|
94
|
-
if (content.includes("django")) return "django";
|
|
95
|
-
if (content.includes("flask")) return "flask";
|
|
96
|
-
}
|
|
97
|
-
if (existsSync(join(root, "requirements.txt"))) {
|
|
98
|
-
const content = safeRead(join(root, "requirements.txt"));
|
|
99
|
-
if (content.includes("fastapi")) return "fastapi";
|
|
100
|
-
if (content.includes("django")) return "django";
|
|
101
|
-
if (content.includes("flask")) return "flask";
|
|
102
|
-
}
|
|
103
|
-
return "none";
|
|
104
|
-
}
|
|
105
|
-
if (hasDep(pkg, "next")) return "next";
|
|
106
|
-
if (hasDep(pkg, "nuxt")) return "nuxt";
|
|
107
|
-
if (hasDep(pkg, "@angular/core")) return "angular";
|
|
108
|
-
if (hasDep(pkg, "svelte") || hasDep(pkg, "@sveltejs/kit")) return "svelte";
|
|
109
|
-
if (hasDep(pkg, "@nestjs/core")) return "nest";
|
|
110
|
-
if (hasDep(pkg, "@tauri-apps/api") || hasDep(pkg, "@tauri-apps/cli")) return "tauri";
|
|
111
|
-
if (hasDep(pkg, "electron")) return "electron";
|
|
112
|
-
if (hasDep(pkg, "vue")) return "vue";
|
|
113
|
-
if (hasDep(pkg, "react")) return "react";
|
|
114
|
-
if (hasDep(pkg, "fastify")) return "fastify";
|
|
115
|
-
if (hasDep(pkg, "express")) return "express";
|
|
116
|
-
return "none";
|
|
117
|
-
}
|
|
118
|
-
function detectTestRunner(root, pkg) {
|
|
119
|
-
if (hasDep(pkg, "vitest")) return "vitest";
|
|
120
|
-
if (hasDep(pkg, "jest") || hasDep(pkg, "@jest/core")) return "jest";
|
|
121
|
-
if (hasDep(pkg, "mocha")) return "mocha";
|
|
122
|
-
if (existsSync(join(root, "pytest.ini")) || existsSync(join(root, "conftest.py"))) return "pytest";
|
|
123
|
-
if (existsSync(join(root, "pyproject.toml"))) {
|
|
124
|
-
const content = safeRead(join(root, "pyproject.toml"));
|
|
125
|
-
if (content.includes("[tool.pytest") || content.includes("pytest")) return "pytest";
|
|
126
|
-
}
|
|
127
|
-
if (existsSync(join(root, "go.mod"))) return "go-test";
|
|
128
|
-
if (existsSync(join(root, "Cargo.toml"))) return "cargo-test";
|
|
129
|
-
if (existsSync(join(root, "pom.xml")) || existsSync(join(root, "build.gradle"))) return "junit";
|
|
130
|
-
if (existsSync(join(root, "Gemfile"))) {
|
|
131
|
-
const content = safeRead(join(root, "Gemfile"));
|
|
132
|
-
if (content.includes("rspec")) return "rspec";
|
|
133
|
-
}
|
|
134
|
-
if (hasDep(pkg, "phpunit") || existsSync(join(root, "phpunit.xml"))) return "phpunit";
|
|
135
|
-
return "none";
|
|
136
|
-
}
|
|
137
|
-
function detectPackageManager(root) {
|
|
138
|
-
if (existsSync(join(root, "pnpm-lock.yaml")) || existsSync(join(root, "pnpm-workspace.yaml"))) return "pnpm";
|
|
139
|
-
if (existsSync(join(root, "bun.lockb")) || existsSync(join(root, "bun.lock"))) return "bun";
|
|
140
|
-
if (existsSync(join(root, "yarn.lock"))) return "yarn";
|
|
141
|
-
if (existsSync(join(root, "package-lock.json"))) return "npm";
|
|
142
|
-
if (existsSync(join(root, "poetry.lock"))) return "poetry";
|
|
143
|
-
if (existsSync(join(root, "Pipfile.lock")) || existsSync(join(root, "requirements.txt"))) return "pip";
|
|
144
|
-
if (existsSync(join(root, "Cargo.lock"))) return "cargo";
|
|
145
|
-
if (existsSync(join(root, "go.sum"))) return "go";
|
|
146
|
-
if (existsSync(join(root, "pom.xml"))) return "maven";
|
|
147
|
-
if (existsSync(join(root, "build.gradle")) || existsSync(join(root, "build.gradle.kts"))) return "gradle";
|
|
148
|
-
return "none";
|
|
149
|
-
}
|
|
150
|
-
function detectLinter(root, pkg) {
|
|
151
|
-
if (hasDep(pkg, "@biomejs/biome") || existsSync(join(root, "biome.json")) || existsSync(join(root, "biome.jsonc"))) return "biome";
|
|
152
|
-
if (hasDep(pkg, "oxlint") || hasDep(pkg, "oxc")) return "oxlint";
|
|
153
|
-
if (hasDep(pkg, "eslint") || existsSync(join(root, ".eslintrc.json")) || existsSync(join(root, ".eslintrc.js")) || existsSync(join(root, "eslint.config.js")) || existsSync(join(root, "eslint.config.mjs"))) return "eslint";
|
|
154
|
-
if (existsSync(join(root, "ruff.toml")) || existsSync(join(root, ".ruff.toml"))) return "ruff";
|
|
155
|
-
if (existsSync(join(root, "pyproject.toml"))) {
|
|
156
|
-
const content = safeRead(join(root, "pyproject.toml"));
|
|
157
|
-
if (content.includes("[tool.ruff")) return "ruff";
|
|
158
|
-
if (content.includes("[tool.pylint") || content.includes("pylint")) return "pylint";
|
|
159
|
-
if (content.includes("flake8")) return "flake8";
|
|
160
|
-
}
|
|
161
|
-
if (existsSync(join(root, ".golangci.yml")) || existsSync(join(root, ".golangci.yaml"))) return "golangci-lint";
|
|
162
|
-
if (existsSync(join(root, "Cargo.toml"))) return "clippy";
|
|
163
|
-
if (existsSync(join(root, ".rubocop.yml"))) return "rubocop";
|
|
164
|
-
return "none";
|
|
165
|
-
}
|
|
166
|
-
function detectFormatter(root, pkg) {
|
|
167
|
-
if (hasDep(pkg, "@biomejs/biome") || existsSync(join(root, "biome.json"))) return "biome";
|
|
168
|
-
if (hasDep(pkg, "prettier") || existsSync(join(root, ".prettierrc")) || existsSync(join(root, ".prettierrc.json")) || existsSync(join(root, "prettier.config.js")) || existsSync(join(root, "prettier.config.mjs"))) return "prettier";
|
|
169
|
-
if (existsSync(join(root, "pyproject.toml"))) {
|
|
170
|
-
const content = safeRead(join(root, "pyproject.toml"));
|
|
171
|
-
if (content.includes("[tool.ruff") && content.includes("format")) return "ruff";
|
|
172
|
-
if (content.includes("[tool.black") || content.includes("black")) return "black";
|
|
173
|
-
}
|
|
174
|
-
if (existsSync(join(root, "go.mod"))) return "gofmt";
|
|
175
|
-
if (existsSync(join(root, "Cargo.toml"))) return "rustfmt";
|
|
176
|
-
return "none";
|
|
177
|
-
}
|
|
178
|
-
function detectDatabase(root) {
|
|
179
|
-
for (const f of ["docker-compose.yml", "docker-compose.yaml", "compose.yml", "compose.yaml"]) {
|
|
180
|
-
const content = safeRead(join(root, f));
|
|
181
|
-
if (!content) continue;
|
|
182
|
-
if (content.includes("postgres")) return "postgresql";
|
|
183
|
-
if (content.includes("mysql") || content.includes("mariadb")) return "mysql";
|
|
184
|
-
if (content.includes("mongo")) return "mongodb";
|
|
185
|
-
if (content.includes("redis")) return "redis";
|
|
186
|
-
}
|
|
187
|
-
for (const f of [".env", ".env.local", ".env.development"]) {
|
|
188
|
-
const content = safeRead(join(root, f));
|
|
189
|
-
if (!content) continue;
|
|
190
|
-
if (content.includes("postgres")) return "postgresql";
|
|
191
|
-
if (content.includes("mysql")) return "mysql";
|
|
192
|
-
if (content.includes("mongodb") || content.includes("mongo+srv")) return "mongodb";
|
|
193
|
-
if (content.includes("redis://")) return "redis";
|
|
194
|
-
}
|
|
195
|
-
if (existsSync(join(root, "prisma", "schema.prisma"))) {
|
|
196
|
-
const content = safeRead(join(root, "prisma", "schema.prisma"));
|
|
197
|
-
if (content.includes("postgresql")) return "postgresql";
|
|
198
|
-
if (content.includes("mysql")) return "mysql";
|
|
199
|
-
if (content.includes("sqlite")) return "sqlite";
|
|
200
|
-
if (content.includes("mongodb")) return "mongodb";
|
|
201
|
-
}
|
|
202
|
-
for (const f of ["*.db", "*.sqlite", "*.sqlite3"]) {
|
|
203
|
-
if (existsSync(join(root, "db.sqlite")) || existsSync(join(root, "database.sqlite")) || existsSync(join(root, "dev.db"))) {
|
|
204
|
-
return "sqlite";
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
return "none";
|
|
208
|
-
}
|
|
209
|
-
function detectRuntime() {
|
|
210
|
-
const isContainer = existsSync("/.dockerenv") || existsSync("/run/.containerenv") || safeRead("/proc/1/cgroup").includes("docker");
|
|
211
|
-
const isSSH = !!process__default.env.SSH_CLIENT || !!process__default.env.SSH_TTY || !!process__default.env.SSH_CONNECTION;
|
|
212
|
-
const isCI = !!(process__default.env.CI || process__default.env.GITHUB_ACTIONS || process__default.env.GITLAB_CI || process__default.env.JENKINS_URL || process__default.env.CIRCLECI || process__default.env.TRAVIS || process__default.env.BUILDKITE);
|
|
213
|
-
const isWSL = safeRead("/proc/version").toLowerCase().includes("microsoft");
|
|
214
|
-
const isMac = process__default.platform === "darwin";
|
|
215
|
-
const hasDisplay = !!(process__default.env.DISPLAY || process__default.env.WAYLAND_DISPLAY || process__default.env.TERM_PROGRAM);
|
|
216
|
-
const isHeadless = !isMac && !hasDisplay && !isWSL;
|
|
217
|
-
const hasBrowser = isMac || hasDisplay || isWSL;
|
|
218
|
-
return {
|
|
219
|
-
isContainer,
|
|
220
|
-
isHeadless,
|
|
221
|
-
isSSH,
|
|
222
|
-
isCI,
|
|
223
|
-
isWSL,
|
|
224
|
-
hasBrowser
|
|
225
|
-
};
|
|
226
|
-
}
|
|
227
|
-
function detectMonorepo(root, pkg) {
|
|
228
|
-
if (pkg?.workspaces) return true;
|
|
229
|
-
if (existsSync(join(root, "pnpm-workspace.yaml"))) return true;
|
|
230
|
-
if (existsSync(join(root, "lerna.json"))) return true;
|
|
231
|
-
if (existsSync(join(root, "nx.json"))) return true;
|
|
232
|
-
if (existsSync(join(root, "turbo.json"))) return true;
|
|
233
|
-
return false;
|
|
234
|
-
}
|
|
235
|
-
function detectConventionalCommits(root, pkg) {
|
|
236
|
-
if (existsSync(join(root, ".commitlintrc.json")) || existsSync(join(root, ".commitlintrc.js")) || existsSync(join(root, "commitlint.config.js")) || existsSync(join(root, "commitlint.config.mjs"))) return true;
|
|
237
|
-
if (hasDep(pkg, "@commitlint/cli") || hasDep(pkg, "@commitlint/config-conventional")) return true;
|
|
238
|
-
try {
|
|
239
|
-
const log = execSync("git log --oneline -10 2>/dev/null", { cwd: root, encoding: "utf-8", timeout: 3e3 });
|
|
240
|
-
const conventionalPattern = /^[a-f0-9]+ (feat|fix|chore|docs|style|refactor|perf|test|build|ci|revert)(\(.+\))?[!]?:/m;
|
|
241
|
-
const lines = log.trim().split("\n").filter(Boolean);
|
|
242
|
-
const matches = lines.filter((l) => conventionalPattern.test(l));
|
|
243
|
-
return lines.length > 0 && matches.length / lines.length > 0.5;
|
|
244
|
-
} catch {
|
|
245
|
-
return false;
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
function detectGitHooks(root, pkg) {
|
|
249
|
-
if (existsSync(join(root, ".husky"))) return true;
|
|
250
|
-
if (hasDep(pkg, "husky") || hasDep(pkg, "simple-git-hooks") || hasDep(pkg, "lefthook")) return true;
|
|
251
|
-
if (existsSync(join(root, ".lefthook.yml"))) return true;
|
|
252
|
-
return false;
|
|
253
|
-
}
|
|
254
|
-
function detectCI(root) {
|
|
255
|
-
return existsSync(join(root, ".github", "workflows")) || existsSync(join(root, ".gitlab-ci.yml")) || existsSync(join(root, ".circleci")) || existsSync(join(root, "Jenkinsfile")) || existsSync(join(root, ".travis.yml")) || existsSync(join(root, "bitbucket-pipelines.yml"));
|
|
256
|
-
}
|
|
257
|
-
function safeRead(path) {
|
|
258
|
-
try {
|
|
259
|
-
if (!existsSync(path)) return "";
|
|
260
|
-
return readFileSync(path, "utf-8");
|
|
261
|
-
} catch {
|
|
262
|
-
return "";
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
export { scanProject as s };
|
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
import { CLOUD_ENDPOINTS } from '../chunks/constants.mjs';
|
|
2
|
-
import { C as CloudApiClient } from './ccjk.D6ycHbak.mjs';
|
|
3
|
-
|
|
4
|
-
const ROUTE_MAP = {
|
|
5
|
-
// Analysis endpoints
|
|
6
|
-
"analysis.projects": {
|
|
7
|
-
v1: "/api/v1/analysis/projects",
|
|
8
|
-
v8: "/api/v8/analyze"
|
|
9
|
-
// Legacy v8 path
|
|
10
|
-
},
|
|
11
|
-
// Template endpoints
|
|
12
|
-
"templates.get": {
|
|
13
|
-
v1: "/api/v1/templates/:id"
|
|
14
|
-
},
|
|
15
|
-
"templates.batch": {
|
|
16
|
-
v1: "/api/v1/templates/batch",
|
|
17
|
-
v8: "/api/v8/templates"
|
|
18
|
-
// Legacy v8 batch endpoint
|
|
19
|
-
},
|
|
20
|
-
// Telemetry endpoints
|
|
21
|
-
"telemetry.installation": {
|
|
22
|
-
v1: "/api/v1/telemetry/installation"
|
|
23
|
-
},
|
|
24
|
-
// Health check
|
|
25
|
-
"health": {
|
|
26
|
-
v1: "/api/v1/health"
|
|
27
|
-
},
|
|
28
|
-
// Plugin endpoints
|
|
29
|
-
"plugins.list": {
|
|
30
|
-
v1: "/v1/plugins/list"
|
|
31
|
-
},
|
|
32
|
-
"plugins.recommend": {
|
|
33
|
-
v1: "/v1/plugins/recommend"
|
|
34
|
-
},
|
|
35
|
-
// Skills endpoints
|
|
36
|
-
"skills.list": {
|
|
37
|
-
v1: "/v1/skills/list"
|
|
38
|
-
},
|
|
39
|
-
"skills.upload": {
|
|
40
|
-
v1: "/v1/skills/upload"
|
|
41
|
-
},
|
|
42
|
-
"skills.download": {
|
|
43
|
-
v1: "/v1/skills/download"
|
|
44
|
-
},
|
|
45
|
-
// Notification endpoints (remote API)
|
|
46
|
-
"notifications.bind": {
|
|
47
|
-
v1: "/bind/use"
|
|
48
|
-
},
|
|
49
|
-
"notifications.send": {
|
|
50
|
-
v1: "/notify"
|
|
51
|
-
},
|
|
52
|
-
"notifications.poll": {
|
|
53
|
-
v1: "/reply/poll"
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
class CloudApiGateway {
|
|
57
|
-
mainClient;
|
|
58
|
-
pluginsClient;
|
|
59
|
-
remoteClient;
|
|
60
|
-
config;
|
|
61
|
-
constructor(config = {}) {
|
|
62
|
-
this.config = {
|
|
63
|
-
timeout: config.timeout || 3e4,
|
|
64
|
-
authToken: config.authToken || "",
|
|
65
|
-
enableVersionFallback: config.enableVersionFallback ?? true
|
|
66
|
-
};
|
|
67
|
-
this.mainClient = new CloudApiClient({
|
|
68
|
-
baseUrl: CLOUD_ENDPOINTS.MAIN.BASE_URL,
|
|
69
|
-
timeout: this.config.timeout,
|
|
70
|
-
authToken: this.config.authToken
|
|
71
|
-
});
|
|
72
|
-
this.pluginsClient = new CloudApiClient({
|
|
73
|
-
baseUrl: CLOUD_ENDPOINTS.PLUGINS.BASE_URL,
|
|
74
|
-
timeout: this.config.timeout,
|
|
75
|
-
authToken: this.config.authToken
|
|
76
|
-
});
|
|
77
|
-
this.remoteClient = new CloudApiClient({
|
|
78
|
-
baseUrl: CLOUD_ENDPOINTS.REMOTE.BASE_URL,
|
|
79
|
-
timeout: this.config.timeout,
|
|
80
|
-
authToken: this.config.authToken
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Make a request through the gateway
|
|
85
|
-
*
|
|
86
|
-
* @param route - Semantic route identifier
|
|
87
|
-
* @param options - Request options
|
|
88
|
-
* @returns API response
|
|
89
|
-
*/
|
|
90
|
-
async request(route, options) {
|
|
91
|
-
const routeConfig = ROUTE_MAP[route];
|
|
92
|
-
if (!routeConfig) {
|
|
93
|
-
return {
|
|
94
|
-
success: false,
|
|
95
|
-
error: `Unknown route: ${route}`,
|
|
96
|
-
code: "INVALID_ROUTE"
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
const client = this.getClientForRoute(route);
|
|
100
|
-
const version = options.preferVersion || "v1";
|
|
101
|
-
const path = this.resolvePath(routeConfig, version);
|
|
102
|
-
const response = await client.request(path, {
|
|
103
|
-
method: options.method,
|
|
104
|
-
body: options.body,
|
|
105
|
-
query: options.query,
|
|
106
|
-
authToken: options.authToken || this.config.authToken,
|
|
107
|
-
timeout: options.timeout || this.config.timeout
|
|
108
|
-
});
|
|
109
|
-
if (!response.success && version === "v1" && routeConfig.v8 && this.config.enableVersionFallback) {
|
|
110
|
-
const v8Path = routeConfig.v8;
|
|
111
|
-
return client.request(v8Path, {
|
|
112
|
-
method: options.method,
|
|
113
|
-
body: options.body,
|
|
114
|
-
query: options.query,
|
|
115
|
-
authToken: options.authToken || this.config.authToken,
|
|
116
|
-
timeout: options.timeout || this.config.timeout
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
return response;
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
* Set authentication token for all clients
|
|
123
|
-
*/
|
|
124
|
-
setAuthToken(token) {
|
|
125
|
-
this.config.authToken = token;
|
|
126
|
-
this.mainClient.setAuthToken(token);
|
|
127
|
-
this.pluginsClient.setAuthToken(token);
|
|
128
|
-
this.remoteClient.setAuthToken(token);
|
|
129
|
-
}
|
|
130
|
-
/**
|
|
131
|
-
* Get current configuration
|
|
132
|
-
*/
|
|
133
|
-
getConfig() {
|
|
134
|
-
return { ...this.config };
|
|
135
|
-
}
|
|
136
|
-
// ==========================================================================
|
|
137
|
-
// Private Methods
|
|
138
|
-
// ==========================================================================
|
|
139
|
-
/**
|
|
140
|
-
* Get appropriate client for a route
|
|
141
|
-
*/
|
|
142
|
-
getClientForRoute(route) {
|
|
143
|
-
if (route.startsWith("plugins.")) {
|
|
144
|
-
return this.pluginsClient;
|
|
145
|
-
}
|
|
146
|
-
if (route.startsWith("notifications.")) {
|
|
147
|
-
return this.remoteClient;
|
|
148
|
-
}
|
|
149
|
-
if (route.startsWith("skills.")) {
|
|
150
|
-
return this.pluginsClient;
|
|
151
|
-
}
|
|
152
|
-
return this.mainClient;
|
|
153
|
-
}
|
|
154
|
-
/**
|
|
155
|
-
* Resolve path for specific version
|
|
156
|
-
*/
|
|
157
|
-
resolvePath(routeConfig, version) {
|
|
158
|
-
return version === "v8" && routeConfig.v8 ? routeConfig.v8 : routeConfig.v1;
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
function createGateway(config) {
|
|
162
|
-
return new CloudApiGateway(config);
|
|
163
|
-
}
|
|
164
|
-
function createDefaultGateway() {
|
|
165
|
-
return new CloudApiGateway({
|
|
166
|
-
timeout: 3e4,
|
|
167
|
-
enableVersionFallback: true
|
|
168
|
-
});
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
export { createGateway as a, createDefaultGateway as c };
|