nx-ce 0.1.1 → 0.1.3

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nx-ce",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "Claude Engine — SDK adapter layer for native messaging host. Bridges @anthropic-ai/claude-agent-sdk calls over a length-prefixed JSON protocol.",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
package/src/cli.js CHANGED
@@ -8,6 +8,7 @@
8
8
  import { existsSync } from 'node:fs';
9
9
  import { runQuery } from './query.js';
10
10
  import { startServe } from './serve.js';
11
+ import { listSkills } from './skills.js';
11
12
  import { readState, listStates } from './session-store.js';
12
13
 
13
14
  /**
@@ -105,6 +106,15 @@ export async function runCli() {
105
106
  return listStates(); // 列出所有实例
106
107
  }
107
108
 
109
+ case 'skills': {
110
+ const result = await listSkills({
111
+ cwd: flags.cwd || process.cwd(),
112
+ claudePath: resolveClaudePath(flags['claude-path']),
113
+ env: flags.env ? parseEnvString(flags.env) : undefined,
114
+ });
115
+ return result;
116
+ }
117
+
108
118
  case 'help':
109
119
  default:
110
120
  // 显示帮助信息
@@ -130,6 +140,8 @@ export async function runCli() {
130
140
 
131
141
  nx-ce status [--name <name>] 查看实例状态
132
142
 
143
+ nx-ce skills [--cwd <path>] 列出 SDK 可用 skill/tool/agent
144
+
133
145
  nx-ce help 显示此帮助
134
146
  `);
135
147
  return null;
package/src/index.js CHANGED
@@ -7,5 +7,6 @@
7
7
  */
8
8
 
9
9
  export { runQuery } from './query.js';
10
+ export { listSkills } from './skills.js';
10
11
  export { readState, writeState, deleteState, listStates } from './session-store.js';
11
12
  export { readMessage, writeMessage } from './protocol.js';
package/src/skills.js ADDED
@@ -0,0 +1,56 @@
1
+ /**
2
+ * skills — 查询 SDK 可用的 skill / tool / agent 列表
3
+ *
4
+ * 使用一次超轻量 agentQuery() 获取 init 元数据。
5
+ * 不发起真正对话,不持久化 session。
6
+ */
7
+
8
+ import { query as agentQuery } from '@anthropic-ai/claude-agent-sdk';
9
+
10
+ /**
11
+ * 获取 SDK 可用的 skills/tools/slashCommands/agents 列表。
12
+ *
13
+ * @param {object} [options]
14
+ * @param {string} [options.cwd] - 工作目录
15
+ * @param {string} [options.claudePath] - Claude CLI 路径
16
+ * @param {object} [options.env] - 额外环境变量
17
+ * @returns {Promise<{ skills: string[], tools: string[], slashCommands: string[], agents: string[] }>}
18
+ */
19
+ export async function listSkills(options = {}) {
20
+ const sdkOptions = {
21
+ cwd: options.cwd || process.cwd(),
22
+ model: 'claude-haiku-4-5',
23
+ permissionMode: 'bypassPermissions',
24
+ allowDangerouslySkipPermissions: true,
25
+ persistSession: false,
26
+ env: { ...process.env, ...options.env },
27
+ };
28
+
29
+ if (options.claudePath) {
30
+ sdkOptions.pathToClaudeCodeExecutable = options.claudePath;
31
+ }
32
+
33
+ // 用空 prompt 做一次超轻量 init
34
+ const response = agentQuery({ prompt: ' ', options: sdkOptions });
35
+
36
+ const result = {
37
+ skills: [],
38
+ tools: [],
39
+ slashCommands: [],
40
+ agents: [],
41
+ };
42
+
43
+ for await (const message of response) {
44
+ if (message.type === 'system' && message.subtype === 'init') {
45
+ if (Array.isArray(message.skills)) result.skills = message.skills;
46
+ if (Array.isArray(message.tools)) result.tools = message.tools;
47
+ if (Array.isArray(message.slash_commands)) result.slashCommands = message.slash_commands;
48
+ if (Array.isArray(message.agents)) result.agents = message.agents;
49
+ // init 消息后立即中断,不继续消耗资源
50
+ await response.interrupt().catch(() => {});
51
+ break;
52
+ }
53
+ }
54
+
55
+ return result;
56
+ }