farmwork 1.0.0 → 1.0.1

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/src/add.js DELETED
@@ -1,194 +0,0 @@
1
- import fs from "fs-extra";
2
- import path from "path";
3
- import chalk from "chalk";
4
- import ora from "ora";
5
-
6
- const TEMPLATES = {
7
- agent: (name, description) => `# ${name} Agent
8
-
9
- > ${description}
10
-
11
- ## Purpose
12
-
13
- [Describe what this agent does and when to use it]
14
-
15
- ## Triggers
16
-
17
- This agent is launched via the Task tool with \`subagent_type="${name}"\`.
18
-
19
- ## Workflow
20
-
21
- 1. [First step]
22
- 2. [Second step]
23
- 3. [Third step]
24
-
25
- ## Output
26
-
27
- [Describe what the agent returns or produces]
28
-
29
- ## Examples
30
-
31
- \`\`\`
32
- # Example usage
33
- Task tool with subagent_type="${name}"
34
- Prompt: "[Example prompt]"
35
- \`\`\`
36
- `,
37
-
38
- command: (
39
- name,
40
- description,
41
- ) => `# ${name.charAt(0).toUpperCase() + name.slice(1)} Command
42
-
43
- ${description}
44
-
45
- ## Workflow
46
-
47
- Execute these steps in order. **Stop immediately if any step fails.**
48
-
49
- ### Step 1: [First Step]
50
-
51
- \`\`\`bash
52
- # Command to run
53
- \`\`\`
54
-
55
- ### Step 2: [Second Step]
56
-
57
- \`\`\`bash
58
- # Command to run
59
- \`\`\`
60
-
61
- ### Step 3: Report Results
62
-
63
- Show a summary of what was accomplished.
64
- `,
65
-
66
- audit: (name) => `# ${name.charAt(0).toUpperCase() + name.slice(1)} Audit
67
-
68
- > [One-line description of this audit area]
69
-
70
- **Last Updated:** ${new Date().toISOString().split("T")[0]}
71
- **Score:** 0.0/10
72
- **Status:** 0 open items
73
-
74
- ---
75
-
76
- ## How to get 10/10
77
-
78
- [One paragraph explaining what perfect looks like for this area]
79
-
80
- ---
81
-
82
- ## Constraints
83
-
84
- | Constraint | Reason | Impact |
85
- |------------|--------|--------|
86
- | [Constraint 1] | [Why] | [What happens] |
87
-
88
- ---
89
-
90
- ## Open Items
91
-
92
- _None currently_
93
-
94
- ---
95
-
96
- ## [Area-Specific Section]
97
-
98
- [Content specific to this audit area]
99
-
100
- ---
101
-
102
- ## Audit History
103
-
104
- | Date | Changes |
105
- |------|---------|
106
- | ${new Date().toISOString().split("T")[0]} | Initial audit document |
107
- `,
108
- };
109
-
110
- export async function add(type, name, options) {
111
- const cwd = process.cwd();
112
- const spinner = ora();
113
-
114
- const validTypes = ["agent", "command", "audit"];
115
- if (!validTypes.includes(type)) {
116
- console.log(chalk.red(`\n❌ Invalid type: ${type}`));
117
- console.log(chalk.gray(` Valid types: ${validTypes.join(", ")}`));
118
- return;
119
- }
120
-
121
- if (!name) {
122
- console.log(chalk.red("\n❌ Name is required"));
123
- console.log(chalk.gray(` Usage: produce add ${type} <name>`));
124
- return;
125
- }
126
-
127
- const claudeDir = path.join(cwd, ".claude");
128
- if (!fs.existsSync(claudeDir)) {
129
- console.log(chalk.red("\n❌ Farmwork not initialized"));
130
- console.log(chalk.gray(" Run: produce init"));
131
- return;
132
- }
133
-
134
- spinner.start(`Adding ${type}: ${name}`);
135
-
136
- try {
137
- let filePath;
138
- let content;
139
- let description = options?.description || `[Description for ${name}]`;
140
-
141
- switch (type) {
142
- case "agent":
143
- filePath = path.join(claudeDir, "agents", `${name}.md`);
144
- content = TEMPLATES.agent(name, description);
145
- break;
146
-
147
- case "command":
148
- filePath = path.join(claudeDir, "commands", `${name}.md`);
149
- content = TEMPLATES.command(name, description);
150
- break;
151
-
152
- case "audit":
153
- const auditDir = path.join(cwd, "_AUDIT");
154
- if (!fs.existsSync(auditDir)) {
155
- fs.mkdirSync(auditDir, { recursive: true });
156
- }
157
- filePath = path.join(auditDir, `${name.toUpperCase()}.md`);
158
- content = TEMPLATES.audit(name);
159
- break;
160
- }
161
-
162
- if (fs.existsSync(filePath)) {
163
- spinner.fail(`${type} already exists: ${name}`);
164
- console.log(chalk.gray(` File: ${filePath}`));
165
- return;
166
- }
167
-
168
- const dir = path.dirname(filePath);
169
- if (!fs.existsSync(dir)) {
170
- fs.mkdirSync(dir, { recursive: true });
171
- }
172
-
173
- fs.writeFileSync(filePath, content);
174
- spinner.succeed(`Added ${type}: ${name}`);
175
-
176
- console.log(chalk.gray(`\n File: ${filePath}`));
177
- console.log(chalk.cyan(`\n Edit the file to customize the ${type}.`));
178
-
179
- if (type === "agent") {
180
- console.log(
181
- chalk.gray(`\n Launch with: Task tool, subagent_type="${name}"`),
182
- );
183
- } else if (type === "command") {
184
- console.log(chalk.gray(`\n Invoke with: /${name}`));
185
- } else if (type === "audit") {
186
- console.log(
187
- chalk.gray(`\n Update FARMHOUSE.md to reference this audit.`),
188
- );
189
- }
190
- } catch (error) {
191
- spinner.fail(`Failed to add ${type}`);
192
- console.log(chalk.red(` ${error.message}`));
193
- }
194
- }