ccjk 9.3.27 → 9.3.28

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.
@@ -1,8 +1,9 @@
1
1
  import ansis from 'ansis';
2
- import { existsSync, readFileSync, writeFileSync, readdirSync } from 'node:fs';
2
+ import { existsSync, readFileSync, mkdirSync, writeFileSync, readdirSync } from 'node:fs';
3
3
  import { homedir } from 'node:os';
4
4
  import { join } from 'pathe';
5
5
  import { g as getPluginManager } from '../shared/ccjk.Bn0NjSvL.mjs';
6
+ import { w as writeAgentFile } from '../shared/ccjk.zEYnsS6R.mjs';
6
7
  import 'tinyexec';
7
8
  import 'node:child_process';
8
9
  import '../shared/ccjk.Bdhyg3X-.mjs';
@@ -759,6 +760,9 @@ class AgentCreator {
759
760
  * Save a template
760
761
  */
761
762
  async saveTemplate(templateId, template) {
763
+ if (!existsSync(AGENT_TEMPLATES_DIR)) {
764
+ mkdirSync(AGENT_TEMPLATES_DIR, { recursive: true });
765
+ }
762
766
  const templatePath = join(AGENT_TEMPLATES_DIR, `${templateId}.json`);
763
767
  writeFileSync(templatePath, JSON.stringify(template, null, 2));
764
768
  }
@@ -770,13 +774,23 @@ class AgentCreator {
770
774
  if (existsSync(AGENT_TEMPLATES_DIR)) {
771
775
  const files = readdirSync(AGENT_TEMPLATES_DIR);
772
776
  for (const file of files) {
773
- if (file.endsWith(".json")) {
774
- templates.push(file.replace(".json", ""));
777
+ if (file.endsWith(".json") || file.endsWith(".md")) {
778
+ templates.push(file.replace(/\.(json|md)$/, ""));
775
779
  }
776
780
  }
777
781
  }
778
782
  return templates;
779
783
  }
784
+ /**
785
+ * Write agent to Claude Code compatible location (project-local .claude/agents/)
786
+ */
787
+ async writeToClaudeCode(agent, options) {
788
+ return writeAgentFile(agent, {
789
+ format: "markdown",
790
+ projectDir: options?.projectDir,
791
+ global: false
792
+ });
793
+ }
780
794
  }
781
795
  class AgentRuntime {
782
796
  context;
@@ -3,9 +3,10 @@ import process__default, { cwd } from 'node:process';
3
3
  import { P as ProjectAnalyzer, g as getTemplatesClient } from '../shared/ccjk.CcFAyU1D.mjs';
4
4
  import { join, dirname } from 'pathe';
5
5
  import { fileURLToPath } from 'node:url';
6
- import { existsSync, readdirSync, readFileSync, writeFileSync, mkdirSync } from 'node:fs';
6
+ import { existsSync, readdirSync, readFileSync, writeFileSync } from 'node:fs';
7
7
  import { homedir } from 'node:os';
8
8
  import { i18n } from './index.mjs';
9
+ import { w as writeAgentFile } from '../shared/ccjk.zEYnsS6R.mjs';
9
10
  import { e as extractDisplayName, a as extractString } from '../shared/ccjk.AqnXPAzw.mjs';
10
11
  import 'fs-extra';
11
12
  import 'fs';
@@ -59,12 +60,12 @@ async function loadAgentTemplates() {
59
60
  return templates;
60
61
  }
61
62
 
62
- const AGENTS_DIR$1 = join(homedir(), ".ccjk", "agents");
63
+ const AGENTS_DIR = join(homedir(), ".ccjk", "agents");
63
64
  async function registerAgent(agent) {
64
- const agentId = "id" in agent ? agent.id : generateAgentId$1(agent);
65
- join(AGENTS_DIR$1, `${agentId}.json`);
66
- if (!existsSync(AGENTS_DIR$1)) ;
67
- const registryPath = join(AGENTS_DIR$1, "registry.json");
65
+ const agentId = "id" in agent ? agent.id : generateAgentId(agent);
66
+ join(AGENTS_DIR, `${agentId}.json`);
67
+ if (!existsSync(AGENTS_DIR)) ;
68
+ const registryPath = join(AGENTS_DIR, "registry.json");
68
69
  let registry = {};
69
70
  if (existsSync(registryPath)) {
70
71
  try {
@@ -78,7 +79,7 @@ async function registerAgent(agent) {
78
79
  };
79
80
  writeFileSync(registryPath, JSON.stringify(registry, null, 2));
80
81
  }
81
- function generateAgentId$1(agent) {
82
+ function generateAgentId(agent) {
82
83
  const name = agent.name || agent.role || "agent";
83
84
  return name.toLowerCase().replace(/\s+/g, "-") + "-" + Date.now();
84
85
  }
@@ -128,30 +129,6 @@ function validateAgentDefinition(agent) {
128
129
  };
129
130
  }
130
131
 
131
- const AGENTS_DIR = join(homedir(), ".ccjk", "agents");
132
- async function writeAgentFile(agent, options) {
133
- const format = "json";
134
- const agentId = generateAgentId(agent);
135
- const fileName = `${agentId}.${format}`;
136
- const filePath = join(AGENTS_DIR, fileName);
137
- if (!existsSync(AGENTS_DIR)) {
138
- mkdirSync(AGENTS_DIR, { recursive: true });
139
- }
140
- let content;
141
- {
142
- content = JSON.stringify(agent, null, 0);
143
- }
144
- writeFileSync(filePath, content, "utf-8");
145
- return filePath;
146
- }
147
- function generateAgentId(agent) {
148
- if (agent.id) {
149
- return agent.id.toLowerCase().replace(/\s+/g, "-");
150
- }
151
- const name = typeof agent.name === "string" ? agent.name : agent.name?.en || agent.name?.["zh-CN"] || "unknown-agent";
152
- return name.toLowerCase().replace(/\s+/g, "-");
153
- }
154
-
155
132
  async function ccjkAgents(options = {}) {
156
133
  try {
157
134
  if (options.lang) {
@@ -34,6 +34,7 @@ import './fs-operations.mjs';
34
34
  import 'node:fs/promises';
35
35
  import './platform.mjs';
36
36
  import 'tinyexec';
37
+ import '../shared/ccjk.zEYnsS6R.mjs';
37
38
  import 'node:child_process';
38
39
  import 'node:util';
39
40
  import 'node:perf_hooks';
@@ -33,6 +33,7 @@ import 'node:crypto';
33
33
  import 'node:fs/promises';
34
34
  import './platform.mjs';
35
35
  import 'tinyexec';
36
+ import '../shared/ccjk.zEYnsS6R.mjs';
36
37
  import '../shared/ccjk.AqnXPAzw.mjs';
37
38
  import 'node:child_process';
38
39
  import 'node:util';
@@ -55,6 +55,7 @@ import 'path';
55
55
  import 'url';
56
56
  import 'module';
57
57
  import 'ofetch';
58
+ import '../shared/ccjk.zEYnsS6R.mjs';
58
59
  import '../shared/ccjk.AqnXPAzw.mjs';
59
60
  import './ccjk-mcp.mjs';
60
61
  import './ccjk-skills.mjs';
@@ -61,6 +61,7 @@ import 'path';
61
61
  import 'url';
62
62
  import 'module';
63
63
  import 'ofetch';
64
+ import '../shared/ccjk.zEYnsS6R.mjs';
64
65
  import '../shared/ccjk.AqnXPAzw.mjs';
65
66
  import '../shared/ccjk.Bdhyg3X-.mjs';
66
67
  import './api-providers.mjs';
@@ -1,4 +1,4 @@
1
- const version = "9.3.27";
1
+ const version = "9.3.28";
2
2
  const homepage = "https://github.com/miounet11/ccjk";
3
3
 
4
4
  export { homepage, version };
@@ -2,6 +2,7 @@ import ansis from 'ansis';
2
2
  import inquirer from 'inquirer';
3
3
  import { i18n } from './index.mjs';
4
4
  import { existsSync, unlinkSync, mkdirSync, readdirSync, readFileSync } from 'node:fs';
5
+ import 'node:os';
5
6
  import { join } from 'pathe';
6
7
  import { CCJK_SKILLS_DIR } from './constants.mjs';
7
8
  import { writeFileAtomic } from './fs-operations.mjs';
@@ -9,7 +10,6 @@ import 'node:process';
9
10
  import 'node:url';
10
11
  import 'i18next';
11
12
  import 'i18next-fs-backend';
12
- import 'node:os';
13
13
  import 'node:crypto';
14
14
  import 'node:fs/promises';
15
15
 
@@ -0,0 +1,114 @@
1
+ import { join } from 'pathe';
2
+ import { homedir } from 'node:os';
3
+ import { existsSync, mkdirSync, writeFileSync } from 'node:fs';
4
+
5
+ const getProjectAgentsDir = (projectDir) => join(projectDir || process.cwd(), ".claude", "agents");
6
+ const LEGACY_AGENTS_DIR = join(homedir(), ".ccjk", "agents");
7
+ const AGENT_COLORS = ["blue", "green", "orange", "purple", "red", "yellow", "cyan", "pink"];
8
+ function agentToMarkdown(agent, options) {
9
+ const name = generateAgentId(agent);
10
+ const description = typeof agent.description === "string" ? agent.description : agent.description?.en || agent.description?.["zh-CN"] || "";
11
+ const tools = options?.tools || [];
12
+ if (agent.skills?.length) {
13
+ tools.push(...agent.skills.map((s) => s.skillId || s.pluginId));
14
+ }
15
+ if (agent.mcpServers?.length) {
16
+ tools.push(...agent.mcpServers.map((m) => `mcp__${m.serverName}`));
17
+ }
18
+ const color = options?.color || selectAgentColor(agent);
19
+ const frontmatter = [
20
+ "---",
21
+ `name: ${name}`,
22
+ `description: ${description}`
23
+ ];
24
+ if (tools.length > 0) {
25
+ frontmatter.push(`tools: ${tools.join(", ")}`);
26
+ }
27
+ frontmatter.push(`color: ${color}`);
28
+ frontmatter.push("---");
29
+ const body = [];
30
+ if (agent.persona) {
31
+ body.push("");
32
+ body.push(agent.persona);
33
+ }
34
+ if (agent.instructions) {
35
+ body.push("");
36
+ body.push("## Instructions");
37
+ body.push("");
38
+ body.push(agent.instructions);
39
+ }
40
+ if (agent.capabilities?.length) {
41
+ body.push("");
42
+ body.push("## Capabilities");
43
+ body.push("");
44
+ for (const cap of agent.capabilities) {
45
+ body.push(`- ${formatCapability(cap)}`);
46
+ }
47
+ }
48
+ if (agent.triggers?.length) {
49
+ body.push("");
50
+ body.push("## Triggers");
51
+ body.push("");
52
+ for (const trigger of agent.triggers) {
53
+ body.push(`- ${trigger}`);
54
+ }
55
+ }
56
+ return frontmatter.join("\n") + body.join("\n") + "\n";
57
+ }
58
+ function selectAgentColor(agent) {
59
+ const caps = agent.capabilities || [];
60
+ if (caps.includes("code-generation") || caps.includes("code-review")) return "blue";
61
+ if (caps.includes("testing")) return "green";
62
+ if (caps.includes("debugging")) return "orange";
63
+ if (caps.includes("deployment")) return "purple";
64
+ if (caps.includes("documentation")) return "cyan";
65
+ if (caps.includes("git-operations")) return "yellow";
66
+ if (caps.includes("web-search") || caps.includes("api-integration")) return "pink";
67
+ const hash = agent.id?.split("").reduce((a, c) => a + c.charCodeAt(0), 0) || 0;
68
+ return AGENT_COLORS[hash % AGENT_COLORS.length];
69
+ }
70
+ function formatCapability(cap) {
71
+ const labels = {
72
+ "code-generation": "Code Generation",
73
+ "code-review": "Code Review",
74
+ "testing": "Testing",
75
+ "documentation": "Documentation",
76
+ "deployment": "Deployment",
77
+ "debugging": "Debugging",
78
+ "refactoring": "Refactoring",
79
+ "git-operations": "Git Operations",
80
+ "file-management": "File Management",
81
+ "web-search": "Web Search",
82
+ "api-integration": "API Integration"
83
+ };
84
+ return labels[cap] || cap;
85
+ }
86
+ async function writeAgentFile(agent, options) {
87
+ const format = options?.format || "markdown";
88
+ const agentId = generateAgentId(agent);
89
+ const isGlobal = options?.global || false;
90
+ const agentsDir = isGlobal ? LEGACY_AGENTS_DIR : getProjectAgentsDir(options?.projectDir);
91
+ const ext = format === "markdown" ? "md" : "json";
92
+ const fileName = `${agentId}.${ext}`;
93
+ const filePath = join(agentsDir, fileName);
94
+ if (!existsSync(agentsDir)) {
95
+ mkdirSync(agentsDir, { recursive: true });
96
+ }
97
+ let content;
98
+ if (format === "markdown") {
99
+ content = agentToMarkdown(agent, options);
100
+ } else {
101
+ content = JSON.stringify(agent, null, options?.pretty ? 2 : 0);
102
+ }
103
+ writeFileSync(filePath, content, "utf-8");
104
+ return filePath;
105
+ }
106
+ function generateAgentId(agent) {
107
+ if (agent.id) {
108
+ return agent.id.toLowerCase().replace(/\s+/g, "-");
109
+ }
110
+ const name = typeof agent.name === "string" ? agent.name : agent.name?.en || agent.name?.["zh-CN"] || "unknown-agent";
111
+ return name.toLowerCase().replace(/\s+/g, "-");
112
+ }
113
+
114
+ export { writeAgentFile as w };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ccjk",
3
3
  "type": "module",
4
- "version": "9.3.27",
4
+ "version": "9.3.28",
5
5
  "packageManager": "pnpm@10.17.1",
6
6
  "description": "CCJK v9.0.0 - Revolutionary AI Development Platform with Enterprise Security, Streaming Cloud Sync, CRDT Conflict Resolution, and Unified V3 Architecture",
7
7
  "author": {