@deimoscloud/coreai 0.1.13 → 0.1.15

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/cli/index.js CHANGED
@@ -374,6 +374,183 @@ function buildAgentTools(agent, mcpServers) {
374
374
  }
375
375
  return tools.join(", ");
376
376
  }
377
+ function generateKnowledgeLibrarySection(agent, lines) {
378
+ const kl = agent.knowledge_library;
379
+ if (!kl) return;
380
+ lines.push("## Knowledge Library Structure");
381
+ lines.push("");
382
+ if (kl.shared) {
383
+ lines.push("### Shared Context (Root - All Agents)");
384
+ lines.push("```");
385
+ lines.push("/KnowledgeLibrary/");
386
+ if (kl.shared.context) {
387
+ const filename = kl.shared.context.split("/").pop() ?? "context.txt";
388
+ lines.push(`\u251C\u2500\u2500 ${filename}`);
389
+ }
390
+ if (kl.shared.architecture) {
391
+ const filename = kl.shared.architecture.split("/").pop() ?? "architecture.txt";
392
+ lines.push(`\u251C\u2500\u2500 ${filename}`);
393
+ }
394
+ if (kl.shared.prd) {
395
+ const filename = kl.shared.prd.split("/").pop() ?? "prd.txt";
396
+ lines.push(`\u2514\u2500\u2500 ${filename}`);
397
+ }
398
+ lines.push("```");
399
+ if (kl.shared.remote && kl.shared.remote.length > 0) {
400
+ lines.push("");
401
+ lines.push("**Remote Documentation:**");
402
+ for (const remote of kl.shared.remote) {
403
+ lines.push(`- ${remote}`);
404
+ }
405
+ }
406
+ lines.push("");
407
+ }
408
+ if (kl.personal) {
409
+ lines.push(`### Personal Context (${agent.role})`);
410
+ lines.push("```");
411
+ lines.push(`/KnowledgeLibrary/${agent.role}/`);
412
+ if (kl.personal.context) {
413
+ lines.push("\u251C\u2500\u2500 context/");
414
+ lines.push("\u2502 \u2514\u2500\u2500 current.txt # Your current state, priorities, decisions, issues");
415
+ }
416
+ if (kl.personal.history) {
417
+ lines.push("\u251C\u2500\u2500 history/");
418
+ lines.push("\u2502 \u2514\u2500\u2500 [archived context files, timestamped]");
419
+ }
420
+ if (kl.personal.inbox) {
421
+ lines.push("\u251C\u2500\u2500 inbox/");
422
+ lines.push("\u2502 \u2514\u2500\u2500 YYYYMMDD_HHMM-[agent-name]-[topic].txt # Messages from other agents");
423
+ }
424
+ if (kl.personal.outbox) {
425
+ lines.push("\u251C\u2500\u2500 outbox/");
426
+ lines.push("\u2502 \u2514\u2500\u2500 YYYYMMDD_HHMM-to-[agent-name]-[topic].txt # Copies of sent messages");
427
+ }
428
+ if (kl.personal.tech) {
429
+ lines.push("\u251C\u2500\u2500 tech/");
430
+ lines.push("\u2502 \u2514\u2500\u2500 [Technical docs, implementation details, working drafts]");
431
+ }
432
+ if (kl.personal.control) {
433
+ lines.push("\u2514\u2500\u2500 control/");
434
+ if (kl.personal.control.objectives) {
435
+ lines.push(" \u251C\u2500\u2500 objectives.txt # Current job objectives and goals");
436
+ }
437
+ if (kl.personal.control.decisions) {
438
+ lines.push(" \u251C\u2500\u2500 decisions.txt # Log of key decisions with rationale");
439
+ }
440
+ if (kl.personal.control.dependencies) {
441
+ lines.push(" \u251C\u2500\u2500 dependencies.txt # Dependencies on other jobs");
442
+ }
443
+ if (kl.personal.control.index) {
444
+ lines.push(" \u2514\u2500\u2500 index.txt # Optional index of files/folders");
445
+ }
446
+ }
447
+ lines.push("```");
448
+ lines.push("");
449
+ }
450
+ lines.push("---");
451
+ lines.push("");
452
+ }
453
+ function generateCommunicationSection(agent, lines) {
454
+ const comm = agent.communication;
455
+ if (!comm) return;
456
+ lines.push("## Communication");
457
+ lines.push("");
458
+ if (comm.inbox) {
459
+ lines.push(`**Inbox:** \`${comm.inbox}\``);
460
+ }
461
+ if (comm.outbox) {
462
+ lines.push(`**Outbox:** \`${comm.outbox}\``);
463
+ }
464
+ lines.push("");
465
+ if (comm.message_format || comm.outbox_format || comm.processed_dir) {
466
+ lines.push("### Message Conventions");
467
+ lines.push("");
468
+ if (comm.message_format) {
469
+ lines.push(`- **Inbox message naming:** \`${comm.message_format}\``);
470
+ }
471
+ if (comm.outbox_format) {
472
+ lines.push(`- **Outbox message naming:** \`${comm.outbox_format}\``);
473
+ }
474
+ if (comm.processed_dir) {
475
+ lines.push(`- **Processed messages:** Move handled inbox messages to \`${comm.processed_dir}\``);
476
+ }
477
+ lines.push("");
478
+ }
479
+ }
480
+ function generateStartupProtocolSection(agent, lines) {
481
+ const protocols = agent.protocols;
482
+ if (!protocols?.startup) return;
483
+ lines.push("## When Invoked");
484
+ lines.push("");
485
+ lines.push("> **MANDATORY STARTUP PROTOCOL** - Execute before proceeding with any task.");
486
+ lines.push("");
487
+ lines.push("### Session Context Check");
488
+ lines.push("");
489
+ lines.push("First, determine if you have already loaded context in this session:");
490
+ lines.push("");
491
+ if (protocols.startup.first_session && protocols.startup.first_session.length > 0) {
492
+ lines.push("**If this is your FIRST invocation in this session** (no prior context loaded):");
493
+ lines.push("");
494
+ for (const step of protocols.startup.first_session) {
495
+ lines.push(`- [ ] ${step}`);
496
+ }
497
+ lines.push("");
498
+ lines.push('Acknowledge: "Startup protocol complete. Full context loaded."');
499
+ lines.push("");
500
+ }
501
+ if (protocols.startup.subsequent && protocols.startup.subsequent.length > 0) {
502
+ lines.push("**If you have ALREADY loaded context in this session** (subsequent invocation):");
503
+ lines.push("");
504
+ for (const step of protocols.startup.subsequent) {
505
+ lines.push(`- [ ] ${step}`);
506
+ }
507
+ lines.push("");
508
+ lines.push('Acknowledge: "Context already loaded. Checked inbox for new messages."');
509
+ lines.push("");
510
+ }
511
+ lines.push("Then proceed with the task.");
512
+ lines.push("");
513
+ lines.push("---");
514
+ lines.push("");
515
+ }
516
+ function generateCompletionProtocolSection(agent, lines) {
517
+ const protocols = agent.protocols;
518
+ if (!protocols?.completion || protocols.completion.length === 0) return;
519
+ lines.push("## Before Finishing");
520
+ lines.push("");
521
+ lines.push("> **MANDATORY COMPLETION PROTOCOL** - Execute ALL steps before ending any task.");
522
+ lines.push("");
523
+ for (let i = 0; i < protocols.completion.length; i++) {
524
+ lines.push(`### ${i + 1}. ${protocols.completion[i]}`);
525
+ lines.push("");
526
+ }
527
+ lines.push('Acknowledge: "Completion protocol finished. Context updated."');
528
+ lines.push("");
529
+ lines.push("---");
530
+ lines.push("");
531
+ }
532
+ function generateLegacyContextSourcesSection(agent, lines) {
533
+ if (!agent.context_sources) return;
534
+ if (agent.knowledge_library) return;
535
+ lines.push("## Context Sources");
536
+ lines.push("");
537
+ if (agent.context_sources.shared && agent.context_sources.shared.length > 0) {
538
+ lines.push("### Shared");
539
+ lines.push("");
540
+ for (const source of agent.context_sources.shared) {
541
+ lines.push(`- ${source}`);
542
+ }
543
+ lines.push("");
544
+ }
545
+ if (agent.context_sources.personal && agent.context_sources.personal.length > 0) {
546
+ lines.push("### Personal");
547
+ lines.push("");
548
+ for (const source of agent.context_sources.personal) {
549
+ lines.push(`- ${source}`);
550
+ }
551
+ lines.push("");
552
+ }
553
+ }
377
554
  function generateAgentMarkdown(agent, mcpServers) {
378
555
  const lines = [];
379
556
  const tools = buildAgentTools(agent, mcpServers);
@@ -469,37 +646,11 @@ function generateAgentMarkdown(agent, mcpServers) {
469
646
  lines.push("");
470
647
  }
471
648
  }
472
- if (agent.context_sources) {
473
- lines.push("## Context Sources");
474
- lines.push("");
475
- if (agent.context_sources.shared && agent.context_sources.shared.length > 0) {
476
- lines.push("### Shared");
477
- lines.push("");
478
- for (const source of agent.context_sources.shared) {
479
- lines.push(`- ${source}`);
480
- }
481
- lines.push("");
482
- }
483
- if (agent.context_sources.personal && agent.context_sources.personal.length > 0) {
484
- lines.push("### Personal");
485
- lines.push("");
486
- for (const source of agent.context_sources.personal) {
487
- lines.push(`- ${source}`);
488
- }
489
- lines.push("");
490
- }
491
- }
492
- if (agent.communication) {
493
- lines.push("## Communication");
494
- lines.push("");
495
- if (agent.communication.inbox) {
496
- lines.push(`**Inbox:** ${agent.communication.inbox}`);
497
- }
498
- if (agent.communication.outbox) {
499
- lines.push(`**Outbox:** ${agent.communication.outbox}`);
500
- }
501
- lines.push("");
502
- }
649
+ generateKnowledgeLibrarySection(agent, lines);
650
+ generateCommunicationSection(agent, lines);
651
+ generateStartupProtocolSection(agent, lines);
652
+ generateCompletionProtocolSection(agent, lines);
653
+ generateLegacyContextSourcesSection(agent, lines);
503
654
  lines.push("---");
504
655
  lines.push("");
505
656
  lines.push("*Generated by CoreAI*");