xo-agent 0.0.1-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 (64) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +159 -0
  3. package/bin/cli.js +2 -0
  4. package/dist/commands/add-agent.d.ts +3 -0
  5. package/dist/commands/add-agent.d.ts.map +1 -0
  6. package/dist/commands/add-agent.js +114 -0
  7. package/dist/commands/add-agent.js.map +1 -0
  8. package/dist/commands/add-command.d.ts +3 -0
  9. package/dist/commands/add-command.d.ts.map +1 -0
  10. package/dist/commands/add-command.js +114 -0
  11. package/dist/commands/add-command.js.map +1 -0
  12. package/dist/commands/add-skill.d.ts +3 -0
  13. package/dist/commands/add-skill.d.ts.map +1 -0
  14. package/dist/commands/add-skill.js +108 -0
  15. package/dist/commands/add-skill.js.map +1 -0
  16. package/dist/commands/add.d.ts +3 -0
  17. package/dist/commands/add.d.ts.map +1 -0
  18. package/dist/commands/add.js +133 -0
  19. package/dist/commands/add.js.map +1 -0
  20. package/dist/commands/interactive.d.ts +3 -0
  21. package/dist/commands/interactive.d.ts.map +1 -0
  22. package/dist/commands/interactive.js +176 -0
  23. package/dist/commands/interactive.js.map +1 -0
  24. package/dist/index.d.ts +3 -0
  25. package/dist/index.d.ts.map +1 -0
  26. package/dist/index.js +22 -0
  27. package/dist/index.js.map +1 -0
  28. package/dist/skills/example-skill/SKILL.md +19 -0
  29. package/dist/templates/agents/code-reviewer/AGENT.md +138 -0
  30. package/dist/templates/agents/documentation-writer/AGENT.md +179 -0
  31. package/dist/templates/commands/deploy.md +52 -0
  32. package/dist/templates/commands/test.md +49 -0
  33. package/dist/templates/skills/example-skill/SKILL.md +19 -0
  34. package/dist/templates/skills/example-skill/references/reference.md +0 -0
  35. package/dist/templates/skills/example-skill/scripts/script.py +0 -0
  36. package/dist/types.d.ts +13 -0
  37. package/dist/types.d.ts.map +1 -0
  38. package/dist/types.js +16 -0
  39. package/dist/types.js.map +1 -0
  40. package/dist/utils/constants.d.ts +13 -0
  41. package/dist/utils/constants.d.ts.map +1 -0
  42. package/dist/utils/constants.js +16 -0
  43. package/dist/utils/constants.js.map +1 -0
  44. package/dist/utils/copy.d.ts +55 -0
  45. package/dist/utils/copy.d.ts.map +1 -0
  46. package/dist/utils/copy.js +229 -0
  47. package/dist/utils/copy.js.map +1 -0
  48. package/dist/utils/evaluate.d.ts +10 -0
  49. package/dist/utils/evaluate.d.ts.map +1 -0
  50. package/dist/utils/evaluate.js +28 -0
  51. package/dist/utils/evaluate.js.map +1 -0
  52. package/dist/utils/file-builder.d.ts +28 -0
  53. package/dist/utils/file-builder.d.ts.map +1 -0
  54. package/dist/utils/file-builder.js +106 -0
  55. package/dist/utils/file-builder.js.map +1 -0
  56. package/dist/utils/prompts.d.ts +12 -0
  57. package/dist/utils/prompts.d.ts.map +1 -0
  58. package/dist/utils/prompts.js +152 -0
  59. package/dist/utils/prompts.js.map +1 -0
  60. package/dist/utils/transform.d.ts +11 -0
  61. package/dist/utils/transform.d.ts.map +1 -0
  62. package/dist/utils/transform.js +43 -0
  63. package/dist/utils/transform.js.map +1 -0
  64. package/package.json +45 -0
@@ -0,0 +1,179 @@
1
+ ---
2
+ name: documentation-writer
3
+ description: Automated documentation generation agent
4
+ ---
5
+
6
+ # Documentation Writer Agent
7
+
8
+ An intelligent sub-agent that automatically generates and maintains project documentation.
9
+
10
+ ## Purpose
11
+
12
+ This agent helps maintain high-quality documentation by:
13
+ - Auto-generating API documentation from code
14
+ - Creating user guides and tutorials
15
+ - Maintaining README files
16
+ - Generating changelog from git history
17
+ - Creating architecture diagrams
18
+
19
+ ## Capabilities
20
+
21
+ ### API Documentation
22
+ - Extract JSDoc/TSDoc comments
23
+ - Generate API reference pages
24
+ - Create interactive examples
25
+ - Document request/response schemas
26
+
27
+ ### User Documentation
28
+ - Generate getting started guides
29
+ - Create feature documentation
30
+ - Write troubleshooting guides
31
+ - Maintain FAQ sections
32
+
33
+ ### Code Documentation
34
+ - Add missing JSDoc comments
35
+ - Update outdated documentation
36
+ - Generate function signatures
37
+ - Document complex algorithms
38
+
39
+ ### Visual Documentation
40
+ - Create architecture diagrams (Mermaid)
41
+ - Generate flowcharts
42
+ - Create sequence diagrams
43
+ - Visualize data models
44
+
45
+ ## Usage
46
+
47
+ ### Auto-Generate Documentation
48
+
49
+ ```bash
50
+ xo-agent docs generate --type api
51
+ xo-agent docs generate --type user-guide
52
+ xo-agent docs generate --type changelog
53
+ ```
54
+
55
+ ### Update Existing Docs
56
+
57
+ ```bash
58
+ xo-agent docs update --files "docs/**/*.md"
59
+ ```
60
+
61
+ ### Generate Diagrams
62
+
63
+ ```bash
64
+ xo-agent docs diagram --type architecture
65
+ xo-agent docs diagram --type flow --function handlePayment
66
+ ```
67
+
68
+ ## Configuration
69
+
70
+ Configure in `.agent/agents/documentation-writer/config.json`:
71
+
72
+ ```json
73
+ {
74
+ "output": {
75
+ "api": "docs/api",
76
+ "guides": "docs/guides",
77
+ "diagrams": "docs/diagrams"
78
+ },
79
+ "style": {
80
+ "format": "markdown",
81
+ "includeExamples": true,
82
+ "includeTypes": true
83
+ },
84
+ "automation": {
85
+ "updateOnCommit": true,
86
+ "generateChangelog": true
87
+ }
88
+ }
89
+ ```
90
+
91
+ ## Documentation Templates
92
+
93
+ ### API Endpoint Template
94
+
95
+ ```markdown
96
+ ## POST /api/users
97
+
98
+ Create a new user account.
99
+
100
+ ### Request Body
101
+
102
+ | Field | Type | Required | Description |
103
+ |-------|------|----------|-------------|
104
+ | email | string | Yes | User email address |
105
+ | name | string | Yes | User full name |
106
+ | role | string | No | User role (default: 'user') |
107
+
108
+ ### Response
109
+
110
+ **Success (201)**
111
+ ```json
112
+ {
113
+ "id": "user_123",
114
+ "email": "user@example.com",
115
+ "name": "John Doe",
116
+ "role": "user"
117
+ }
118
+ ```
119
+
120
+ **Error (400)**
121
+ ```json
122
+ {
123
+ "error": "Invalid email format"
124
+ }
125
+ ```
126
+
127
+ ### Example
128
+
129
+ ```bash
130
+ curl -X POST https://api.example.com/api/users \
131
+ -H "Content-Type: application/json" \
132
+ -d '{"email":"user@example.com","name":"John Doe"}'
133
+ ```
134
+ ```
135
+
136
+ ## Integration
137
+
138
+ - Runs on git pre-commit hooks
139
+ - Integrates with CI/CD pipelines
140
+ - Syncs with documentation sites (Docusaurus, VitePress)
141
+ - Exports to PDF for offline reading
142
+
143
+ ## Examples
144
+
145
+ ### Generated Architecture Diagram
146
+
147
+ ```mermaid
148
+ graph TD
149
+ A[Client] -->|HTTP Request| B[API Gateway]
150
+ B --> C[Auth Service]
151
+ B --> D[User Service]
152
+ D --> E[(Database)]
153
+ C --> E
154
+ ```
155
+
156
+ ### Auto-Generated Function Documentation
157
+
158
+ ```typescript
159
+ /**
160
+ * Processes a payment transaction
161
+ *
162
+ * @param {string} userId - The ID of the user making the payment
163
+ * @param {number} amount - The payment amount in cents
164
+ * @param {string} currency - The currency code (e.g., 'USD', 'EUR')
165
+ * @returns {Promise<PaymentResult>} The payment result with transaction ID
166
+ * @throws {PaymentError} If payment processing fails
167
+ *
168
+ * @example
169
+ * const result = await processPayment('user_123', 5000, 'USD');
170
+ * console.log(result.transactionId); // 'txn_abc123'
171
+ */
172
+ async function processPayment(
173
+ userId: string,
174
+ amount: number,
175
+ currency: string
176
+ ): Promise<PaymentResult> {
177
+ // Implementation
178
+ }
179
+ ```
@@ -0,0 +1,52 @@
1
+ ---
2
+ description: Deploy application to production
3
+ ---
4
+
5
+ # Deploy
6
+
7
+ Deploy the application to production environment.
8
+
9
+ ## Prerequisites
10
+
11
+ - Ensure all tests pass
12
+ - Update version number
13
+ - Create git tag
14
+
15
+ ## Steps
16
+
17
+ // turbo
18
+ 1. Run tests
19
+ ```bash
20
+ npm test
21
+ ```
22
+
23
+ // turbo
24
+ 2. Build production bundle
25
+ ```bash
26
+ npm run build
27
+ ```
28
+
29
+ // turbo
30
+ 3. Deploy to server
31
+ ```bash
32
+ npm run deploy:prod
33
+ ```
34
+
35
+ 4. Verify deployment
36
+ - Check application health endpoint
37
+ - Monitor logs for errors
38
+ - Test critical user flows
39
+
40
+ ## Rollback
41
+
42
+ If deployment fails:
43
+
44
+ ```bash
45
+ npm run rollback
46
+ ```
47
+
48
+ ## Post-Deployment
49
+
50
+ - Update changelog
51
+ - Notify team in Slack
52
+ - Monitor metrics for 30 minutes
@@ -0,0 +1,49 @@
1
+ ---
2
+ description: Run all tests and generate coverage report
3
+ ---
4
+
5
+ # Test
6
+
7
+ Run the complete test suite with coverage reporting.
8
+
9
+ ## Steps
10
+
11
+ // turbo-all
12
+ 1. Run unit tests
13
+ ```bash
14
+ npm run test:unit
15
+ ```
16
+
17
+ 2. Run integration tests
18
+ ```bash
19
+ npm run test:integration
20
+ ```
21
+
22
+ 3. Run e2e tests
23
+ ```bash
24
+ npm run test:e2e
25
+ ```
26
+
27
+ 4. Generate coverage report
28
+ ```bash
29
+ npm run test:coverage
30
+ ```
31
+
32
+ 5. Open coverage report
33
+ ```bash
34
+ open coverage/index.html
35
+ ```
36
+
37
+ ## Continuous Testing
38
+
39
+ For development with auto-reload:
40
+
41
+ ```bash
42
+ npm run test:watch
43
+ ```
44
+
45
+ ## Troubleshooting
46
+
47
+ - If tests fail, check the error output
48
+ - Clear cache: `npm run test:clear-cache`
49
+ - Update snapshots: `npm run test:update-snapshots`
@@ -0,0 +1,19 @@
1
+ ---
2
+ name: Example Skill
3
+ description: This is an example skill template
4
+ category: example
5
+ ---
6
+
7
+ # Example Skill
8
+
9
+ This is an example skill that demonstrates the structure of a skill file.
10
+
11
+ ## Usage
12
+
13
+ Add your skill documentation here.
14
+
15
+ ## Features
16
+
17
+ - Feature 1
18
+ - Feature 2
19
+ - Feature 3
@@ -0,0 +1,13 @@
1
+ export type AgentType = 'antigravity' | 'claude';
2
+ export interface AgentConfig {
3
+ name: string;
4
+ directory: string;
5
+ displayName: string;
6
+ }
7
+ export interface Skill {
8
+ name: string;
9
+ path: string;
10
+ description?: string;
11
+ }
12
+ export declare const AGENT_CONFIGS: Record<AgentType, AgentConfig>;
13
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GAAG,aAAa,GAAG,QAAQ,CAAC;AAEjD,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,KAAK;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,eAAO,MAAM,aAAa,EAAE,MAAM,CAAC,SAAS,EAAE,WAAW,CAWxD,CAAC"}
package/dist/types.js ADDED
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AGENT_CONFIGS = void 0;
4
+ exports.AGENT_CONFIGS = {
5
+ antigravity: {
6
+ name: 'antigravity',
7
+ directory: '.agent',
8
+ displayName: 'Antigravity',
9
+ },
10
+ claude: {
11
+ name: 'claude',
12
+ directory: '.claude',
13
+ displayName: 'Claude',
14
+ },
15
+ };
16
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;AAca,QAAA,aAAa,GAAmC;IAC3D,WAAW,EAAE;QACX,IAAI,EAAE,aAAa;QACnB,SAAS,EAAE,QAAQ;QACnB,WAAW,EAAE,aAAa;KAC3B;IACD,MAAM,EAAE;QACN,IAAI,EAAE,QAAQ;QACd,SAAS,EAAE,SAAS;QACpB,WAAW,EAAE,QAAQ;KACtB;CACF,CAAC"}
@@ -0,0 +1,13 @@
1
+ export declare const AGENT_STRUCTURES: {
2
+ antigravity: {
3
+ skills: string;
4
+ commands: string;
5
+ agents: string;
6
+ };
7
+ claude: {
8
+ skills: string;
9
+ commands: string;
10
+ agents: string;
11
+ };
12
+ };
13
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/utils/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB;;;;;;;;;;;CAW5B,CAAC"}
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AGENT_STRUCTURES = void 0;
4
+ exports.AGENT_STRUCTURES = {
5
+ antigravity: {
6
+ skills: 'skills',
7
+ commands: 'workflows',
8
+ agents: 'agents',
9
+ },
10
+ claude: {
11
+ skills: 'skills',
12
+ commands: 'commands',
13
+ agents: 'agents',
14
+ },
15
+ };
16
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/utils/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,gBAAgB,GAAG;IAC9B,WAAW,EAAE;QACX,MAAM,EAAE,QAAQ;QAChB,QAAQ,EAAE,WAAW;QACrB,MAAM,EAAE,QAAQ;KACjB;IACD,MAAM,EAAE;QACN,MAAM,EAAE,QAAQ;QAChB,QAAQ,EAAE,UAAU;QACpB,MAAM,EAAE,QAAQ;KACjB;CACF,CAAC"}
@@ -0,0 +1,55 @@
1
+ import { Skill, AgentType } from '../types';
2
+ export interface Template {
3
+ name: string;
4
+ path: string;
5
+ description?: string;
6
+ }
7
+ /**
8
+ * Get all available skills from the skills directory
9
+ */
10
+ export declare function getAvailableSkills(skillsDir: string): Promise<Skill[]>;
11
+ /**
12
+ * Get all available command templates
13
+ */
14
+ export declare function getAvailableCommands(commandsDir: string): Promise<Template[]>;
15
+ /**
16
+ * Get all available agent templates
17
+ */
18
+ export declare function getAvailableAgents(agentsDir: string): Promise<Template[]>;
19
+ /**
20
+ * Copy .md files from a skill directory to the target agent directory
21
+ */
22
+ export declare function copySkill(skillPath: string, targetDir: string, skillName: string, agent: AgentType): Promise<void>;
23
+ /**
24
+ * Copy a command template to the target directory
25
+ */
26
+ export declare function copyCommand(templatePath: string, targetDir: string, commandName: string, agent: AgentType): Promise<void>;
27
+ /**
28
+ * Copy an agent template to the target directory
29
+ */
30
+ export declare function copyAgent(templatePath: string, targetDir: string, agentName: string, agent: AgentType): Promise<void>;
31
+ /**
32
+ * Check if the current directory is a valid project (has package.json)
33
+ */
34
+ export declare function isValidProject(cwd: string): Promise<boolean>;
35
+ /**
36
+ * Check if agent directory exists, if not, create it
37
+ */
38
+ export declare function ensureAgentDirectory(agentDir: string): Promise<void>;
39
+ /**
40
+ * Check if skill already exists in target directory
41
+ */
42
+ export declare function skillExists(targetDir: string, skillName: string): Promise<boolean>;
43
+ /**
44
+ * Check if command already exists
45
+ */
46
+ export declare function commandExists(targetDir: string, commandName: string, agent: AgentType): Promise<boolean>;
47
+ /**
48
+ * Check if agent already exists
49
+ */
50
+ export declare function agentExists(targetDir: string, agentName: string): Promise<boolean>;
51
+ /**
52
+ * Remove a skill from the target directory
53
+ */
54
+ export declare function removeSkill(targetDir: string, skillName: string): Promise<void>;
55
+ //# sourceMappingURL=copy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"copy.d.ts","sourceRoot":"","sources":["../../src/utils/copy.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAI5C,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAgDD;;GAEG;AACH,wBAAsB,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC,CAE5E;AAED;;GAEG;AACH,wBAAsB,oBAAoB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC,CAEnF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AM,GAAG,OAAO,CAAC,IAAI,CAAC,CAErF"}
@@ -0,0 +1,229 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.getAvailableSkills = getAvailableSkills;
40
+ exports.getAvailableCommands = getAvailableCommands;
41
+ exports.getAvailableAgents = getAvailableAgents;
42
+ exports.copySkill = copySkill;
43
+ exports.copyCommand = copyCommand;
44
+ exports.copyAgent = copyAgent;
45
+ exports.isValidProject = isValidProject;
46
+ exports.ensureAgentDirectory = ensureAgentDirectory;
47
+ exports.skillExists = skillExists;
48
+ exports.commandExists = commandExists;
49
+ exports.agentExists = agentExists;
50
+ exports.removeSkill = removeSkill;
51
+ const fs = __importStar(require("fs-extra"));
52
+ const path = __importStar(require("path"));
53
+ const fast_glob_1 = __importDefault(require("fast-glob"));
54
+ const file_builder_1 = require("./file-builder");
55
+ const constants_1 = require("./constants");
56
+ /**
57
+ * Generic function to extract description from markdown frontmatter
58
+ */
59
+ async function extractDescription(filePath) {
60
+ if (await fs.pathExists(filePath)) {
61
+ const content = await fs.readFile(filePath, 'utf-8');
62
+ const descMatch = content.match(/description:\s*(.+)/i);
63
+ return descMatch ? descMatch[1].trim() : undefined;
64
+ }
65
+ return undefined;
66
+ }
67
+ /**
68
+ * Generic function to get templates from a directory
69
+ */
70
+ async function getTemplates(templatesDir, metadataFile) {
71
+ try {
72
+ const items = await fs.readdir(templatesDir);
73
+ const templates = [];
74
+ for (const itemName of items) {
75
+ const itemPath = path.join(templatesDir, itemName);
76
+ const stat = await fs.stat(itemPath);
77
+ // Handle directory-based templates (skills, agents)
78
+ if (stat.isDirectory() && metadataFile) {
79
+ const description = await extractDescription(path.join(itemPath, metadataFile));
80
+ templates.push({ name: itemName, path: itemPath, description });
81
+ }
82
+ // Handle file-based templates (commands)
83
+ else if (stat.isFile() && itemName.endsWith('.md') && !metadataFile) {
84
+ const name = itemName.replace('.md', '');
85
+ const description = await extractDescription(itemPath);
86
+ templates.push({ name, path: itemPath, description });
87
+ }
88
+ }
89
+ return templates;
90
+ }
91
+ catch (error) {
92
+ return []; // Return empty array if directory doesn't exist
93
+ }
94
+ }
95
+ /**
96
+ * Get all available skills from the skills directory
97
+ */
98
+ async function getAvailableSkills(skillsDir) {
99
+ return getTemplates(skillsDir, 'SKILL.md');
100
+ }
101
+ /**
102
+ * Get all available command templates
103
+ */
104
+ async function getAvailableCommands(commandsDir) {
105
+ return getTemplates(commandsDir);
106
+ }
107
+ /**
108
+ * Get all available agent templates
109
+ */
110
+ async function getAvailableAgents(agentsDir) {
111
+ return getTemplates(agentsDir, 'AGENT.md');
112
+ }
113
+ /**
114
+ * Generic function to process and copy files with FileBuilder
115
+ */
116
+ async function processAndCopyFiles(sourcePath, destPath, agent, agentDir, pattern = '**/*') {
117
+ const files = await (0, fast_glob_1.default)(pattern, {
118
+ cwd: sourcePath,
119
+ absolute: false,
120
+ dot: false,
121
+ });
122
+ if (files.length === 0) {
123
+ throw new Error(`No files found matching pattern "${pattern}" in ${sourcePath}`);
124
+ }
125
+ await fs.ensureDir(destPath);
126
+ for (const file of files) {
127
+ const sourceFile = path.join(sourcePath, file);
128
+ const destFile = path.join(destPath, file);
129
+ await fs.ensureDir(path.dirname(destFile));
130
+ // Only process .md files with FileBuilder, copy others directly
131
+ if (file.endsWith('.md')) {
132
+ let content = await fs.readFile(sourceFile, 'utf-8');
133
+ // Process with FileBuilder to handle directives
134
+ content = new file_builder_1.FileBuilder({
135
+ agent,
136
+ content,
137
+ agentDir,
138
+ source: sourceFile,
139
+ })
140
+ .include()
141
+ .code()
142
+ .build();
143
+ await fs.writeFile(destFile, content, 'utf-8');
144
+ }
145
+ else {
146
+ // Copy non-.md files directly
147
+ await fs.copy(sourceFile, destFile);
148
+ }
149
+ }
150
+ }
151
+ /**
152
+ * Copy .md files from a skill directory to the target agent directory
153
+ */
154
+ async function copySkill(skillPath, targetDir, skillName, agent) {
155
+ const destination = path.join(targetDir, 'skills', skillName);
156
+ await processAndCopyFiles(skillPath, destination, agent, targetDir);
157
+ }
158
+ /**
159
+ * Copy a command template to the target directory
160
+ */
161
+ async function copyCommand(templatePath, targetDir, commandName, agent) {
162
+ const commandsDir = constants_1.AGENT_STRUCTURES[agent].commands;
163
+ const workflowsDir = path.join(targetDir, commandsDir);
164
+ await fs.ensureDir(workflowsDir);
165
+ const destFile = path.join(workflowsDir, `${commandName}.md`);
166
+ let content = await fs.readFile(templatePath, 'utf-8');
167
+ // Process with FileBuilder to handle directives
168
+ content = new file_builder_1.FileBuilder({
169
+ agent,
170
+ content,
171
+ agentDir: targetDir,
172
+ source: templatePath,
173
+ })
174
+ .include()
175
+ .code()
176
+ .build();
177
+ await fs.writeFile(destFile, content, 'utf-8');
178
+ }
179
+ /**
180
+ * Copy an agent template to the target directory
181
+ */
182
+ async function copyAgent(templatePath, targetDir, agentName, agent) {
183
+ const destDir = path.join(targetDir, 'agents', agentName);
184
+ await processAndCopyFiles(templatePath, destDir, agent, targetDir);
185
+ }
186
+ /**
187
+ * Check if the current directory is a valid project (has package.json)
188
+ */
189
+ async function isValidProject(cwd) {
190
+ return await fs.pathExists(path.join(cwd, 'package.json'));
191
+ }
192
+ /**
193
+ * Check if agent directory exists, if not, create it
194
+ */
195
+ async function ensureAgentDirectory(agentDir) {
196
+ await fs.ensureDir(agentDir);
197
+ }
198
+ /**
199
+ * Generic function to check if item exists
200
+ */
201
+ async function itemExists(targetDir, itemPath) {
202
+ return await fs.pathExists(path.join(targetDir, itemPath));
203
+ }
204
+ /**
205
+ * Check if skill already exists in target directory
206
+ */
207
+ async function skillExists(targetDir, skillName) {
208
+ return itemExists(targetDir, path.join('skills', skillName));
209
+ }
210
+ /**
211
+ * Check if command already exists
212
+ */
213
+ async function commandExists(targetDir, commandName, agent) {
214
+ const commandsDir = constants_1.AGENT_STRUCTURES[agent].commands;
215
+ return itemExists(targetDir, path.join(commandsDir, `${commandName}.md`));
216
+ }
217
+ /**
218
+ * Check if agent already exists
219
+ */
220
+ async function agentExists(targetDir, agentName) {
221
+ return itemExists(targetDir, path.join('agents', agentName));
222
+ }
223
+ /**
224
+ * Remove a skill from the target directory
225
+ */
226
+ async function removeSkill(targetDir, skillName) {
227
+ await fs.remove(path.join(targetDir, 'skills', skillName));
228
+ }
229
+ //# sourceMappingURL=copy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"copy.js","sourceRoot":"","sources":["../../src/utils/copy.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8DA,gDAEC;AAKD,oDAE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