@xagent/x-cli 1.1.55 → 1.1.57

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/README.md CHANGED
@@ -1,4 +1,4 @@
1
- ## 1.1.55 – Logo Assets & NPM Publication Complete
1
+ ## 1.1.57 – Logo Assets & NPM Publication Complete
2
2
 
3
3
  ✅ **Live on NPM**: [@xagent/x-cli](https://www.npmjs.com/package/@xagent/x-cli) - Fully published and ready for global installation
4
4
 
@@ -419,6 +419,141 @@ This means you can have different models for different projects while maintainin
419
419
  }
420
420
  ```
421
421
 
422
+ ## 📚 .agent Documentation System
423
+
424
+ ### 🎯 **Best Feature of X CLI - AI Context Optimization**
425
+
426
+ The **`.agent` folder** is the most powerful feature of X CLI, enabling **self-documenting AI workflows** that automatically provide context to AI agents. This revolutionary approach ensures every AI interaction is informed by comprehensive project documentation, making conversations with Grok significantly more productive and accurate.
427
+
428
+ ### 🏗️ **How It Works**
429
+
430
+ When you run `npx -y @xagent/x-cli@latest`, the CLI automatically detects and reads `.agent/` documentation:
431
+
432
+ 1. **Auto-Discovery**: Scans for `.agent/` folder in current directory
433
+ 2. **Configuration Loading**: Reads `.agent/auto-read-config.json` for custom settings
434
+ 3. **Smart Loading**: Reads configured documentation files into chat context
435
+ 4. **Context Enhancement**: Provides comprehensive project understanding to AI
436
+
437
+ ### 📂 **Key Components**
438
+
439
+ #### **`sop/` - Standard Operating Procedures**
440
+
441
+ - **`git-workflow.md`** - Git workflow standards and smart push guidelines
442
+ - **`release-management.md`** - Automated release processes and version management
443
+ - **`automation-protection.md`** - Safeguards for automated NPM publishing
444
+ - **`npm-publishing-troubleshooting.md`** - NPM publication issue resolution
445
+ - **`documentation-workflow.md`** - Documentation maintenance procedures
446
+
447
+ #### **`system/` - System Architecture & State**
448
+
449
+ - **`architecture.md`** - Complete system design and technology stack
450
+ - **`critical-state.md`** - Current system capabilities and status
451
+ - **`api-schema.md`** - API integration specifications
452
+ - **`installation.md`** - Setup and deployment procedures
453
+ - **`auto-read-system.md`** - Documentation of this auto-loading feature!
454
+
455
+ ### 🔄 **Auto-Read System Benefits**
456
+
457
+ #### **Immediate Context**
458
+
459
+ - **Zero Setup Required**: Just having `.agent/` folder provides instant AI context
460
+ - **Comprehensive Understanding**: AI gets complete project overview on startup
461
+ - **Standardized Knowledge**: Consistent documentation format across projects
462
+
463
+ #### **Self-Documenting Workflows**
464
+
465
+ - **Living Documentation**: Docs evolve with project development
466
+ - **AI-Assisted Maintenance**: AI can help update documentation
467
+ - **Version-Controlled**: All docs tracked in git with project history
468
+
469
+ #### **Quality Assurance**
470
+
471
+ - **Error Prevention**: SOPs guide AI to follow established patterns
472
+ - **Consistency Enforcement**: Standardized approaches across team
473
+ - **Knowledge Preservation**: Critical procedures documented and accessible
474
+
475
+ ### 🪝 **Husky Commit Hook Integration**
476
+
477
+ **Best Practice**: Set up automatic documentation syncing with git hooks.
478
+
479
+ #### **Why Husky Integration?**
480
+
481
+ The `.agent` folder is intentionally **gitignored** (contains sensitive project-specific docs), but you want docs to sync to public repositories or team wikis. Husky commit hooks automate this process:
482
+
483
+ 1. **Pre-commit Validation**: Ensure docs are up-to-date before commits
484
+ 2. **Auto-Sync**: Push docs to Docusaurus, GitHub Wiki, or team documentation sites
485
+ 3. **Quality Gates**: Prevent commits if critical docs are missing
486
+
487
+ #### **Setup Instructions**
488
+
489
+ 1. **Initialize `.agent` system**:
490
+
491
+ ```bash
492
+ xcli
493
+ /init-agent
494
+ ```
495
+
496
+ 2. **Install Husky**:
497
+
498
+ ```bash
499
+ npm install --save-dev husky
500
+ npx husky install
501
+ ```
502
+
503
+ 3. **Add documentation sync hook**:
504
+
505
+ ```bash
506
+ npx husky add .husky/pre-commit "npm run sync-docs"
507
+ ```
508
+
509
+ 4. **Configure sync script** (add to `package.json`):
510
+
511
+ ```json
512
+ {
513
+ "scripts": {
514
+ "sync-docs": "xcli /update-agent-docs --sync-to-docusaurus"
515
+ }
516
+ }
517
+ ```
518
+
519
+ #### **Benefits of Husky Integration**
520
+
521
+ - **Automatic Updates**: Docs sync on every commit
522
+ - **Team Consistency**: Everyone's local docs stay current
523
+ - **Quality Assurance**: Pre-commit checks ensure documentation completeness
524
+ - **Zero Manual Work**: Documentation maintenance becomes automatic
525
+
526
+ ### 🎖️ **Why This is Revolutionary**
527
+
528
+ 1. **Context-First AI**: Unlike other CLIs that start conversations from scratch, X CLI begins with complete project context
529
+
530
+ 2. **Self-Improving System**: As you document procedures, AI gets better at following them
531
+
532
+ 3. **Knowledge Preservation**: Critical procedures are documented where they're actually used
533
+
534
+ 4. **Team Synchronization**: Everyone works with the same documented standards
535
+
536
+ 5. **Future-Proof**: AI can help maintain and evolve documentation
537
+
538
+ ### 🚀 **Getting Started**
539
+
540
+ 1. **Initialize your project**:
541
+
542
+ ```bash
543
+ xcli
544
+ /init-agent
545
+ ```
546
+
547
+ 2. **Customize documentation** in `.agent/` folder
548
+
549
+ 3. **Set up Husky hooks** for automatic syncing
550
+
551
+ 4. **Enjoy context-aware AI** that understands your project's standards and procedures!
552
+
553
+ **This feature transforms AI CLI interactions from generic conversations to informed, context-aware development sessions.**
554
+
555
+ ---
556
+
422
557
  ## Usage
423
558
 
424
559
  ### Interactive Mode
package/dist/index.js CHANGED
@@ -9293,7 +9293,7 @@ EOF`;
9293
9293
  var package_default = {
9294
9294
  type: "module",
9295
9295
  name: "@xagent/x-cli",
9296
- version: "1.1.55",
9296
+ version: "1.1.57",
9297
9297
  description: "An open-source AI agent that brings the power of Grok directly into your terminal.",
9298
9298
  main: "dist/index.js",
9299
9299
  module: "dist/index.js",
@@ -18314,75 +18314,80 @@ function ChatInterfaceWithAgent({
18314
18314
  if (fs__default.existsSync(".agent")) {
18315
18315
  const initialMessages = [];
18316
18316
  let docsRead = 0;
18317
- initialMessages.push({
18318
- type: "assistant",
18319
- content: "\u{1F4DA} Reading core documentation into memory...",
18320
- timestamp: /* @__PURE__ */ new Date()
18321
- });
18322
- const archPath = path7__default.join(".agent", "system", "architecture.md");
18323
- if (fs__default.existsSync(archPath)) {
18317
+ let config2 = null;
18318
+ const configPath = path7__default.join(".agent", "auto-read-config.json");
18319
+ if (fs__default.existsSync(configPath)) {
18324
18320
  try {
18325
- const archContent = fs__default.readFileSync(archPath, "utf8");
18326
- initialMessages.push({
18327
- type: "assistant",
18328
- content: `\u{1F4CB} **System Architecture (from .agent/system/architecture.md)**
18329
-
18330
- ${archContent}`,
18331
- timestamp: /* @__PURE__ */ new Date()
18332
- });
18333
- docsRead++;
18321
+ const configContent = fs__default.readFileSync(configPath, "utf8");
18322
+ config2 = JSON.parse(configContent);
18334
18323
  } catch (_error) {
18335
18324
  }
18336
18325
  }
18337
- const workflowPath = path7__default.join(".agent", "sop", "git-workflow.md");
18338
- if (fs__default.existsSync(workflowPath)) {
18339
- try {
18340
- const workflowContent = fs__default.readFileSync(workflowPath, "utf8");
18341
- initialMessages.push({
18342
- type: "assistant",
18343
- content: `\u{1F527} **Git Workflow SOP (from .agent/sop/git-workflow.md)**
18344
-
18345
- ${workflowContent}`,
18346
- timestamp: /* @__PURE__ */ new Date()
18347
- });
18348
- docsRead++;
18349
- } catch (_error) {
18350
- }
18326
+ const isEnabled = config2?.enabled !== false;
18327
+ const showLoadingMessage = config2?.showLoadingMessage !== false;
18328
+ const showSummaryMessage = config2?.showSummaryMessage !== false;
18329
+ if (!isEnabled) {
18330
+ return;
18351
18331
  }
18352
- const sopDir = path7__default.join(".agent", "sop");
18353
- if (fs__default.existsSync(sopDir)) {
18354
- const sopFiles = ["release-management.md", "automation-protection.md"];
18355
- for (const file of sopFiles) {
18356
- const filePath = path7__default.join(sopDir, file);
18357
- if (fs__default.existsSync(filePath)) {
18358
- try {
18359
- const content = fs__default.readFileSync(filePath, "utf8");
18360
- const title = file.replace(".md", "").replace("-", " ").toUpperCase();
18361
- initialMessages.push({
18362
- type: "assistant",
18363
- content: `\u{1F4D6} **${title} SOP (from .agent/sop/${file})**
18364
-
18365
- ${content}`,
18366
- timestamp: /* @__PURE__ */ new Date()
18367
- });
18368
- docsRead++;
18369
- } catch (_error) {
18370
- }
18371
- }
18332
+ if (showLoadingMessage) {
18333
+ initialMessages.push({
18334
+ type: "assistant",
18335
+ content: "\u{1F4DA} Reading core documentation into memory...",
18336
+ timestamp: /* @__PURE__ */ new Date()
18337
+ });
18338
+ }
18339
+ const folders = config2?.folders || [
18340
+ {
18341
+ name: "system",
18342
+ priority: 1,
18343
+ files: [
18344
+ { name: "architecture.md", title: "System Architecture", icon: "\u{1F4CB}", required: true },
18345
+ { name: "critical-state.md", title: "Critical State", icon: "\u{1F3D7}\uFE0F", required: false },
18346
+ { name: "installation.md", title: "Installation", icon: "\u{1F3D7}\uFE0F", required: false },
18347
+ { name: "api-schema.md", title: "API Schema", icon: "\u{1F3D7}\uFE0F", required: false },
18348
+ { name: "auto-read-system.md", title: "Auto-Read System", icon: "\u{1F3D7}\uFE0F", required: false }
18349
+ ]
18350
+ },
18351
+ {
18352
+ name: "sop",
18353
+ priority: 2,
18354
+ files: [
18355
+ { name: "git-workflow.md", title: "Git Workflow SOP", icon: "\u{1F527}", required: true },
18356
+ { name: "release-management.md", title: "Release Management SOP", icon: "\u{1F4D6}", required: false },
18357
+ { name: "automation-protection.md", title: "Automation Protection SOP", icon: "\u{1F4D6}", required: false },
18358
+ { name: "npm-publishing-troubleshooting.md", title: "NPM Publishing Troubleshooting", icon: "\u{1F4D6}", required: false }
18359
+ ]
18372
18360
  }
18361
+ ];
18362
+ if (config2?.customFolders) {
18363
+ folders.push(...config2.customFolders);
18373
18364
  }
18374
- const systemDir = path7__default.join(".agent", "system");
18375
- if (fs__default.existsSync(systemDir)) {
18376
- const systemFiles = ["critical-state.md", "installation.md", "api-schema.md", "auto-read-system.md"];
18377
- for (const file of systemFiles) {
18378
- const filePath = path7__default.join(systemDir, file);
18379
- if (fs__default.existsSync(filePath)) {
18365
+ folders.sort((a, b) => (a.priority || 999) - (b.priority || 999));
18366
+ for (const folder of folders) {
18367
+ const folderPath = path7__default.join(".agent", folder.name);
18368
+ if (!fs__default.existsSync(folderPath)) {
18369
+ continue;
18370
+ }
18371
+ for (const file of folder.files) {
18372
+ let filePaths = [];
18373
+ if (file.pattern) {
18374
+ continue;
18375
+ } else {
18376
+ filePaths = [file.name];
18377
+ }
18378
+ for (const fileName of filePaths) {
18379
+ const filePath = path7__default.join(folderPath, fileName);
18380
+ if (!fs__default.existsSync(filePath)) {
18381
+ if (file.required) ;
18382
+ continue;
18383
+ }
18380
18384
  try {
18381
18385
  const content = fs__default.readFileSync(filePath, "utf8");
18382
- const title = file.replace(".md", "").replace("-", " ").toUpperCase();
18386
+ const displayTitle = file.title || fileName.replace(".md", "").replace("-", " ").toUpperCase();
18387
+ const icon = file.icon || "\u{1F4C4}";
18383
18388
  initialMessages.push({
18384
18389
  type: "assistant",
18385
- content: `\u{1F3D7}\uFE0F **${title} (from .agent/system/${file})**
18390
+ content: `${icon} **${displayTitle} (from .agent/${folder.name}/${fileName})**
18386
18391
 
18387
18392
  ${content}`,
18388
18393
  timestamp: /* @__PURE__ */ new Date()
@@ -18393,7 +18398,7 @@ ${content}`,
18393
18398
  }
18394
18399
  }
18395
18400
  }
18396
- if (docsRead > 0) {
18401
+ if (showSummaryMessage && docsRead > 0) {
18397
18402
  initialMessages.push({
18398
18403
  type: "assistant",
18399
18404
  content: `\u2705 ${docsRead} documentation files read - I have a complete understanding of the current architecture and operational procedures.`,