@zeyue0329/xiaoma-cli 1.0.0

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.
Files changed (123) hide show
  1. package/.releaserc.json +18 -0
  2. package/.vscode/settings.json +44 -0
  3. package/CONTRIBUTING.md +209 -0
  4. package/LICENSE +21 -0
  5. package/QUICK-START.md +173 -0
  6. package/README.md +532 -0
  7. package/common/tasks/create-doc.md +101 -0
  8. package/common/tasks/execute-checklist.md +93 -0
  9. package/common/utils/bmad-doc-template.md +325 -0
  10. package/common/utils/workflow-management.md +69 -0
  11. package/dist/agents/analyst.txt +2882 -0
  12. package/dist/agents/architect.txt +3543 -0
  13. package/dist/agents/dev.txt +428 -0
  14. package/dist/agents/pm.txt +2229 -0
  15. package/dist/agents/po.txt +1364 -0
  16. package/dist/agents/qa.txt +386 -0
  17. package/dist/agents/sm.txt +668 -0
  18. package/dist/agents/ux-expert.txt +701 -0
  19. package/dist/agents/xiaoma-master.txt +8756 -0
  20. package/dist/agents/xiaoma-orchestrator.txt +1490 -0
  21. package/dist/teams/team-all.txt +11062 -0
  22. package/dist/teams/team-fullstack.txt +10392 -0
  23. package/dist/teams/team-ide-minimal.txt +3507 -0
  24. package/dist/teams/team-no-ui.txt +8951 -0
  25. package/docs/GUIDING-PRINCIPLES.md +91 -0
  26. package/docs/core-architecture.md +219 -0
  27. package/docs/expansion-packs.md +280 -0
  28. package/docs/versioning-and-releases.md +77 -0
  29. package/docs/versions.md +48 -0
  30. package/expansion-packs/README.md +3 -0
  31. package/package.json +80 -0
  32. package/tools/bmad-npx-wrapper.js +39 -0
  33. package/tools/builders/web-builder.js +681 -0
  34. package/tools/bump-all-versions.js +106 -0
  35. package/tools/bump-expansion-version.js +83 -0
  36. package/tools/cli.js +152 -0
  37. package/tools/flattener/main.js +570 -0
  38. package/tools/installer/README.md +8 -0
  39. package/tools/installer/bin/xiaoma.js +326 -0
  40. package/tools/installer/config/ide-agent-config.yaml +58 -0
  41. package/tools/installer/config/install.config.yaml +113 -0
  42. package/tools/installer/lib/config-loader.js +253 -0
  43. package/tools/installer/lib/file-manager.js +411 -0
  44. package/tools/installer/lib/ide-base-setup.js +227 -0
  45. package/tools/installer/lib/ide-setup.js +1302 -0
  46. package/tools/installer/lib/installer.js +1772 -0
  47. package/tools/installer/lib/memory-profiler.js +224 -0
  48. package/tools/installer/lib/module-manager.js +110 -0
  49. package/tools/installer/lib/resource-locator.js +310 -0
  50. package/tools/installer/package-lock.json +906 -0
  51. package/tools/installer/package.json +43 -0
  52. package/tools/lib/dependency-resolver.js +179 -0
  53. package/tools/lib/yaml-utils.js +29 -0
  54. package/tools/md-assets/web-agent-startup-instructions.md +39 -0
  55. package/tools/semantic-release-sync-installer.js +30 -0
  56. package/tools/sync-installer-version.js +34 -0
  57. package/tools/update-expansion-version.js +54 -0
  58. package/tools/upgraders/v3-to-v4-upgrader.js +763 -0
  59. package/tools/version-bump.js +79 -0
  60. package/tools/xiaoma-npx-wrapper.js +39 -0
  61. package/tools/yaml-format.js +240 -0
  62. package/xiaoma-core/agent-teams/team-all.yaml +14 -0
  63. package/xiaoma-core/agent-teams/team-fullstack.yaml +18 -0
  64. package/xiaoma-core/agent-teams/team-ide-minimal.yaml +10 -0
  65. package/xiaoma-core/agent-teams/team-no-ui.yaml +13 -0
  66. package/xiaoma-core/agents/analyst.md +81 -0
  67. package/xiaoma-core/agents/architect.md +84 -0
  68. package/xiaoma-core/agents/dev.md +76 -0
  69. package/xiaoma-core/agents/pm.md +81 -0
  70. package/xiaoma-core/agents/po.md +76 -0
  71. package/xiaoma-core/agents/qa.md +69 -0
  72. package/xiaoma-core/agents/sm.md +62 -0
  73. package/xiaoma-core/agents/ux-expert.md +66 -0
  74. package/xiaoma-core/agents/xiaoma-master.md +108 -0
  75. package/xiaoma-core/agents/xiaoma-orchestrator.md +150 -0
  76. package/xiaoma-core/bmad-core/user-guide.md +0 -0
  77. package/xiaoma-core/checklists/architect-checklist.md +443 -0
  78. package/xiaoma-core/checklists/change-checklist.md +182 -0
  79. package/xiaoma-core/checklists/pm-checklist.md +375 -0
  80. package/xiaoma-core/checklists/po-master-checklist.md +441 -0
  81. package/xiaoma-core/checklists/story-dod-checklist.md +101 -0
  82. package/xiaoma-core/checklists/story-draft-checklist.md +156 -0
  83. package/xiaoma-core/core-config.yaml +20 -0
  84. package/xiaoma-core/data/brainstorming-techniques.md +36 -0
  85. package/xiaoma-core/data/elicitation-methods.md +134 -0
  86. package/xiaoma-core/data/technical-preferences.md +3 -0
  87. package/xiaoma-core/data/xiaoma-kb.md +803 -0
  88. package/xiaoma-core/enhanced-ide-development-workflow.md +43 -0
  89. package/xiaoma-core/tasks/advanced-elicitation.md +117 -0
  90. package/xiaoma-core/tasks/brownfield-create-epic.md +160 -0
  91. package/xiaoma-core/tasks/brownfield-create-story.md +147 -0
  92. package/xiaoma-core/tasks/correct-course.md +70 -0
  93. package/xiaoma-core/tasks/create-brownfield-story.md +304 -0
  94. package/xiaoma-core/tasks/create-deep-research-prompt.md +289 -0
  95. package/xiaoma-core/tasks/create-next-story.md +112 -0
  96. package/xiaoma-core/tasks/document-project.md +341 -0
  97. package/xiaoma-core/tasks/facilitate-brainstorming-session.md +136 -0
  98. package/xiaoma-core/tasks/generate-ai-frontend-prompt.md +51 -0
  99. package/xiaoma-core/tasks/index-docs.md +179 -0
  100. package/xiaoma-core/tasks/kb-mode-interaction.md +75 -0
  101. package/xiaoma-core/tasks/review-story.md +145 -0
  102. package/xiaoma-core/tasks/shard-doc.md +187 -0
  103. package/xiaoma-core/tasks/validate-next-story.md +134 -0
  104. package/xiaoma-core/templates/architecture-tmpl.yaml +650 -0
  105. package/xiaoma-core/templates/brainstorming-output-tmpl.yaml +156 -0
  106. package/xiaoma-core/templates/brownfield-architecture-tmpl.yaml +476 -0
  107. package/xiaoma-core/templates/brownfield-prd-tmpl.yaml +280 -0
  108. package/xiaoma-core/templates/competitor-analysis-tmpl.yaml +293 -0
  109. package/xiaoma-core/templates/front-end-architecture-tmpl.yaml +206 -0
  110. package/xiaoma-core/templates/front-end-spec-tmpl.yaml +349 -0
  111. package/xiaoma-core/templates/fullstack-architecture-tmpl.yaml +805 -0
  112. package/xiaoma-core/templates/market-research-tmpl.yaml +252 -0
  113. package/xiaoma-core/templates/prd-tmpl.yaml +202 -0
  114. package/xiaoma-core/templates/project-brief-tmpl.yaml +221 -0
  115. package/xiaoma-core/templates/story-tmpl.yaml +137 -0
  116. package/xiaoma-core/user-guide.md +251 -0
  117. package/xiaoma-core/workflows/brownfield-fullstack.yaml +297 -0
  118. package/xiaoma-core/workflows/brownfield-service.yaml +187 -0
  119. package/xiaoma-core/workflows/brownfield-ui.yaml +197 -0
  120. package/xiaoma-core/workflows/greenfield-fullstack.yaml +240 -0
  121. package/xiaoma-core/workflows/greenfield-service.yaml +206 -0
  122. package/xiaoma-core/workflows/greenfield-ui.yaml +235 -0
  123. package/xiaoma-core/working-in-the-brownfield.md +364 -0
@@ -0,0 +1,227 @@
1
+ /**
2
+ * Base IDE Setup - Common functionality for all IDE setups
3
+ * Reduces duplication and provides shared methods
4
+ */
5
+
6
+ const path = require("path");
7
+ const fs = require("fs-extra");
8
+ const yaml = require("js-yaml");
9
+ const chalk = require("chalk");
10
+ const fileManager = require("./file-manager");
11
+ const resourceLocator = require("./resource-locator");
12
+ const { extractYamlFromAgent } = require("../../lib/yaml-utils");
13
+
14
+ class BaseIdeSetup {
15
+ constructor() {
16
+ this._agentCache = new Map();
17
+ this._pathCache = new Map();
18
+ }
19
+
20
+ /**
21
+ * Get all agent IDs with caching
22
+ */
23
+ async getAllAgentIds(installDir) {
24
+ const cacheKey = `all-agents:${installDir}`;
25
+ if (this._agentCache.has(cacheKey)) {
26
+ return this._agentCache.get(cacheKey);
27
+ }
28
+
29
+ const allAgents = new Set();
30
+
31
+ // Get core agents
32
+ const coreAgents = await this.getCoreAgentIds(installDir);
33
+ coreAgents.forEach(id => allAgents.add(id));
34
+
35
+ // Get expansion pack agents
36
+ const expansionPacks = await this.getInstalledExpansionPacks(installDir);
37
+ for (const pack of expansionPacks) {
38
+ const packAgents = await this.getExpansionPackAgents(pack.path);
39
+ packAgents.forEach(id => allAgents.add(id));
40
+ }
41
+
42
+ const result = Array.from(allAgents);
43
+ this._agentCache.set(cacheKey, result);
44
+ return result;
45
+ }
46
+
47
+ /**
48
+ * Get core agent IDs
49
+ */
50
+ async getCoreAgentIds(installDir) {
51
+ const coreAgents = [];
52
+ const corePaths = [
53
+ path.join(installDir, ".xiaoma-core", "agents"),
54
+ path.join(installDir, "xiaoma-core", "agents")
55
+ ];
56
+
57
+ for (const agentsDir of corePaths) {
58
+ if (await fileManager.pathExists(agentsDir)) {
59
+ const files = await resourceLocator.findFiles("*.md", { cwd: agentsDir });
60
+ coreAgents.push(...files.map(file => path.basename(file, ".md")));
61
+ break; // Use first found
62
+ }
63
+ }
64
+
65
+ return coreAgents;
66
+ }
67
+
68
+ /**
69
+ * Find agent path with caching
70
+ */
71
+ async findAgentPath(agentId, installDir) {
72
+ const cacheKey = `agent-path:${agentId}:${installDir}`;
73
+ if (this._pathCache.has(cacheKey)) {
74
+ return this._pathCache.get(cacheKey);
75
+ }
76
+
77
+ // Use resource locator for efficient path finding
78
+ let agentPath = await resourceLocator.getAgentPath(agentId);
79
+
80
+ if (!agentPath) {
81
+ // Check installation-specific paths
82
+ const possiblePaths = [
83
+ path.join(installDir, ".xiaoma-core", "agents", `${agentId}.md`),
84
+ path.join(installDir, "xiaoma-core", "agents", `${agentId}.md`),
85
+ path.join(installDir, "common", "agents", `${agentId}.md`)
86
+ ];
87
+
88
+ for (const testPath of possiblePaths) {
89
+ if (await fileManager.pathExists(testPath)) {
90
+ agentPath = testPath;
91
+ break;
92
+ }
93
+ }
94
+ }
95
+
96
+ if (agentPath) {
97
+ this._pathCache.set(cacheKey, agentPath);
98
+ }
99
+ return agentPath;
100
+ }
101
+
102
+ /**
103
+ * Get agent title from metadata
104
+ */
105
+ async getAgentTitle(agentId, installDir) {
106
+ const agentPath = await this.findAgentPath(agentId, installDir);
107
+ if (!agentPath) return agentId;
108
+
109
+ try {
110
+ const content = await fileManager.readFile(agentPath);
111
+ const yamlContent = extractYamlFromAgent(content);
112
+ if (yamlContent) {
113
+ const metadata = yaml.load(yamlContent);
114
+ return metadata.agent_name || agentId;
115
+ }
116
+ } catch (error) {
117
+ // Fallback to agent ID
118
+ }
119
+ return agentId;
120
+ }
121
+
122
+ /**
123
+ * Get installed expansion packs
124
+ */
125
+ async getInstalledExpansionPacks(installDir) {
126
+ const cacheKey = `expansion-packs:${installDir}`;
127
+ if (this._pathCache.has(cacheKey)) {
128
+ return this._pathCache.get(cacheKey);
129
+ }
130
+
131
+ const expansionPacks = [];
132
+
133
+ // Check for dot-prefixed expansion packs
134
+ const dotExpansions = await resourceLocator.findFiles(".bmad-*", { cwd: installDir });
135
+
136
+ for (const dotExpansion of dotExpansions) {
137
+ if (dotExpansion !== ".xiaoma-core") {
138
+ const packPath = path.join(installDir, dotExpansion);
139
+ const packName = dotExpansion.substring(1); // remove the dot
140
+ expansionPacks.push({
141
+ name: packName,
142
+ path: packPath
143
+ });
144
+ }
145
+ }
146
+
147
+ // Check other dot folders that have config.yaml
148
+ const allDotFolders = await resourceLocator.findFiles(".*", { cwd: installDir });
149
+ for (const folder of allDotFolders) {
150
+ if (!folder.startsWith(".bmad-") && folder !== ".xiaoma-core") {
151
+ const packPath = path.join(installDir, folder);
152
+ const configPath = path.join(packPath, "config.yaml");
153
+ if (await fileManager.pathExists(configPath)) {
154
+ expansionPacks.push({
155
+ name: folder.substring(1), // remove the dot
156
+ path: packPath
157
+ });
158
+ }
159
+ }
160
+ }
161
+
162
+ this._pathCache.set(cacheKey, expansionPacks);
163
+ return expansionPacks;
164
+ }
165
+
166
+ /**
167
+ * Get expansion pack agents
168
+ */
169
+ async getExpansionPackAgents(packPath) {
170
+ const agentsDir = path.join(packPath, "agents");
171
+ if (!(await fileManager.pathExists(agentsDir))) {
172
+ return [];
173
+ }
174
+
175
+ const agentFiles = await resourceLocator.findFiles("*.md", { cwd: agentsDir });
176
+ return agentFiles.map(file => path.basename(file, ".md"));
177
+ }
178
+
179
+ /**
180
+ * Create agent rule content (shared logic)
181
+ */
182
+ async createAgentRuleContent(agentId, agentPath, installDir, format = 'mdc') {
183
+ const agentContent = await fileManager.readFile(agentPath);
184
+ const agentTitle = await this.getAgentTitle(agentId, installDir);
185
+ const yamlContent = extractYamlFromAgent(agentContent);
186
+
187
+ let content = "";
188
+
189
+ if (format === 'mdc') {
190
+ // MDC format for Cursor
191
+ content = "---\n";
192
+ content += "description: \n";
193
+ content += "globs: []\n";
194
+ content += "alwaysApply: false\n";
195
+ content += "---\n\n";
196
+ content += `# ${agentId.toUpperCase()} Agent Rule\n\n`;
197
+ content += `This rule is triggered when the user types \`@${agentId}\` and activates the ${agentTitle} agent persona.\n\n`;
198
+ content += "## Agent Activation\n\n";
199
+ content += "CRITICAL: Read the full YAML, start activation to alter your state of being, follow startup section instructions, stay in this being until told to exit this mode:\n\n";
200
+ content += "```yaml\n";
201
+ content += yamlContent || agentContent.replace(/^#.*$/m, "").trim();
202
+ content += "\n```\n\n";
203
+ content += "## File Reference\n\n";
204
+ const relativePath = path.relative(installDir, agentPath).replace(/\\/g, '/');
205
+ content += `The complete agent definition is available in [${relativePath}](mdc:${relativePath}).\n\n`;
206
+ content += "## Usage\n\n";
207
+ content += `When the user types \`@${agentId}\`, activate this ${agentTitle} persona and follow all instructions defined in the YAML configuration above.\n`;
208
+ } else if (format === 'claude') {
209
+ // Claude Code format
210
+ content = `# /${agentId} Command\n\n`;
211
+ content += `When this command is used, adopt the following agent persona:\n\n`;
212
+ content += agentContent;
213
+ }
214
+
215
+ return content;
216
+ }
217
+
218
+ /**
219
+ * Clear all caches
220
+ */
221
+ clearCache() {
222
+ this._agentCache.clear();
223
+ this._pathCache.clear();
224
+ }
225
+ }
226
+
227
+ module.exports = BaseIdeSetup;