ccjk 2.4.3 → 2.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/api-providers.mjs +73 -1
- package/dist/chunks/ccjk-config.mjs +13 -77
- package/dist/chunks/ccr.mjs +9 -4
- package/dist/chunks/check-updates.mjs +4 -2
- package/dist/chunks/claude-code-config-manager.mjs +9 -15
- package/dist/chunks/claude-code-incremental-manager.mjs +5 -8
- package/dist/chunks/codex.mjs +10 -569
- package/dist/chunks/config-switch.mjs +7 -5
- package/dist/chunks/config.mjs +573 -0
- package/dist/chunks/config2.mjs +451 -0
- package/dist/chunks/doctor.mjs +89 -1
- package/dist/chunks/features.mjs +13 -10
- package/dist/chunks/index.mjs +10 -1164
- package/dist/chunks/index2.mjs +8 -2
- package/dist/chunks/init.mjs +14 -11
- package/dist/chunks/json-config.mjs +59 -0
- package/dist/chunks/mcp-server.mjs +776 -0
- package/dist/chunks/mcp.mjs +10 -8
- package/dist/chunks/menu.mjs +5 -5
- package/dist/chunks/package.mjs +1 -1
- package/dist/chunks/permissions.mjs +420 -0
- package/dist/chunks/prompts.mjs +2 -1
- package/dist/chunks/providers.mjs +261 -0
- package/dist/chunks/session.mjs +484 -41
- package/dist/chunks/skills.mjs +553 -0
- package/dist/chunks/stats.mjs +411 -0
- package/dist/chunks/uninstall.mjs +4 -3
- package/dist/chunks/update.mjs +6 -3
- package/dist/chunks/workflows2.mjs +140 -0
- package/dist/cli.mjs +316 -10
- package/dist/i18n/locales/en/hooks.json +47 -0
- package/dist/i18n/locales/en/mcp.json +55 -0
- package/dist/i18n/locales/en/permissions.json +43 -0
- package/dist/i18n/locales/en/sandbox.json +44 -0
- package/dist/i18n/locales/en/skills.json +89 -129
- package/dist/i18n/locales/en/stats.json +20 -0
- package/dist/i18n/locales/zh-CN/hooks.json +47 -0
- package/dist/i18n/locales/zh-CN/mcp.json +55 -0
- package/dist/i18n/locales/zh-CN/permissions.json +43 -0
- package/dist/i18n/locales/zh-CN/sandbox.json +44 -0
- package/dist/i18n/locales/zh-CN/skills.json +88 -128
- package/dist/i18n/locales/zh-CN/stats.json +20 -0
- package/dist/index.mjs +12 -8
- package/dist/shared/ccjk.B-lZxV2u.mjs +1162 -0
- package/dist/shared/{ccjk.CURU8gbR.mjs → ccjk.CUdzQluX.mjs} +1 -1
- package/dist/shared/{ccjk.ByTIGCUC.mjs → ccjk.Dut3wyoP.mjs} +1 -1
- package/dist/shared/ccjk.J8YiPsOw.mjs +259 -0
- package/dist/shared/{ccjk.CGTmRqsu.mjs → ccjk.rLRHmcqD.mjs} +5 -134
- package/dist/shared/{ccjk.QbS8EAOd.mjs → ccjk.uVUeWAt8.mjs} +2 -1
- package/package.json +1 -1
- package/templates/common/skills/code-review.md +343 -0
- package/templates/common/skills/summarize.md +312 -0
- package/templates/common/skills/translate.md +202 -0
package/dist/chunks/mcp.mjs
CHANGED
|
@@ -3,8 +3,9 @@ import { i18n } from './index2.mjs';
|
|
|
3
3
|
import 'node:child_process';
|
|
4
4
|
import 'node:process';
|
|
5
5
|
import { M as MCP_SERVICE_TIERS, i as isCoreService, g as getServicesByTier, c as checkMcpPerformance, f as formatPerformanceWarning, a as calculateResourceUsage, b as getOptimizationSuggestions, d as getMcpTierConfig } from './mcp-performance.mjs';
|
|
6
|
-
import {
|
|
7
|
-
export { m as mcpInstall, a as mcpList, b as mcpSearch, c as mcpUninstall } from '../shared/ccjk.
|
|
6
|
+
import { r as readMcpConfig, b as backupMcpConfig, w as writeMcpConfig } from './config.mjs';
|
|
7
|
+
export { m as mcpInstall, a as mcpList, b as mcpSearch, c as mcpUninstall } from '../shared/ccjk.uVUeWAt8.mjs';
|
|
8
|
+
import { M as MCP_SERVICE_CONFIGS } from './codex.mjs';
|
|
8
9
|
import 'node:fs';
|
|
9
10
|
import 'node:url';
|
|
10
11
|
import 'i18next';
|
|
@@ -12,17 +13,18 @@ import 'i18next-fs-backend';
|
|
|
12
13
|
import 'pathe';
|
|
13
14
|
import 'dayjs';
|
|
14
15
|
import 'inquirer';
|
|
15
|
-
import 'ora';
|
|
16
|
-
import 'semver';
|
|
17
|
-
import 'smol-toml';
|
|
18
|
-
import 'tinyexec';
|
|
19
16
|
import './constants.mjs';
|
|
20
17
|
import 'node:os';
|
|
21
|
-
import './
|
|
18
|
+
import './json-config.mjs';
|
|
22
19
|
import './fs-operations.mjs';
|
|
23
20
|
import 'node:crypto';
|
|
24
21
|
import 'node:fs/promises';
|
|
25
22
|
import './platform.mjs';
|
|
23
|
+
import 'tinyexec';
|
|
24
|
+
import 'ora';
|
|
25
|
+
import 'semver';
|
|
26
|
+
import 'smol-toml';
|
|
27
|
+
import './ccjk-config.mjs';
|
|
26
28
|
import '../shared/ccjk.DhBeLRzf.mjs';
|
|
27
29
|
import 'inquirer-toggle';
|
|
28
30
|
import './prompts.mjs';
|
|
@@ -418,7 +420,7 @@ async function useProfile(profileId, options = {}) {
|
|
|
418
420
|
}
|
|
419
421
|
|
|
420
422
|
async function mcpStatus(options = {}) {
|
|
421
|
-
const { readMcpConfig } = await import('./
|
|
423
|
+
const { readMcpConfig } = await import('./config.mjs').then(function (n) { return n.C; });
|
|
422
424
|
const { checkMcpPerformance, formatPerformanceWarning } = await import('./mcp-performance.mjs').then(function (n) { return n.e; });
|
|
423
425
|
const { MCP_SERVICE_TIERS } = await import('./mcp-performance.mjs').then(function (n) { return n.m; });
|
|
424
426
|
const lang = options.lang || i18n.language || "en";
|
package/dist/chunks/menu.mjs
CHANGED
|
@@ -6,9 +6,9 @@ import { join } from 'pathe';
|
|
|
6
6
|
import { CODE_TOOL_BANNERS, CLAUDE_DIR, isCodeToolType, DEFAULT_CODE_TOOL_TYPE } from './constants.mjs';
|
|
7
7
|
import { ensureI18nInitialized, i18n } from './index2.mjs';
|
|
8
8
|
import { a as displayBannerWithInfo } from '../shared/ccjk.BhKlRJ0h.mjs';
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import { r as resolveCodeType } from '../shared/ccjk.
|
|
9
|
+
import { updateZcfConfig, readZcfConfig } from './ccjk-config.mjs';
|
|
10
|
+
import { C as runCodexUpdate, B as runCodexUninstall, K as configureCodexMcp, i as configureCodexApi, E as runCodexWorkflowImportWithLanguageSelection, z as runCodexFullInit } from './codex.mjs';
|
|
11
|
+
import { r as resolveCodeType } from '../shared/ccjk.CUdzQluX.mjs';
|
|
12
12
|
import { h as handleExitPromptError, a as handleGeneralError } from '../shared/ccjk.tB4-Y4Qb.mjs';
|
|
13
13
|
import { changeScriptLanguageFeature, configureCodexAiMemoryFeature, configureCodexDefaultModelFeature, configureEnvPermissionFeature, configureAiMemoryFeature, configureDefaultModelFeature, configureMcpFeature, configureApiFeature } from './features.mjs';
|
|
14
14
|
import { c as checkForUpdates, g as getInstalledPackages, s as searchPackages } from '../shared/ccjk.RR9TS76h.mjs';
|
|
@@ -22,10 +22,10 @@ import { homedir } from 'node:os';
|
|
|
22
22
|
import { runCcrStop, runCcrStart, runCcrRestart, runCcrStatus, runCcrUi } from './commands2.mjs';
|
|
23
23
|
import { checkUpdates } from './check-updates.mjs';
|
|
24
24
|
import { configSwitchCommand } from './config-switch.mjs';
|
|
25
|
-
import { d as detectProjectContext, h as getProjectTypeLabel, b as getApplicableRules, c as getContextFiles, j as getContextFileTypeLabel, r as readContextFile, m as mergeContextContent, e as generateContextContent, w as writeContextFile, f as getRecommendedRules, k as formatFileSize } from '../shared/ccjk.
|
|
25
|
+
import { d as detectProjectContext, h as getProjectTypeLabel, b as getApplicableRules, c as getContextFiles, j as getContextFileTypeLabel, r as readContextFile, m as mergeContextContent, e as generateContextContent, w as writeContextFile, f as getRecommendedRules, k as formatFileSize } from '../shared/ccjk.Dut3wyoP.mjs';
|
|
26
26
|
import { doctor, workspaceDiagnostics } from './doctor.mjs';
|
|
27
27
|
import { ensureDir, writeFileAtomic, exists, readJsonFile } from './fs-operations.mjs';
|
|
28
|
-
import { a as mcpList, c as mcpUninstall, m as mcpInstall, d as mcpTrending, b as mcpSearch } from '../shared/ccjk.
|
|
28
|
+
import { a as mcpList, c as mcpUninstall, m as mcpInstall, d as mcpTrending, b as mcpSearch } from '../shared/ccjk.uVUeWAt8.mjs';
|
|
29
29
|
import { notificationCommand } from './notification.mjs';
|
|
30
30
|
import { uninstall } from './uninstall.mjs';
|
|
31
31
|
import { update } from './update.mjs';
|
package/dist/chunks/package.mjs
CHANGED
|
@@ -0,0 +1,420 @@
|
|
|
1
|
+
import process__default from 'node:process';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import { existsSync, readFileSync, writeFileSync } from 'node:fs';
|
|
4
|
+
import { homedir } from 'node:os';
|
|
5
|
+
import { join } from 'pathe';
|
|
6
|
+
|
|
7
|
+
class PermissionManager {
|
|
8
|
+
permissions = [];
|
|
9
|
+
configPath;
|
|
10
|
+
constructor(configPath) {
|
|
11
|
+
this.configPath = configPath || join(homedir(), ".ccjk", "config.json");
|
|
12
|
+
this.loadPermissions();
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Load permissions from config file
|
|
16
|
+
*/
|
|
17
|
+
loadPermissions() {
|
|
18
|
+
try {
|
|
19
|
+
if (!existsSync(this.configPath)) {
|
|
20
|
+
this.permissions = [];
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
const configContent = readFileSync(this.configPath, "utf-8");
|
|
24
|
+
const config = JSON.parse(configContent);
|
|
25
|
+
if (config.permissions) {
|
|
26
|
+
this.permissions = [];
|
|
27
|
+
if (Array.isArray(config.permissions.allow)) {
|
|
28
|
+
config.permissions.allow.forEach((pattern) => {
|
|
29
|
+
this.permissions.push({
|
|
30
|
+
type: "allow",
|
|
31
|
+
pattern,
|
|
32
|
+
scope: "global"
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
if (Array.isArray(config.permissions.deny)) {
|
|
37
|
+
config.permissions.deny.forEach((pattern) => {
|
|
38
|
+
this.permissions.push({
|
|
39
|
+
type: "deny",
|
|
40
|
+
pattern,
|
|
41
|
+
scope: "global"
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
} catch (_error) {
|
|
47
|
+
this.permissions = [];
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Save permissions to config file
|
|
52
|
+
*/
|
|
53
|
+
savePermissions() {
|
|
54
|
+
try {
|
|
55
|
+
let config = {};
|
|
56
|
+
if (existsSync(this.configPath)) {
|
|
57
|
+
const configContent = readFileSync(this.configPath, "utf-8");
|
|
58
|
+
config = JSON.parse(configContent);
|
|
59
|
+
}
|
|
60
|
+
config.permissions = {
|
|
61
|
+
allow: this.permissions.filter((p) => p.type === "allow").map((p) => p.pattern),
|
|
62
|
+
deny: this.permissions.filter((p) => p.type === "deny").map((p) => p.pattern)
|
|
63
|
+
};
|
|
64
|
+
writeFileSync(this.configPath, JSON.stringify(config, null, 2), "utf-8");
|
|
65
|
+
} catch (error) {
|
|
66
|
+
throw new Error(`Failed to save permissions: ${error instanceof Error ? error.message : String(error)}`);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Check if an action on a resource is permitted
|
|
71
|
+
* @param action - The action to check (e.g., "read", "write", "admin")
|
|
72
|
+
* @param resource - The resource identifier (e.g., "Provider(302ai)", "Model(claude-opus)")
|
|
73
|
+
* @returns Permission check result
|
|
74
|
+
*/
|
|
75
|
+
checkPermission(action, resource) {
|
|
76
|
+
const target = `${resource}:${action}`;
|
|
77
|
+
for (const permission of this.permissions) {
|
|
78
|
+
if (permission.type === "deny" && this.matchPattern(permission.pattern, target)) {
|
|
79
|
+
return {
|
|
80
|
+
allowed: false,
|
|
81
|
+
matchedRule: permission,
|
|
82
|
+
reason: `Denied by rule: ${permission.pattern}`
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
for (const permission of this.permissions) {
|
|
87
|
+
if (permission.type === "allow" && this.matchPattern(permission.pattern, target)) {
|
|
88
|
+
return {
|
|
89
|
+
allowed: true,
|
|
90
|
+
matchedRule: permission,
|
|
91
|
+
reason: `Allowed by rule: ${permission.pattern}`
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return {
|
|
96
|
+
allowed: false,
|
|
97
|
+
reason: "No matching permission rule found (default deny)"
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Match a pattern against a target string
|
|
102
|
+
* Supports wildcards: * (any characters), ? (single character)
|
|
103
|
+
* @param pattern - Pattern with wildcards
|
|
104
|
+
* @param target - Target string to match
|
|
105
|
+
* @returns True if pattern matches target
|
|
106
|
+
*/
|
|
107
|
+
matchPattern(pattern, target) {
|
|
108
|
+
const regexPattern = pattern.replace(/[.+^${}()|[\]\\]/g, "\\$&").replace(/\*/g, ".*").replace(/\?/g, ".");
|
|
109
|
+
const regex = new RegExp(`^${regexPattern}$`, "i");
|
|
110
|
+
return regex.test(target);
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Add a permission rule
|
|
114
|
+
* @param permission - Permission to add
|
|
115
|
+
*/
|
|
116
|
+
addPermission(permission) {
|
|
117
|
+
const existingIndex = this.permissions.findIndex(
|
|
118
|
+
(p) => p.pattern === permission.pattern && p.type === permission.type
|
|
119
|
+
);
|
|
120
|
+
if (existingIndex >= 0) {
|
|
121
|
+
this.permissions[existingIndex] = {
|
|
122
|
+
...permission,
|
|
123
|
+
createdAt: this.permissions[existingIndex].createdAt || (/* @__PURE__ */ new Date()).toISOString()
|
|
124
|
+
};
|
|
125
|
+
} else {
|
|
126
|
+
this.permissions.push({
|
|
127
|
+
...permission,
|
|
128
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
this.savePermissions();
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Remove a permission rule by pattern
|
|
135
|
+
* @param pattern - Pattern to remove
|
|
136
|
+
* @param type - Optional type filter
|
|
137
|
+
* @returns Number of rules removed
|
|
138
|
+
*/
|
|
139
|
+
removePermission(pattern, type) {
|
|
140
|
+
const initialLength = this.permissions.length;
|
|
141
|
+
this.permissions = this.permissions.filter((p) => {
|
|
142
|
+
if (type) {
|
|
143
|
+
return !(p.pattern === pattern && p.type === type);
|
|
144
|
+
}
|
|
145
|
+
return p.pattern !== pattern;
|
|
146
|
+
});
|
|
147
|
+
const removedCount = initialLength - this.permissions.length;
|
|
148
|
+
if (removedCount > 0) {
|
|
149
|
+
this.savePermissions();
|
|
150
|
+
}
|
|
151
|
+
return removedCount;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* List all permissions
|
|
155
|
+
* @param type - Optional filter by type
|
|
156
|
+
* @param scope - Optional filter by scope
|
|
157
|
+
* @returns Array of permissions
|
|
158
|
+
*/
|
|
159
|
+
listPermissions(type, scope) {
|
|
160
|
+
let filtered = [...this.permissions];
|
|
161
|
+
if (type) {
|
|
162
|
+
filtered = filtered.filter((p) => p.type === type);
|
|
163
|
+
}
|
|
164
|
+
if (scope) {
|
|
165
|
+
filtered = filtered.filter((p) => p.scope === scope);
|
|
166
|
+
}
|
|
167
|
+
return filtered;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Clear all permissions
|
|
171
|
+
* @param type - Optional type to clear (if not specified, clears all)
|
|
172
|
+
*/
|
|
173
|
+
clearPermissions(type) {
|
|
174
|
+
if (type) {
|
|
175
|
+
this.permissions = this.permissions.filter((p) => p.type !== type);
|
|
176
|
+
} else {
|
|
177
|
+
this.permissions = [];
|
|
178
|
+
}
|
|
179
|
+
this.savePermissions();
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Get permission statistics
|
|
183
|
+
*/
|
|
184
|
+
getStats() {
|
|
185
|
+
return {
|
|
186
|
+
total: this.permissions.length,
|
|
187
|
+
allow: this.permissions.filter((p) => p.type === "allow").length,
|
|
188
|
+
deny: this.permissions.filter((p) => p.type === "deny").length
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Export permissions to JSON
|
|
193
|
+
*/
|
|
194
|
+
exportPermissions() {
|
|
195
|
+
return {
|
|
196
|
+
allow: this.permissions.filter((p) => p.type === "allow").map((p) => p.pattern),
|
|
197
|
+
deny: this.permissions.filter((p) => p.type === "deny").map((p) => p.pattern)
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Import permissions from JSON
|
|
202
|
+
* @param config - Permission configuration to import
|
|
203
|
+
* @param merge - If true, merge with existing permissions; if false, replace
|
|
204
|
+
*/
|
|
205
|
+
importPermissions(config, merge = false) {
|
|
206
|
+
if (!merge) {
|
|
207
|
+
this.permissions = [];
|
|
208
|
+
}
|
|
209
|
+
if (Array.isArray(config.allow)) {
|
|
210
|
+
config.allow.forEach((pattern) => {
|
|
211
|
+
this.addPermission({
|
|
212
|
+
type: "allow",
|
|
213
|
+
pattern,
|
|
214
|
+
scope: "global"
|
|
215
|
+
});
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
if (Array.isArray(config.deny)) {
|
|
219
|
+
config.deny.forEach((pattern) => {
|
|
220
|
+
this.addPermission({
|
|
221
|
+
type: "deny",
|
|
222
|
+
pattern,
|
|
223
|
+
scope: "global"
|
|
224
|
+
});
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
const permissionManager = PermissionManager.getInstance();
|
|
231
|
+
async function listPermissions(options) {
|
|
232
|
+
const format = options.format || "table";
|
|
233
|
+
const verbose = options.verbose || false;
|
|
234
|
+
const permissions = permissionManager.getAllPermissions();
|
|
235
|
+
if (format === "json") {
|
|
236
|
+
console.log(JSON.stringify(permissions, null, 2));
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
console.log(chalk.bold("\n\u{1F4CB} CCJK Permissions\n"));
|
|
240
|
+
if (permissions.length === 0) {
|
|
241
|
+
console.log(chalk.yellow("No permissions configured."));
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
if (format === "list") {
|
|
245
|
+
for (const perm of permissions) {
|
|
246
|
+
const levelColor = getLevelColor(perm.level);
|
|
247
|
+
console.log(`${chalk.cyan(perm.resource)}: ${levelColor(perm.level)}`);
|
|
248
|
+
if (verbose && perm.metadata) {
|
|
249
|
+
console.log(chalk.gray(` Metadata: ${JSON.stringify(perm.metadata)}`));
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
} else {
|
|
253
|
+
console.log(chalk.bold("Resource".padEnd(40)) + chalk.bold("Level".padEnd(15)) + chalk.bold("Granted At"));
|
|
254
|
+
console.log("\u2500".repeat(70));
|
|
255
|
+
for (const perm of permissions) {
|
|
256
|
+
const levelColor = getLevelColor(perm.level);
|
|
257
|
+
const resource = perm.resource.padEnd(40);
|
|
258
|
+
const level = levelColor(perm.level.padEnd(15));
|
|
259
|
+
const grantedAt = new Date(perm.grantedAt).toLocaleString();
|
|
260
|
+
console.log(`${resource}${level}${grantedAt}`);
|
|
261
|
+
if (verbose && perm.metadata) {
|
|
262
|
+
console.log(chalk.gray(` Metadata: ${JSON.stringify(perm.metadata)}`));
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
console.log();
|
|
267
|
+
}
|
|
268
|
+
async function checkPermission(resource, options) {
|
|
269
|
+
if (!resource) {
|
|
270
|
+
console.error(chalk.red("Error: Resource is required"));
|
|
271
|
+
console.log("Usage: ccjk permissions check <resource>");
|
|
272
|
+
process__default.exit(1);
|
|
273
|
+
}
|
|
274
|
+
const verbose = options.verbose || false;
|
|
275
|
+
console.log(chalk.bold(`
|
|
276
|
+
\u{1F50D} Checking permission for: ${chalk.cyan(resource)}
|
|
277
|
+
`));
|
|
278
|
+
const hasPermission = await permissionManager.checkPermission(resource, "read");
|
|
279
|
+
const permission = permissionManager.getPermission(resource);
|
|
280
|
+
if (hasPermission) {
|
|
281
|
+
console.log(chalk.green("\u2713 Permission granted"));
|
|
282
|
+
if (permission) {
|
|
283
|
+
const levelColor = getLevelColor(permission.level);
|
|
284
|
+
console.log(` Level: ${levelColor(permission.level)}`);
|
|
285
|
+
console.log(` Granted at: ${new Date(permission.grantedAt).toLocaleString()}`);
|
|
286
|
+
if (verbose && permission.metadata) {
|
|
287
|
+
console.log(` Metadata: ${JSON.stringify(permission.metadata, null, 2)}`);
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
} else {
|
|
291
|
+
console.log(chalk.red("\u2717 Permission denied"));
|
|
292
|
+
console.log(chalk.yellow(' Use "ccjk permissions grant" to grant permission'));
|
|
293
|
+
}
|
|
294
|
+
console.log();
|
|
295
|
+
}
|
|
296
|
+
async function grantPermission(resource, _options) {
|
|
297
|
+
if (!resource) {
|
|
298
|
+
console.error(chalk.red("Error: Resource is required"));
|
|
299
|
+
console.log("Usage: ccjk permissions grant <resource>");
|
|
300
|
+
process__default.exit(1);
|
|
301
|
+
}
|
|
302
|
+
console.log(chalk.bold(`
|
|
303
|
+
\u2713 Granting permission for: ${chalk.cyan(resource)}
|
|
304
|
+
`));
|
|
305
|
+
await permissionManager.grantPermission(resource, "full", {
|
|
306
|
+
grantedBy: "cli",
|
|
307
|
+
grantedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
308
|
+
});
|
|
309
|
+
console.log(chalk.green("Permission granted successfully!"));
|
|
310
|
+
console.log();
|
|
311
|
+
}
|
|
312
|
+
async function revokePermission(resource, _options) {
|
|
313
|
+
if (!resource) {
|
|
314
|
+
console.error(chalk.red("Error: Resource is required"));
|
|
315
|
+
console.log("Usage: ccjk permissions revoke <resource>");
|
|
316
|
+
process__default.exit(1);
|
|
317
|
+
}
|
|
318
|
+
console.log(chalk.bold(`
|
|
319
|
+
\u2717 Revoking permission for: ${chalk.cyan(resource)}
|
|
320
|
+
`));
|
|
321
|
+
await permissionManager.revokePermission(resource);
|
|
322
|
+
console.log(chalk.green("Permission revoked successfully!"));
|
|
323
|
+
console.log();
|
|
324
|
+
}
|
|
325
|
+
async function resetPermissions(_options) {
|
|
326
|
+
console.log(chalk.bold("\n\u26A0\uFE0F Resetting all permissions\n"));
|
|
327
|
+
const readline = await import('node:readline');
|
|
328
|
+
const rl = readline.createInterface({
|
|
329
|
+
input: process__default.stdin,
|
|
330
|
+
output: process__default.stdout
|
|
331
|
+
});
|
|
332
|
+
const answer = await new Promise((resolve) => {
|
|
333
|
+
rl.question(chalk.yellow("Are you sure you want to reset all permissions? (yes/no): "), resolve);
|
|
334
|
+
});
|
|
335
|
+
rl.close();
|
|
336
|
+
if (answer.toLowerCase() !== "yes") {
|
|
337
|
+
console.log(chalk.gray("Operation cancelled."));
|
|
338
|
+
return;
|
|
339
|
+
}
|
|
340
|
+
await permissionManager.clearAllPermissions();
|
|
341
|
+
console.log(chalk.green("All permissions have been reset!"));
|
|
342
|
+
console.log();
|
|
343
|
+
}
|
|
344
|
+
async function exportPermissions(filePath, _options) {
|
|
345
|
+
const fs = await import('node:fs/promises');
|
|
346
|
+
const path = await import('node:path');
|
|
347
|
+
const outputPath = filePath || path.join(process__default.cwd(), "permissions.json");
|
|
348
|
+
console.log(chalk.bold(`
|
|
349
|
+
\u{1F4E4} Exporting permissions to: ${chalk.cyan(outputPath)}
|
|
350
|
+
`));
|
|
351
|
+
const permissions = permissionManager.getAllPermissions();
|
|
352
|
+
await fs.writeFile(outputPath, JSON.stringify(permissions, null, 2), "utf-8");
|
|
353
|
+
console.log(chalk.green(`Exported ${permissions.length} permissions successfully!`));
|
|
354
|
+
console.log();
|
|
355
|
+
}
|
|
356
|
+
async function importPermissions(filePath, _options) {
|
|
357
|
+
if (!filePath) {
|
|
358
|
+
console.error(chalk.red("Error: File path is required"));
|
|
359
|
+
console.log("Usage: ccjk permissions import <file>");
|
|
360
|
+
process__default.exit(1);
|
|
361
|
+
}
|
|
362
|
+
const fs = await import('node:fs/promises');
|
|
363
|
+
console.log(chalk.bold(`
|
|
364
|
+
\u{1F4E5} Importing permissions from: ${chalk.cyan(filePath)}
|
|
365
|
+
`));
|
|
366
|
+
try {
|
|
367
|
+
const content = await fs.readFile(filePath, "utf-8");
|
|
368
|
+
const permissions = JSON.parse(content);
|
|
369
|
+
if (!Array.isArray(permissions)) {
|
|
370
|
+
throw new TypeError("Invalid permissions file format");
|
|
371
|
+
}
|
|
372
|
+
await permissionManager.clearAllPermissions();
|
|
373
|
+
for (const perm of permissions) {
|
|
374
|
+
await permissionManager.grantPermission(perm.resource, perm.level, perm.metadata);
|
|
375
|
+
}
|
|
376
|
+
console.log(chalk.green(`Imported ${permissions.length} permissions successfully!`));
|
|
377
|
+
} catch (error) {
|
|
378
|
+
console.error(chalk.red("Error importing permissions:"), error);
|
|
379
|
+
process__default.exit(1);
|
|
380
|
+
}
|
|
381
|
+
console.log();
|
|
382
|
+
}
|
|
383
|
+
function permissionsHelp(_options) {
|
|
384
|
+
console.log(chalk.bold("\n\u{1F4CB} CCJK Permissions Management\n"));
|
|
385
|
+
console.log(chalk.bold("Usage:"));
|
|
386
|
+
console.log(" ccjk permissions [action] [...args]\n");
|
|
387
|
+
console.log(chalk.bold("Actions:"));
|
|
388
|
+
console.log(" list List all permissions");
|
|
389
|
+
console.log(" check <resource> Check permission for a resource");
|
|
390
|
+
console.log(" grant <resource> Grant permission for a resource");
|
|
391
|
+
console.log(" revoke <resource> Revoke permission for a resource");
|
|
392
|
+
console.log(" reset Reset all permissions");
|
|
393
|
+
console.log(" export [file] Export permissions to a file");
|
|
394
|
+
console.log(" import <file> Import permissions from a file\n");
|
|
395
|
+
console.log(chalk.bold("Options:"));
|
|
396
|
+
console.log(" --format, -f Output format (table|json|list)");
|
|
397
|
+
console.log(" --verbose, -v Verbose output\n");
|
|
398
|
+
console.log(chalk.bold("Examples:"));
|
|
399
|
+
console.log(" ccjk permissions list");
|
|
400
|
+
console.log(" ccjk permissions check file:///path/to/file");
|
|
401
|
+
console.log(" ccjk permissions grant mcp://server-name");
|
|
402
|
+
console.log(" ccjk permissions export permissions.json");
|
|
403
|
+
console.log(" ccjk permissions import permissions.json\n");
|
|
404
|
+
}
|
|
405
|
+
function getLevelColor(level) {
|
|
406
|
+
switch (level) {
|
|
407
|
+
case "none":
|
|
408
|
+
return chalk.red;
|
|
409
|
+
case "read":
|
|
410
|
+
return chalk.yellow;
|
|
411
|
+
case "write":
|
|
412
|
+
return chalk.blue;
|
|
413
|
+
case "full":
|
|
414
|
+
return chalk.green;
|
|
415
|
+
default:
|
|
416
|
+
return chalk.gray;
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
export { checkPermission, exportPermissions, grantPermission, importPermissions, listPermissions, permissionsHelp, resetPermissions, revokePermission };
|
package/dist/chunks/prompts.mjs
CHANGED
|
@@ -4,7 +4,7 @@ import inquirer from 'inquirer';
|
|
|
4
4
|
import { version } from './package.mjs';
|
|
5
5
|
import { LANG_LABELS, getAiOutputLanguageLabel, SUPPORTED_LANGS, AI_OUTPUT_LANGUAGES } from './constants.mjs';
|
|
6
6
|
import { ensureI18nInitialized, i18n } from './index2.mjs';
|
|
7
|
-
import {
|
|
7
|
+
import { readZcfConfig, updateZcfConfig } from './ccjk-config.mjs';
|
|
8
8
|
import { a as addNumbersToChoices, p as promptBoolean } from '../shared/ccjk.DhBeLRzf.mjs';
|
|
9
9
|
import 'node:os';
|
|
10
10
|
import 'pathe';
|
|
@@ -16,6 +16,7 @@ import 'smol-toml';
|
|
|
16
16
|
import './fs-operations.mjs';
|
|
17
17
|
import 'node:crypto';
|
|
18
18
|
import 'node:fs/promises';
|
|
19
|
+
import './json-config.mjs';
|
|
19
20
|
import 'dayjs';
|
|
20
21
|
import 'inquirer-toggle';
|
|
21
22
|
|