jinzd-ai-cli 0.3.3 → 0.3.4

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.
@@ -45,6 +45,7 @@ async function joinHub(options, configManager, providers) {
45
45
  let myRoleName = "";
46
46
  let topic = "";
47
47
  let allRoles = [];
48
+ let hubContext;
48
49
  let persona = "";
49
50
  ws.on("open", () => {
50
51
  console.log(chalk.green(" \u2713 Connected to Hub"));
@@ -76,6 +77,7 @@ async function joinHub(options, configManager, providers) {
76
77
  myRoleName = msg.roleName;
77
78
  topic = msg.topic;
78
79
  allRoles = msg.roles;
80
+ hubContext = msg.context;
79
81
  persona = buildPersonaFromRole(myRoleId, myRoleName);
80
82
  console.log(chalk.bold(` \u{1F4CB} Assigned role: ${chalk.cyan(myRoleName)} (${myRoleId})`));
81
83
  if (topic) {
@@ -108,7 +110,8 @@ async function joinHub(options, configManager, providers) {
108
110
  persona,
109
111
  providers,
110
112
  defaultProvider,
111
- defaultModel
113
+ defaultModel,
114
+ hubContext
112
115
  );
113
116
  } catch (err) {
114
117
  console.error(chalk.red(` \u2717 Response error: ${err.message}`));
@@ -181,9 +184,13 @@ async function joinHub(options, configManager, providers) {
181
184
  await new Promise(() => {
182
185
  });
183
186
  }
184
- async function generateResponse(topic, history, round, maxRounds, roleId, roleName, persona, providers, providerId, modelId) {
187
+ async function generateResponse(topic, history, round, maxRounds, roleId, roleName, persona, providers, providerId, modelId, context) {
185
188
  const provider = providers.get(providerId);
186
189
  if (!provider) throw new Error(`Provider "${providerId}" not available`);
190
+ const contextSection = context ? `
191
+
192
+ ## Reference Documents
193
+ ${context}` : "";
187
194
  const systemPrompt = `# Multi-Agent Discussion \u2014 Role: ${roleName}
188
195
 
189
196
  ${persona}
@@ -198,7 +205,7 @@ ${persona}
198
205
  - Use the language that the topic is written in (if the topic is in Chinese, respond in Chinese).
199
206
 
200
207
  ## Topic
201
- ${topic}`;
208
+ ${topic}${contextSection}`;
202
209
  const messages = [];
203
210
  for (const msg of history) {
204
211
  if (msg.passed) continue;
@@ -16,7 +16,7 @@ import {
16
16
  SUBAGENT_MAX_ROUNDS_LIMIT,
17
17
  VERSION,
18
18
  runTestsTool
19
- } from "./chunk-NLSQEHZU.js";
19
+ } from "./chunk-HUQVG74X.js";
20
20
 
21
21
  // src/config/config-manager.ts
22
22
  import { readFileSync, writeFileSync, existsSync, mkdirSync } from "fs";
@@ -8,7 +8,7 @@ import { platform } from "os";
8
8
  import chalk from "chalk";
9
9
 
10
10
  // src/core/constants.ts
11
- var VERSION = "0.3.3";
11
+ var VERSION = "0.3.4";
12
12
  var APP_NAME = "ai-cli";
13
13
  var CONFIG_DIR_NAME = ".aicli";
14
14
  var CONFIG_FILE_NAME = "config.json";
@@ -7,11 +7,14 @@ var HubAgent = class {
7
7
  providers;
8
8
  defaultProvider;
9
9
  defaultModel;
10
- constructor(role, providers, defaultProvider, defaultModel) {
10
+ /** External context documents injected into system prompt */
11
+ context;
12
+ constructor(role, providers, defaultProvider, defaultModel, context) {
11
13
  this.role = role;
12
14
  this.providers = providers;
13
15
  this.defaultProvider = defaultProvider;
14
16
  this.defaultModel = defaultModel;
17
+ this.context = context;
15
18
  }
16
19
  get providerId() {
17
20
  return this.role.provider ?? this.defaultProvider;
@@ -75,6 +78,10 @@ var HubAgent = class {
75
78
  }
76
79
  // ── Private ──────────────────────────────────────────────────────
77
80
  buildSystemPrompt(topic, round, maxRounds) {
81
+ const contextSection = this.context ? `
82
+
83
+ ## Reference Documents
84
+ ${this.context}` : "";
78
85
  return `# Multi-Agent Discussion \u2014 Role: ${this.role.name}
79
86
 
80
87
  ${this.role.persona}
@@ -89,7 +96,7 @@ ${this.role.persona}
89
96
  - Use the language that the topic is written in (if the topic is in Chinese, respond in Chinese).
90
97
 
91
98
  ## Topic
92
- ${topic}`;
99
+ ${topic}${contextSection}`;
93
100
  }
94
101
  buildMessages(history) {
95
102
  const messages = [];
@@ -173,13 +180,16 @@ function assignRoleColors(roles) {
173
180
  }
174
181
  });
175
182
  }
176
- function renderHubBanner(topic, roles, maxRounds) {
183
+ function renderHubBanner(topic, roles, maxRounds, contextFiles) {
177
184
  console.log();
178
185
  console.log(chalk.bold.white(" \u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557"));
179
186
  console.log(chalk.bold.white(" \u2551") + chalk.bold.cyan(" \u{1F3DB}\uFE0F AI-CLI Multi-Agent Hub \u2014 Discussion Mode ") + chalk.bold.white("\u2551"));
180
187
  console.log(chalk.bold.white(" \u2560\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2563"));
181
188
  console.log(chalk.bold.white(" \u2551") + chalk.dim(` Topic: ${truncate(topic, 52)}`.padEnd(62)) + chalk.bold.white("\u2551"));
182
189
  console.log(chalk.bold.white(" \u2551") + chalk.dim(` Rounds: up to ${maxRounds}`.padEnd(62)) + chalk.bold.white("\u2551"));
190
+ if (contextFiles && contextFiles.length > 0) {
191
+ console.log(chalk.bold.white(" \u2551") + chalk.dim(` Context: ${contextFiles.join(", ")}`.padEnd(62)) + chalk.bold.white("\u2551"));
192
+ }
183
193
  console.log(chalk.bold.white(" \u2551") + chalk.dim(" Participants:".padEnd(62)) + chalk.bold.white("\u2551"));
184
194
  for (const role of roles) {
185
195
  const color = colorMap.get(role.id) ?? chalk.white;
@@ -6,7 +6,7 @@ import { platform } from "os";
6
6
  import chalk from "chalk";
7
7
 
8
8
  // src/core/constants.ts
9
- var VERSION = "0.3.3";
9
+ var VERSION = "0.3.4";
10
10
  var APP_NAME = "ai-cli";
11
11
  var CONFIG_DIR_NAME = ".aicli";
12
12
  var CONFIG_FILE_NAME = "config.json";
@@ -4,7 +4,7 @@ import {
4
4
  assignRoleColors,
5
5
  renderHubBanner,
6
6
  renderHubEvent
7
- } from "./chunk-4ZAZF4CF.js";
7
+ } from "./chunk-SVOWJLQJ.js";
8
8
 
9
9
  // src/hub/discuss.ts
10
10
  var DiscussionOrchestrator = class {
@@ -12,7 +12,7 @@ var DiscussionOrchestrator = class {
12
12
  this.config = config;
13
13
  this.providers = providers;
14
14
  this.agents = config.roles.map(
15
- (role) => new HubAgent(role, providers, config.defaultProvider, config.defaultModel)
15
+ (role) => new HubAgent(role, providers, config.defaultProvider, config.defaultModel, config.context)
16
16
  );
17
17
  this.state = {
18
18
  topic: "",
@@ -331,13 +331,33 @@ async function startHub(options, configManager, providers) {
331
331
  console.error(' aicli hub --preset brainstorm "your topic here"');
332
332
  process.exit(1);
333
333
  }
334
+ let context;
335
+ const contextFileNames = [];
336
+ if (options.contextFiles && options.contextFiles.length > 0) {
337
+ const parts = [];
338
+ for (const filePath of options.contextFiles) {
339
+ if (!existsSync(filePath)) {
340
+ console.error(` \u2717 Context file not found: ${filePath}`);
341
+ process.exit(1);
342
+ }
343
+ const content = readFileSync(filePath, "utf-8");
344
+ const fileName = filePath.replace(/\\/g, "/").split("/").pop() ?? filePath;
345
+ contextFileNames.push(fileName);
346
+ parts.push(`### ${fileName}
347
+
348
+ ${content}`);
349
+ }
350
+ context = parts.join("\n\n---\n\n");
351
+ }
334
352
  const config = {
335
353
  mode: options.mode ?? "discuss",
336
354
  roles,
337
355
  defaultProvider,
338
356
  defaultModel,
339
357
  maxRounds: options.maxRounds ?? 10,
340
- enableTools: false
358
+ enableTools: false,
359
+ context,
360
+ contextFiles: contextFileNames.length > 0 ? contextFileNames : void 0
341
361
  };
342
362
  if (config.mode === "discuss") {
343
363
  if (options.distributed) {
@@ -351,7 +371,7 @@ async function startHub(options, configManager, providers) {
351
371
  }
352
372
  }
353
373
  async function runDistributedDiscussion(config, providers, topic, port) {
354
- const { HubServer } = await import("./hub-server-P547YWUN.js");
374
+ const { HubServer } = await import("./hub-server-2MT2GPJK.js");
355
375
  const hub = new HubServer(config, providers, port);
356
376
  let interrupted = false;
357
377
  const onSigint = () => {
@@ -387,7 +407,7 @@ async function runDiscussion(config, providers, topic) {
387
407
  orchestrator.abort();
388
408
  };
389
409
  process.on("SIGINT", onSigint);
390
- renderHubBanner(topic, config.roles, config.maxRounds ?? 10);
410
+ renderHubBanner(topic, config.roles, config.maxRounds ?? 10, config.contextFiles);
391
411
  try {
392
412
  await orchestrator.run(topic);
393
413
  } catch (err) {
@@ -11,7 +11,7 @@ import {
11
11
  renderRoundHeader,
12
12
  renderSummary,
13
13
  renderUserInterrupt
14
- } from "./chunk-4ZAZF4CF.js";
14
+ } from "./chunk-SVOWJLQJ.js";
15
15
 
16
16
  // src/hub/hub-server.ts
17
17
  import { WebSocketServer } from "ws";
@@ -43,7 +43,7 @@ var HubServer = class {
43
43
  this.httpServer.listen(this.port, () => resolve());
44
44
  });
45
45
  const maxRounds = this.config.maxRounds ?? 10;
46
- renderHubBanner(topic, this.config.roles, maxRounds);
46
+ renderHubBanner(topic, this.config.roles, maxRounds, this.config.contextFiles);
47
47
  console.log(chalk.bold.cyan(` \u{1F310} Hub server listening on ws://localhost:${this.port}`));
48
48
  console.log(chalk.dim(` Waiting for ${this.config.roles.length} agent(s) to connect...`));
49
49
  console.log(chalk.dim(` Each agent should run: aicli join --port ${this.port}`));
@@ -145,7 +145,8 @@ var HubServer = class {
145
145
  roleName: role.name,
146
146
  topic: "",
147
147
  // Will be sent when discussion starts
148
- roles: this.config.roles.map((r) => ({ id: r.id, name: r.name }))
148
+ roles: this.config.roles.map((r) => ({ id: r.id, name: r.name })),
149
+ context: this.config.context
149
150
  });
150
151
  }
151
152
  // ── Wait for Agents ──────────────────────────────────────────────
@@ -172,7 +173,8 @@ var HubServer = class {
172
173
  roleId: agent.roleId,
173
174
  roleName: agent.roleName,
174
175
  topic,
175
- roles: this.config.roles.map((r) => ({ id: r.id, name: r.name }))
176
+ roles: this.config.roles.map((r) => ({ id: r.id, name: r.name })),
177
+ context: this.config.context
176
178
  });
177
179
  }
178
180
  }
@@ -248,7 +250,7 @@ var HubServer = class {
248
250
  }
249
251
  }
250
252
  async getBuiltinResponse(role, topic, round, maxRounds) {
251
- const agent = new HubAgent(role, this.providers, this.config.defaultProvider, this.config.defaultModel);
253
+ const agent = new HubAgent(role, this.providers, this.config.defaultProvider, this.config.defaultModel, this.config.context);
252
254
  return agent.speak(topic, this.history, round, maxRounds);
253
255
  }
254
256
  async generateSummary(topic) {
@@ -259,7 +261,8 @@ var HubServer = class {
259
261
  this.config.roles[0],
260
262
  this.providers,
261
263
  this.config.defaultProvider,
262
- this.config.defaultModel
264
+ this.config.defaultModel,
265
+ this.config.context
263
266
  );
264
267
  try {
265
268
  console.log(chalk.dim(" Generating summary..."));
package/dist/index.js CHANGED
@@ -36,7 +36,7 @@ import {
36
36
  theme,
37
37
  truncateOutput,
38
38
  undoStack
39
- } from "./chunk-54GQL2O4.js";
39
+ } from "./chunk-6YBF647F.js";
40
40
  import {
41
41
  AGENTIC_BEHAVIOR_GUIDELINE,
42
42
  AUTHOR,
@@ -56,7 +56,7 @@ import {
56
56
  REPO_URL,
57
57
  SKILLS_DIR_NAME,
58
58
  VERSION
59
- } from "./chunk-NLSQEHZU.js";
59
+ } from "./chunk-HUQVG74X.js";
60
60
 
61
61
  // src/index.ts
62
62
  import { program } from "commander";
@@ -1907,7 +1907,7 @@ ${hint}` : "")
1907
1907
  description: "Run project tests and show structured report",
1908
1908
  usage: "/test [command|filter]",
1909
1909
  async execute(args, _ctx) {
1910
- const { executeTests } = await import("./run-tests-WGSNA7K4.js");
1910
+ const { executeTests } = await import("./run-tests-5F4IFT5H.js");
1911
1911
  const argStr = args.join(" ").trim();
1912
1912
  let testArgs = {};
1913
1913
  if (argStr) {
@@ -5517,7 +5517,7 @@ program.command("web").description("Start Web UI server with browser-based chat
5517
5517
  console.error("Error: Invalid port number. Must be between 1 and 65535.");
5518
5518
  process.exit(1);
5519
5519
  }
5520
- const { startWebServer } = await import("./server-BIZW2NHV.js");
5520
+ const { startWebServer } = await import("./server-AXKGLNOI.js");
5521
5521
  await startWebServer({ port, host: options.host });
5522
5522
  });
5523
5523
  program.command("user [action] [username]").description("Manage Web UI users (list | create <name> | delete <name> | reset-password <name> | migrate <name>)").action(async (action, username) => {
@@ -5638,7 +5638,7 @@ program.command("sessions").description("List recent conversation sessions").act
5638
5638
  }
5639
5639
  console.log();
5640
5640
  });
5641
- program.command("hub [topic]").description("Start multi-agent hub (discuss / brainstorm with multiple AI roles)").option("--preset <name>", "Use a built-in role preset (default: tech-review)").option("--roles <file>", "Load roles from a JSON file").option("--provider <name>", "Override default AI provider").option("-m, --model <name>", "Override default model").option("--max-rounds <n>", "Max discussion rounds (default: 10)").option("--presets", "List available role presets").option("--distributed", "Start WebSocket server so remote aicli instances can join as agents").option("--port <n>", "WebSocket port for distributed mode (default: 9527)", "9527").action(async (topic, options) => {
5641
+ program.command("hub [topic]").description("Start multi-agent hub (discuss / brainstorm with multiple AI roles)").option("--preset <name>", "Use a built-in role preset (default: tech-review)").option("--roles <file>", "Load roles from a JSON file").option("--provider <name>", "Override default AI provider").option("-m, --model <name>", "Override default model").option("--max-rounds <n>", "Max discussion rounds (default: 10)").option("--presets", "List available role presets").option("--context <files...>", "Inject external document(s) as context for all agents (e.g. README.md spec.md)").option("--distributed", "Start WebSocket server so remote aicli instances can join as agents").option("--port <n>", "WebSocket port for distributed mode (default: 9527)", "9527").action(async (topic, options) => {
5642
5642
  const config = new ConfigManager();
5643
5643
  const registry = new ProviderRegistry();
5644
5644
  await registry.initialize(
@@ -5649,7 +5649,7 @@ program.command("hub [topic]").description("Start multi-agent hub (discuss / bra
5649
5649
  }),
5650
5650
  config.get("customProviders")
5651
5651
  );
5652
- const { startHub } = await import("./hub-ZTEJJ4WD.js");
5652
+ const { startHub } = await import("./hub-Y4UP3NAQ.js");
5653
5653
  await startHub(
5654
5654
  {
5655
5655
  topic: topic ?? "",
@@ -5659,6 +5659,7 @@ program.command("hub [topic]").description("Start multi-agent hub (discuss / bra
5659
5659
  model: options.model,
5660
5660
  maxRounds: options.maxRounds ? parseInt(options.maxRounds, 10) : void 0,
5661
5661
  listPresets: options.presets === true,
5662
+ contextFiles: options.context,
5662
5663
  distributed: options.distributed === true,
5663
5664
  port: options.port ? parseInt(options.port, 10) : void 0
5664
5665
  },
@@ -5677,7 +5678,7 @@ program.command("join").description("Join a running hub as a remote AI agent").o
5677
5678
  }),
5678
5679
  config.get("customProviders")
5679
5680
  );
5680
- const { joinHub } = await import("./agent-client-YRCQVYHJ.js");
5681
+ const { joinHub } = await import("./agent-client-POWN3QOR.js");
5681
5682
  await joinHub(
5682
5683
  {
5683
5684
  port: parseInt(options.port ?? "9527", 10),
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  executeTests,
4
4
  runTestsTool
5
- } from "./chunk-NLSQEHZU.js";
5
+ } from "./chunk-HUQVG74X.js";
6
6
  export {
7
7
  executeTests,
8
8
  runTestsTool
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  executeTests,
3
3
  runTestsTool
4
- } from "./chunk-IPGCPV3X.js";
4
+ } from "./chunk-YYZEZ6BO.js";
5
5
  export {
6
6
  executeTests,
7
7
  runTestsTool
@@ -27,7 +27,7 @@ import {
27
27
  spawnAgentContext,
28
28
  truncateOutput,
29
29
  undoStack
30
- } from "./chunk-54GQL2O4.js";
30
+ } from "./chunk-6YBF647F.js";
31
31
  import {
32
32
  AGENTIC_BEHAVIOR_GUIDELINE,
33
33
  CONTEXT_FILE_CANDIDATES,
@@ -39,7 +39,7 @@ import {
39
39
  PLAN_MODE_SYSTEM_ADDON,
40
40
  SKILLS_DIR_NAME,
41
41
  VERSION
42
- } from "./chunk-NLSQEHZU.js";
42
+ } from "./chunk-HUQVG74X.js";
43
43
  import {
44
44
  AuthManager
45
45
  } from "./chunk-CPLT6CD3.js";
@@ -1438,7 +1438,7 @@ ${undoResults.map((r) => ` \u2022 ${r}`).join("\n")}` });
1438
1438
  case "test": {
1439
1439
  this.send({ type: "info", message: "\u{1F9EA} Running tests..." });
1440
1440
  try {
1441
- const { executeTests } = await import("./run-tests-WGSNA7K4.js");
1441
+ const { executeTests } = await import("./run-tests-5F4IFT5H.js");
1442
1442
  const argStr = args.join(" ").trim();
1443
1443
  let testArgs = {};
1444
1444
  if (argStr) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jinzd-ai-cli",
3
- "version": "0.3.3",
3
+ "version": "0.3.4",
4
4
  "description": "Cross-platform REPL-style AI CLI with multi-provider support",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",