fluentcart-developer 1.1.0 → 1.1.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/CLAUDE.md +22 -22
- package/LICENSE +21 -21
- package/README.md +169 -127
- package/SKILL.md +127 -127
- package/bin/index.js +281 -281
- package/package.json +48 -37
- package/skills/fluentcart-developer/SKILL.md +172 -172
- package/skills/fluentcart-developer/examples/README.md +25 -25
- package/skills/fluentcart-developer/examples/fluentcart-starter-child-theme/fluent-cart/checkout.php +32 -32
- package/skills/fluentcart-developer/examples/fluentcart-starter-child-theme/functions.php +40 -40
- package/skills/fluentcart-developer/examples/sample-custom-addon/fluentcart-custom-addon.php +114 -114
- package/skills/fluentcart-developer/examples/sample-custom-payment-gateway/fluentcart-custom-gateway-example.php +149 -149
- package/skills/fluentcart-developer/examples/sample-fee-surcharge-plugin/fluentcart-fee-surcharge.php +38 -38
- package/skills/fluentcart-developer/examples/sample-shipping-carrier/fluentcart-custom-shipping-carrier.php +62 -62
- package/skills/fluentcart-developer/references/action-hooks-admin-templates.md +787 -787
- package/skills/fluentcart-developer/references/action-hooks-cart-checkout.md +1355 -1355
- package/skills/fluentcart-developer/references/action-hooks-customers-users.md +266 -266
- package/skills/fluentcart-developer/references/action-hooks-licenses.md +855 -855
- package/skills/fluentcart-developer/references/action-hooks-orders.md +631 -631
- package/skills/fluentcart-developer/references/action-hooks-payments-integrations.md +963 -963
- package/skills/fluentcart-developer/references/action-hooks-products-coupons.md +585 -585
- package/skills/fluentcart-developer/references/action-hooks-subscriptions.md +661 -661
- package/skills/fluentcart-developer/references/database-models-query-builder.md +194 -194
- package/skills/fluentcart-developer/references/database-models-reference.md +604 -604
- package/skills/fluentcart-developer/references/database-schema-reference.md +940 -940
- package/skills/fluentcart-developer/references/engineering-notes.md +154 -154
- package/skills/fluentcart-developer/references/fee-system-guide.md +449 -449
- package/skills/fluentcart-developer/references/filter-hooks-cart-checkout.md +1202 -1202
- package/skills/fluentcart-developer/references/filter-hooks-customers-subscriptions.md +902 -902
- package/skills/fluentcart-developer/references/filter-hooks-integrations-advanced.md +1598 -1598
- package/skills/fluentcart-developer/references/filter-hooks-orders-payments.md +1319 -1319
- package/skills/fluentcart-developer/references/filter-hooks-products-pricing.md +628 -628
- package/skills/fluentcart-developer/references/filter-hooks-settings-configuration.md +1177 -1177
- package/skills/fluentcart-developer/references/fluentcart-developer-guide.md +154 -154
- package/skills/fluentcart-developer/references/ghost-product-selling.md +458 -458
- package/skills/fluentcart-developer/references/modules-and-extensions-reference.md +224 -224
- package/skills/fluentcart-developer/references/payment-gateway-integration.md +761 -761
- package/skills/fluentcart-developer/references/rest-api-checkout.md +286 -286
- package/skills/fluentcart-developer/references/rest-api-coupons.md +794 -794
- package/skills/fluentcart-developer/references/rest-api-customer-profile.md +190 -190
- package/skills/fluentcart-developer/references/rest-api-customers.md +1121 -1121
- package/skills/fluentcart-developer/references/rest-api-dashboard-utilities.md +219 -219
- package/skills/fluentcart-developer/references/rest-api-email-notifications.md +619 -619
- package/skills/fluentcart-developer/references/rest-api-files.md +290 -290
- package/skills/fluentcart-developer/references/rest-api-integrations.md +324 -324
- package/skills/fluentcart-developer/references/rest-api-labels-attributes.md +321 -321
- package/skills/fluentcart-developer/references/rest-api-licensing.md +171 -171
- package/skills/fluentcart-developer/references/rest-api-order-bumps.md +200 -200
- package/skills/fluentcart-developer/references/rest-api-orders.md +1241 -1241
- package/skills/fluentcart-developer/references/rest-api-overview.md +131 -131
- package/skills/fluentcart-developer/references/rest-api-products.md +2563 -2563
- package/skills/fluentcart-developer/references/rest-api-public-shop.md +172 -172
- package/skills/fluentcart-developer/references/rest-api-reference.md +552 -552
- package/skills/fluentcart-developer/references/rest-api-reports.md +377 -377
- package/skills/fluentcart-developer/references/rest-api-roles-permissions.md +147 -147
- package/skills/fluentcart-developer/references/rest-api-settings.md +528 -528
- package/skills/fluentcart-developer/references/rest-api-shipping.md +799 -799
- package/skills/fluentcart-developer/references/rest-api-subscriptions.md +606 -606
- package/skills/fluentcart-developer/references/rest-api-tax.md +356 -356
- package/skills/fluentcart-developer/references/subscription-customization.md +197 -197
- package/skills/fluentcart-developer/scripts/cli.js +1 -1
- package/.gitattributes +0 -2
- package/CONTRIBUTING.md +0 -73
- package/copy-skills.js +0 -43
- package/skills.sh.json +0 -13
package/bin/index.js
CHANGED
|
@@ -1,281 +1,281 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const fs = require('fs');
|
|
4
|
-
const path = require('path');
|
|
5
|
-
const os = require('os');
|
|
6
|
-
const readline = require('readline');
|
|
7
|
-
|
|
8
|
-
// Helper to copy directory recursively
|
|
9
|
-
function copyDir(src, dest) {
|
|
10
|
-
fs.mkdirSync(dest, { recursive: true });
|
|
11
|
-
let entries = fs.readdirSync(src, { withFileTypes: true });
|
|
12
|
-
|
|
13
|
-
for (let entry of entries) {
|
|
14
|
-
let srcPath = path.join(src, entry.name);
|
|
15
|
-
let destPath = path.join(dest, entry.name);
|
|
16
|
-
|
|
17
|
-
if (entry.isDirectory()) {
|
|
18
|
-
copyDir(srcPath, destPath);
|
|
19
|
-
} else {
|
|
20
|
-
fs.copyFileSync(srcPath, destPath);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
// Helper to safely write rules to a file with markers
|
|
26
|
-
function writeRulesWithMarkers(filePath, rulesContent, bannerName) {
|
|
27
|
-
try {
|
|
28
|
-
const dir = path.dirname(filePath);
|
|
29
|
-
fs.mkdirSync(dir, { recursive: true });
|
|
30
|
-
|
|
31
|
-
let existingContent = '';
|
|
32
|
-
if (fs.existsSync(filePath)) {
|
|
33
|
-
existingContent = fs.readFileSync(filePath, 'utf8');
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const startMarker = `<!-- BEGIN ${bannerName} -->`;
|
|
37
|
-
const endMarker = `<!-- END ${bannerName} -->`;
|
|
38
|
-
|
|
39
|
-
if (existingContent.includes(startMarker)) {
|
|
40
|
-
const startIndex = existingContent.indexOf(startMarker);
|
|
41
|
-
const endIndex = existingContent.indexOf(endMarker) + endMarker.length;
|
|
42
|
-
const updatedContent = existingContent.substring(0, startIndex) +
|
|
43
|
-
startMarker + '\n' + rulesContent + '\n' + endMarker +
|
|
44
|
-
existingContent.substring(endIndex);
|
|
45
|
-
fs.writeFileSync(filePath, updatedContent, 'utf8');
|
|
46
|
-
console.log(`✓ Updated rules in: ${filePath}`);
|
|
47
|
-
} else {
|
|
48
|
-
const separator = existingContent ? '\n\n' : '';
|
|
49
|
-
const newContent = existingContent + separator + startMarker + '\n' + rulesContent + '\n' + endMarker;
|
|
50
|
-
fs.writeFileSync(filePath, newContent, 'utf8');
|
|
51
|
-
console.log(`✓ Added rules to: ${filePath}`);
|
|
52
|
-
}
|
|
53
|
-
} catch (err) {
|
|
54
|
-
console.error(`Error updating rules in ${filePath}:`, err.message);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
// Helper to safely remove rules markers from a file
|
|
59
|
-
function removeRulesWithMarkers(filePath, bannerName) {
|
|
60
|
-
try {
|
|
61
|
-
if (!fs.existsSync(filePath)) return;
|
|
62
|
-
let existingContent = fs.readFileSync(filePath, 'utf8');
|
|
63
|
-
const startMarker = `<!-- BEGIN ${bannerName} -->`;
|
|
64
|
-
const endMarker = `<!-- END ${bannerName} -->`;
|
|
65
|
-
|
|
66
|
-
if (existingContent.includes(startMarker) && existingContent.includes(endMarker)) {
|
|
67
|
-
const startIndex = existingContent.indexOf(startMarker);
|
|
68
|
-
const endIndex = existingContent.indexOf(endMarker) + endMarker.length;
|
|
69
|
-
const updatedContent = existingContent.substring(0, startIndex) + existingContent.substring(endIndex);
|
|
70
|
-
fs.writeFileSync(filePath, updatedContent.trim(), 'utf8');
|
|
71
|
-
console.log(`✓ Removed rules from: ${filePath}`);
|
|
72
|
-
}
|
|
73
|
-
} catch (err) {
|
|
74
|
-
console.error(`Error removing rules from ${filePath}:`, err.message);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
const args = process.argv.slice(2);
|
|
79
|
-
const initialCommand = args[0];
|
|
80
|
-
|
|
81
|
-
const homeDir = os.homedir();
|
|
82
|
-
const packageRoot = path.join(__dirname, '..');
|
|
83
|
-
const localSkillSrc = path.join(packageRoot, 'skills', 'fluentcart-developer');
|
|
84
|
-
|
|
85
|
-
// Global Paths
|
|
86
|
-
const geminiGlobalSkillDir = path.join(homeDir, '.gemini', 'config', 'skills', 'fluentcart-developer');
|
|
87
|
-
const geminiGlobalRulesFile = path.join(homeDir, '.gemini', 'config', 'AGENTS.md');
|
|
88
|
-
const claudeGlobalSkillDir = path.join(homeDir, '.claude', 'skills', 'fluentcart-developer');
|
|
89
|
-
|
|
90
|
-
// Zed Global Path
|
|
91
|
-
const zedGlobalRulesWin = path.join(process.env.APPDATA || path.join(homeDir, 'AppData', 'Roaming'), 'Zed', 'AGENTS.md');
|
|
92
|
-
const zedGlobalRulesUnix = path.join(homeDir, '.config', 'zed', 'AGENTS.md');
|
|
93
|
-
|
|
94
|
-
// Load rules source
|
|
95
|
-
const rulesFileSrc = path.join(packageRoot, 'fluentcart-rules.md');
|
|
96
|
-
let rulesContent = '';
|
|
97
|
-
if (fs.existsSync(rulesFileSrc)) {
|
|
98
|
-
rulesContent = fs.readFileSync(rulesFileSrc, 'utf8');
|
|
99
|
-
} else {
|
|
100
|
-
rulesContent = `# FluentCart Development Rules\n\nEnsure functions.php includes add_theme_support('fluent_cart');`;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
// Global install function
|
|
104
|
-
function installGlobal() {
|
|
105
|
-
console.log('\nInstalling FluentCart Developer Skill globally for all IDEs...');
|
|
106
|
-
|
|
107
|
-
const srcSkillMd = path.join(localSkillSrc, 'SKILL.md');
|
|
108
|
-
const srcReferences = path.join(localSkillSrc, 'references');
|
|
109
|
-
const srcExamples = path.join(localSkillSrc, 'examples');
|
|
110
|
-
|
|
111
|
-
// 1. Antigravity/Gemini Global Skill & Rules
|
|
112
|
-
try {
|
|
113
|
-
fs.mkdirSync(geminiGlobalSkillDir, { recursive: true });
|
|
114
|
-
if (fs.existsSync(srcSkillMd)) fs.copyFileSync(srcSkillMd, path.join(geminiGlobalSkillDir, 'SKILL.md'));
|
|
115
|
-
if (fs.existsSync(srcReferences)) copyDir(srcReferences, path.join(geminiGlobalSkillDir, 'references'));
|
|
116
|
-
if (fs.existsSync(srcExamples)) copyDir(srcExamples, path.join(geminiGlobalSkillDir, 'examples'));
|
|
117
|
-
|
|
118
|
-
writeRulesWithMarkers(geminiGlobalRulesFile, rulesContent, 'FLUENTCART_RULES');
|
|
119
|
-
console.log('✓ Global skill and rules installed for Antigravity/Gemini!');
|
|
120
|
-
} catch (err) {
|
|
121
|
-
console.error('Error installing global Antigravity skill:', err.message);
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
// 2. Claude Code Global Skill
|
|
125
|
-
try {
|
|
126
|
-
fs.mkdirSync(claudeGlobalSkillDir, { recursive: true });
|
|
127
|
-
if (fs.existsSync(srcSkillMd)) fs.copyFileSync(srcSkillMd, path.join(claudeGlobalSkillDir, 'SKILL.md'));
|
|
128
|
-
if (fs.existsSync(srcReferences)) copyDir(srcReferences, path.join(claudeGlobalSkillDir, 'references'));
|
|
129
|
-
if (fs.existsSync(srcExamples)) copyDir(srcExamples, path.join(claudeGlobalSkillDir, 'examples'));
|
|
130
|
-
|
|
131
|
-
console.log('✓ Global skill installed for Claude Code!');
|
|
132
|
-
} catch (err) {
|
|
133
|
-
console.error('Error installing global Claude Code skill:', err.message);
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
// 3. Zed Global Rules
|
|
137
|
-
try {
|
|
138
|
-
const isWindows = process.platform === 'win32';
|
|
139
|
-
const zedGlobalRulesPath = isWindows ? zedGlobalRulesWin : zedGlobalRulesUnix;
|
|
140
|
-
writeRulesWithMarkers(zedGlobalRulesPath, rulesContent, 'FLUENTCART_RULES');
|
|
141
|
-
console.log('✓ Global rules installed for Zed!');
|
|
142
|
-
} catch (err) {
|
|
143
|
-
console.error('Error installing global Zed rules:', err.message);
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
console.log('✓ Global installation completed successfully!\n');
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
// Project install function
|
|
150
|
-
function installProject() {
|
|
151
|
-
console.log('\nInitializing project-specific skills and rules in current directory...');
|
|
152
|
-
const cwd = process.cwd();
|
|
153
|
-
const srcSkillMd = path.join(localSkillSrc, 'SKILL.md');
|
|
154
|
-
const srcReferences = path.join(localSkillSrc, 'references');
|
|
155
|
-
const srcExamples = path.join(localSkillSrc, 'examples');
|
|
156
|
-
|
|
157
|
-
try {
|
|
158
|
-
// A. Project rules files
|
|
159
|
-
if (fs.existsSync(path.join(packageRoot, '.cursorrules'))) {
|
|
160
|
-
fs.copyFileSync(path.join(packageRoot, '.cursorrules'), path.join(cwd, '.cursorrules'));
|
|
161
|
-
fs.copyFileSync(path.join(packageRoot, '.cursorrules'), path.join(cwd, '.windsurfrules'));
|
|
162
|
-
fs.copyFileSync(path.join(packageRoot, '.cursorrules'), path.join(cwd, '.clinerules'));
|
|
163
|
-
fs.copyFileSync(path.join(packageRoot, '.cursorrules'), path.join(cwd, '.rules'));
|
|
164
|
-
}
|
|
165
|
-
if (fs.existsSync(path.join(packageRoot, 'CLAUDE.md'))) {
|
|
166
|
-
fs.copyFileSync(path.join(packageRoot, 'CLAUDE.md'), path.join(cwd, 'CLAUDE.md'));
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
const copilotDir = path.join(cwd, '.github');
|
|
170
|
-
fs.mkdirSync(copilotDir, { recursive: true });
|
|
171
|
-
if (fs.existsSync(path.join(packageRoot, '.cursorrules'))) {
|
|
172
|
-
fs.copyFileSync(path.join(packageRoot, '.cursorrules'), path.join(copilotDir, 'copilot-instructions.md'));
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
console.log('✓ Created project rules files (.cursorrules, .windsurfrules, .clinerules, .rules, CLAUDE.md, .github/copilot-instructions.md)');
|
|
176
|
-
|
|
177
|
-
// B. Project-level Skills
|
|
178
|
-
const geminiLocalSkillDir = path.join(cwd, '.agents', 'skills', 'fluentcart-developer');
|
|
179
|
-
fs.mkdirSync(geminiLocalSkillDir, { recursive: true });
|
|
180
|
-
if (fs.existsSync(srcSkillMd)) fs.copyFileSync(srcSkillMd, path.join(geminiLocalSkillDir, 'SKILL.md'));
|
|
181
|
-
if (fs.existsSync(srcReferences)) copyDir(srcReferences, path.join(geminiLocalSkillDir, 'references'));
|
|
182
|
-
if (fs.existsSync(srcExamples)) copyDir(srcExamples, path.join(geminiLocalSkillDir, 'examples'));
|
|
183
|
-
|
|
184
|
-
console.log('✓ Created project skills directory (.agents/skills/fluentcart-developer)');
|
|
185
|
-
console.log('✓ Project initialization completed successfully!\n');
|
|
186
|
-
} catch (err) {
|
|
187
|
-
console.error('Error initializing project rules:', err.message);
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
// Remove rules function
|
|
192
|
-
function removeRules() {
|
|
193
|
-
console.log('\nRemoving FluentCart rules from global and project files...');
|
|
194
|
-
const cwd = process.cwd();
|
|
195
|
-
|
|
196
|
-
removeRulesWithMarkers(geminiGlobalRulesFile, 'FLUENTCART_RULES');
|
|
197
|
-
|
|
198
|
-
const isWindows = process.platform === 'win32';
|
|
199
|
-
const zedGlobalRulesPath = isWindows ? zedGlobalRulesWin : zedGlobalRulesUnix;
|
|
200
|
-
removeRulesWithMarkers(zedGlobalRulesPath, 'FLUENTCART_RULES');
|
|
201
|
-
|
|
202
|
-
// Remove project rules files
|
|
203
|
-
const projectFilesToRemove = [
|
|
204
|
-
path.join(cwd, '.cursorrules'),
|
|
205
|
-
path.join(cwd, '.windsurfrules'),
|
|
206
|
-
path.join(cwd, '.clinerules'),
|
|
207
|
-
path.join(cwd, '.rules'),
|
|
208
|
-
path.join(cwd, 'CLAUDE.md'),
|
|
209
|
-
path.join(cwd, '.github', 'copilot-instructions.md')
|
|
210
|
-
];
|
|
211
|
-
|
|
212
|
-
projectFilesToRemove.forEach(file => {
|
|
213
|
-
if (fs.existsSync(file)) {
|
|
214
|
-
try {
|
|
215
|
-
fs.unlinkSync(file);
|
|
216
|
-
console.log(`✓ Removed: ${file}`);
|
|
217
|
-
} catch (err) {
|
|
218
|
-
console.error(`Error removing ${file}:`, err.message);
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
});
|
|
222
|
-
|
|
223
|
-
// Remove local skills directory
|
|
224
|
-
const geminiLocalSkillDir = path.join(cwd, '.agents', 'skills', 'fluentcart-developer');
|
|
225
|
-
if (fs.existsSync(geminiLocalSkillDir)) {
|
|
226
|
-
try {
|
|
227
|
-
fs.rmSync(geminiLocalSkillDir, { recursive: true, force: true });
|
|
228
|
-
console.log(`✓ Removed project skill directory: ${geminiLocalSkillDir}`);
|
|
229
|
-
} catch (err) {
|
|
230
|
-
console.error(`Error removing project skill dir:`, err.message);
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
console.log('✓ Removal completed!\n');
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
// CLI Command Router
|
|
238
|
-
if (initialCommand === 'init') {
|
|
239
|
-
installGlobal();
|
|
240
|
-
installProject();
|
|
241
|
-
} else if (initialCommand === 'global') {
|
|
242
|
-
installGlobal();
|
|
243
|
-
} else if (initialCommand === 'project') {
|
|
244
|
-
installProject();
|
|
245
|
-
} else if (initialCommand === 'remove') {
|
|
246
|
-
removeRules();
|
|
247
|
-
} else {
|
|
248
|
-
// Interactive Wizard
|
|
249
|
-
const rl = readline.createInterface({
|
|
250
|
-
input: process.stdin,
|
|
251
|
-
output: process.stdout
|
|
252
|
-
});
|
|
253
|
-
|
|
254
|
-
console.log('\n======================================================');
|
|
255
|
-
console.log(' FluentCart Developer Skill & Rules Installer');
|
|
256
|
-
console.log('======================================================');
|
|
257
|
-
console.log('Select an installation option:');
|
|
258
|
-
console.log(' 1. Initialize BOTH Global & Current Project Rules (Recommended)');
|
|
259
|
-
console.log(' 2. Install ONLY Global Skill (~/.gemini/, ~/.claude/, Zed)');
|
|
260
|
-
console.log(' 3. Setup ONLY Current Project Rules & Local Skills (.agents/)');
|
|
261
|
-
console.log(' 4. Remove FluentCart rules & skills');
|
|
262
|
-
console.log(' 5. Exit');
|
|
263
|
-
console.log('------------------------------------------------------');
|
|
264
|
-
|
|
265
|
-
rl.question('Enter your choice (1-5): ', (answer) => {
|
|
266
|
-
const choice = answer.trim();
|
|
267
|
-
if (choice === '1') {
|
|
268
|
-
installGlobal();
|
|
269
|
-
installProject();
|
|
270
|
-
} else if (choice === '2') {
|
|
271
|
-
installGlobal();
|
|
272
|
-
} else if (choice === '3') {
|
|
273
|
-
installProject();
|
|
274
|
-
} else if (choice === '4') {
|
|
275
|
-
removeRules();
|
|
276
|
-
} else {
|
|
277
|
-
console.log('Exiting without changes.');
|
|
278
|
-
}
|
|
279
|
-
rl.close();
|
|
280
|
-
});
|
|
281
|
-
}
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
const os = require('os');
|
|
6
|
+
const readline = require('readline');
|
|
7
|
+
|
|
8
|
+
// Helper to copy directory recursively
|
|
9
|
+
function copyDir(src, dest) {
|
|
10
|
+
fs.mkdirSync(dest, { recursive: true });
|
|
11
|
+
let entries = fs.readdirSync(src, { withFileTypes: true });
|
|
12
|
+
|
|
13
|
+
for (let entry of entries) {
|
|
14
|
+
let srcPath = path.join(src, entry.name);
|
|
15
|
+
let destPath = path.join(dest, entry.name);
|
|
16
|
+
|
|
17
|
+
if (entry.isDirectory()) {
|
|
18
|
+
copyDir(srcPath, destPath);
|
|
19
|
+
} else {
|
|
20
|
+
fs.copyFileSync(srcPath, destPath);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// Helper to safely write rules to a file with markers
|
|
26
|
+
function writeRulesWithMarkers(filePath, rulesContent, bannerName) {
|
|
27
|
+
try {
|
|
28
|
+
const dir = path.dirname(filePath);
|
|
29
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
30
|
+
|
|
31
|
+
let existingContent = '';
|
|
32
|
+
if (fs.existsSync(filePath)) {
|
|
33
|
+
existingContent = fs.readFileSync(filePath, 'utf8');
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const startMarker = `<!-- BEGIN ${bannerName} -->`;
|
|
37
|
+
const endMarker = `<!-- END ${bannerName} -->`;
|
|
38
|
+
|
|
39
|
+
if (existingContent.includes(startMarker)) {
|
|
40
|
+
const startIndex = existingContent.indexOf(startMarker);
|
|
41
|
+
const endIndex = existingContent.indexOf(endMarker) + endMarker.length;
|
|
42
|
+
const updatedContent = existingContent.substring(0, startIndex) +
|
|
43
|
+
startMarker + '\n' + rulesContent + '\n' + endMarker +
|
|
44
|
+
existingContent.substring(endIndex);
|
|
45
|
+
fs.writeFileSync(filePath, updatedContent, 'utf8');
|
|
46
|
+
console.log(`✓ Updated rules in: ${filePath}`);
|
|
47
|
+
} else {
|
|
48
|
+
const separator = existingContent ? '\n\n' : '';
|
|
49
|
+
const newContent = existingContent + separator + startMarker + '\n' + rulesContent + '\n' + endMarker;
|
|
50
|
+
fs.writeFileSync(filePath, newContent, 'utf8');
|
|
51
|
+
console.log(`✓ Added rules to: ${filePath}`);
|
|
52
|
+
}
|
|
53
|
+
} catch (err) {
|
|
54
|
+
console.error(`Error updating rules in ${filePath}:`, err.message);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// Helper to safely remove rules markers from a file
|
|
59
|
+
function removeRulesWithMarkers(filePath, bannerName) {
|
|
60
|
+
try {
|
|
61
|
+
if (!fs.existsSync(filePath)) return;
|
|
62
|
+
let existingContent = fs.readFileSync(filePath, 'utf8');
|
|
63
|
+
const startMarker = `<!-- BEGIN ${bannerName} -->`;
|
|
64
|
+
const endMarker = `<!-- END ${bannerName} -->`;
|
|
65
|
+
|
|
66
|
+
if (existingContent.includes(startMarker) && existingContent.includes(endMarker)) {
|
|
67
|
+
const startIndex = existingContent.indexOf(startMarker);
|
|
68
|
+
const endIndex = existingContent.indexOf(endMarker) + endMarker.length;
|
|
69
|
+
const updatedContent = existingContent.substring(0, startIndex) + existingContent.substring(endIndex);
|
|
70
|
+
fs.writeFileSync(filePath, updatedContent.trim(), 'utf8');
|
|
71
|
+
console.log(`✓ Removed rules from: ${filePath}`);
|
|
72
|
+
}
|
|
73
|
+
} catch (err) {
|
|
74
|
+
console.error(`Error removing rules from ${filePath}:`, err.message);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const args = process.argv.slice(2);
|
|
79
|
+
const initialCommand = args[0];
|
|
80
|
+
|
|
81
|
+
const homeDir = os.homedir();
|
|
82
|
+
const packageRoot = path.join(__dirname, '..');
|
|
83
|
+
const localSkillSrc = path.join(packageRoot, 'skills', 'fluentcart-developer');
|
|
84
|
+
|
|
85
|
+
// Global Paths
|
|
86
|
+
const geminiGlobalSkillDir = path.join(homeDir, '.gemini', 'config', 'skills', 'fluentcart-developer');
|
|
87
|
+
const geminiGlobalRulesFile = path.join(homeDir, '.gemini', 'config', 'AGENTS.md');
|
|
88
|
+
const claudeGlobalSkillDir = path.join(homeDir, '.claude', 'skills', 'fluentcart-developer');
|
|
89
|
+
|
|
90
|
+
// Zed Global Path
|
|
91
|
+
const zedGlobalRulesWin = path.join(process.env.APPDATA || path.join(homeDir, 'AppData', 'Roaming'), 'Zed', 'AGENTS.md');
|
|
92
|
+
const zedGlobalRulesUnix = path.join(homeDir, '.config', 'zed', 'AGENTS.md');
|
|
93
|
+
|
|
94
|
+
// Load rules source
|
|
95
|
+
const rulesFileSrc = path.join(packageRoot, 'fluentcart-rules.md');
|
|
96
|
+
let rulesContent = '';
|
|
97
|
+
if (fs.existsSync(rulesFileSrc)) {
|
|
98
|
+
rulesContent = fs.readFileSync(rulesFileSrc, 'utf8');
|
|
99
|
+
} else {
|
|
100
|
+
rulesContent = `# FluentCart Development Rules\n\nEnsure functions.php includes add_theme_support('fluent_cart');`;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// Global install function
|
|
104
|
+
function installGlobal() {
|
|
105
|
+
console.log('\nInstalling FluentCart Developer Skill globally for all IDEs...');
|
|
106
|
+
|
|
107
|
+
const srcSkillMd = path.join(localSkillSrc, 'SKILL.md');
|
|
108
|
+
const srcReferences = path.join(localSkillSrc, 'references');
|
|
109
|
+
const srcExamples = path.join(localSkillSrc, 'examples');
|
|
110
|
+
|
|
111
|
+
// 1. Antigravity/Gemini Global Skill & Rules
|
|
112
|
+
try {
|
|
113
|
+
fs.mkdirSync(geminiGlobalSkillDir, { recursive: true });
|
|
114
|
+
if (fs.existsSync(srcSkillMd)) fs.copyFileSync(srcSkillMd, path.join(geminiGlobalSkillDir, 'SKILL.md'));
|
|
115
|
+
if (fs.existsSync(srcReferences)) copyDir(srcReferences, path.join(geminiGlobalSkillDir, 'references'));
|
|
116
|
+
if (fs.existsSync(srcExamples)) copyDir(srcExamples, path.join(geminiGlobalSkillDir, 'examples'));
|
|
117
|
+
|
|
118
|
+
writeRulesWithMarkers(geminiGlobalRulesFile, rulesContent, 'FLUENTCART_RULES');
|
|
119
|
+
console.log('✓ Global skill and rules installed for Antigravity/Gemini!');
|
|
120
|
+
} catch (err) {
|
|
121
|
+
console.error('Error installing global Antigravity skill:', err.message);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// 2. Claude Code Global Skill
|
|
125
|
+
try {
|
|
126
|
+
fs.mkdirSync(claudeGlobalSkillDir, { recursive: true });
|
|
127
|
+
if (fs.existsSync(srcSkillMd)) fs.copyFileSync(srcSkillMd, path.join(claudeGlobalSkillDir, 'SKILL.md'));
|
|
128
|
+
if (fs.existsSync(srcReferences)) copyDir(srcReferences, path.join(claudeGlobalSkillDir, 'references'));
|
|
129
|
+
if (fs.existsSync(srcExamples)) copyDir(srcExamples, path.join(claudeGlobalSkillDir, 'examples'));
|
|
130
|
+
|
|
131
|
+
console.log('✓ Global skill installed for Claude Code!');
|
|
132
|
+
} catch (err) {
|
|
133
|
+
console.error('Error installing global Claude Code skill:', err.message);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// 3. Zed Global Rules
|
|
137
|
+
try {
|
|
138
|
+
const isWindows = process.platform === 'win32';
|
|
139
|
+
const zedGlobalRulesPath = isWindows ? zedGlobalRulesWin : zedGlobalRulesUnix;
|
|
140
|
+
writeRulesWithMarkers(zedGlobalRulesPath, rulesContent, 'FLUENTCART_RULES');
|
|
141
|
+
console.log('✓ Global rules installed for Zed!');
|
|
142
|
+
} catch (err) {
|
|
143
|
+
console.error('Error installing global Zed rules:', err.message);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
console.log('✓ Global installation completed successfully!\n');
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// Project install function
|
|
150
|
+
function installProject() {
|
|
151
|
+
console.log('\nInitializing project-specific skills and rules in current directory...');
|
|
152
|
+
const cwd = process.cwd();
|
|
153
|
+
const srcSkillMd = path.join(localSkillSrc, 'SKILL.md');
|
|
154
|
+
const srcReferences = path.join(localSkillSrc, 'references');
|
|
155
|
+
const srcExamples = path.join(localSkillSrc, 'examples');
|
|
156
|
+
|
|
157
|
+
try {
|
|
158
|
+
// A. Project rules files
|
|
159
|
+
if (fs.existsSync(path.join(packageRoot, '.cursorrules'))) {
|
|
160
|
+
fs.copyFileSync(path.join(packageRoot, '.cursorrules'), path.join(cwd, '.cursorrules'));
|
|
161
|
+
fs.copyFileSync(path.join(packageRoot, '.cursorrules'), path.join(cwd, '.windsurfrules'));
|
|
162
|
+
fs.copyFileSync(path.join(packageRoot, '.cursorrules'), path.join(cwd, '.clinerules'));
|
|
163
|
+
fs.copyFileSync(path.join(packageRoot, '.cursorrules'), path.join(cwd, '.rules'));
|
|
164
|
+
}
|
|
165
|
+
if (fs.existsSync(path.join(packageRoot, 'CLAUDE.md'))) {
|
|
166
|
+
fs.copyFileSync(path.join(packageRoot, 'CLAUDE.md'), path.join(cwd, 'CLAUDE.md'));
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
const copilotDir = path.join(cwd, '.github');
|
|
170
|
+
fs.mkdirSync(copilotDir, { recursive: true });
|
|
171
|
+
if (fs.existsSync(path.join(packageRoot, '.cursorrules'))) {
|
|
172
|
+
fs.copyFileSync(path.join(packageRoot, '.cursorrules'), path.join(copilotDir, 'copilot-instructions.md'));
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
console.log('✓ Created project rules files (.cursorrules, .windsurfrules, .clinerules, .rules, CLAUDE.md, .github/copilot-instructions.md)');
|
|
176
|
+
|
|
177
|
+
// B. Project-level Skills
|
|
178
|
+
const geminiLocalSkillDir = path.join(cwd, '.agents', 'skills', 'fluentcart-developer');
|
|
179
|
+
fs.mkdirSync(geminiLocalSkillDir, { recursive: true });
|
|
180
|
+
if (fs.existsSync(srcSkillMd)) fs.copyFileSync(srcSkillMd, path.join(geminiLocalSkillDir, 'SKILL.md'));
|
|
181
|
+
if (fs.existsSync(srcReferences)) copyDir(srcReferences, path.join(geminiLocalSkillDir, 'references'));
|
|
182
|
+
if (fs.existsSync(srcExamples)) copyDir(srcExamples, path.join(geminiLocalSkillDir, 'examples'));
|
|
183
|
+
|
|
184
|
+
console.log('✓ Created project skills directory (.agents/skills/fluentcart-developer)');
|
|
185
|
+
console.log('✓ Project initialization completed successfully!\n');
|
|
186
|
+
} catch (err) {
|
|
187
|
+
console.error('Error initializing project rules:', err.message);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
// Remove rules function
|
|
192
|
+
function removeRules() {
|
|
193
|
+
console.log('\nRemoving FluentCart rules from global and project files...');
|
|
194
|
+
const cwd = process.cwd();
|
|
195
|
+
|
|
196
|
+
removeRulesWithMarkers(geminiGlobalRulesFile, 'FLUENTCART_RULES');
|
|
197
|
+
|
|
198
|
+
const isWindows = process.platform === 'win32';
|
|
199
|
+
const zedGlobalRulesPath = isWindows ? zedGlobalRulesWin : zedGlobalRulesUnix;
|
|
200
|
+
removeRulesWithMarkers(zedGlobalRulesPath, 'FLUENTCART_RULES');
|
|
201
|
+
|
|
202
|
+
// Remove project rules files
|
|
203
|
+
const projectFilesToRemove = [
|
|
204
|
+
path.join(cwd, '.cursorrules'),
|
|
205
|
+
path.join(cwd, '.windsurfrules'),
|
|
206
|
+
path.join(cwd, '.clinerules'),
|
|
207
|
+
path.join(cwd, '.rules'),
|
|
208
|
+
path.join(cwd, 'CLAUDE.md'),
|
|
209
|
+
path.join(cwd, '.github', 'copilot-instructions.md')
|
|
210
|
+
];
|
|
211
|
+
|
|
212
|
+
projectFilesToRemove.forEach(file => {
|
|
213
|
+
if (fs.existsSync(file)) {
|
|
214
|
+
try {
|
|
215
|
+
fs.unlinkSync(file);
|
|
216
|
+
console.log(`✓ Removed: ${file}`);
|
|
217
|
+
} catch (err) {
|
|
218
|
+
console.error(`Error removing ${file}:`, err.message);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
// Remove local skills directory
|
|
224
|
+
const geminiLocalSkillDir = path.join(cwd, '.agents', 'skills', 'fluentcart-developer');
|
|
225
|
+
if (fs.existsSync(geminiLocalSkillDir)) {
|
|
226
|
+
try {
|
|
227
|
+
fs.rmSync(geminiLocalSkillDir, { recursive: true, force: true });
|
|
228
|
+
console.log(`✓ Removed project skill directory: ${geminiLocalSkillDir}`);
|
|
229
|
+
} catch (err) {
|
|
230
|
+
console.error(`Error removing project skill dir:`, err.message);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
console.log('✓ Removal completed!\n');
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
// CLI Command Router
|
|
238
|
+
if (initialCommand === 'init') {
|
|
239
|
+
installGlobal();
|
|
240
|
+
installProject();
|
|
241
|
+
} else if (initialCommand === 'global') {
|
|
242
|
+
installGlobal();
|
|
243
|
+
} else if (initialCommand === 'project') {
|
|
244
|
+
installProject();
|
|
245
|
+
} else if (initialCommand === 'remove') {
|
|
246
|
+
removeRules();
|
|
247
|
+
} else {
|
|
248
|
+
// Interactive Wizard
|
|
249
|
+
const rl = readline.createInterface({
|
|
250
|
+
input: process.stdin,
|
|
251
|
+
output: process.stdout
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
console.log('\n======================================================');
|
|
255
|
+
console.log(' FluentCart Developer Skill & Rules Installer');
|
|
256
|
+
console.log('======================================================');
|
|
257
|
+
console.log('Select an installation option:');
|
|
258
|
+
console.log(' 1. Initialize BOTH Global & Current Project Rules (Recommended)');
|
|
259
|
+
console.log(' 2. Install ONLY Global Skill (~/.gemini/, ~/.claude/, Zed)');
|
|
260
|
+
console.log(' 3. Setup ONLY Current Project Rules & Local Skills (.agents/)');
|
|
261
|
+
console.log(' 4. Remove FluentCart rules & skills');
|
|
262
|
+
console.log(' 5. Exit');
|
|
263
|
+
console.log('------------------------------------------------------');
|
|
264
|
+
|
|
265
|
+
rl.question('Enter your choice (1-5): ', (answer) => {
|
|
266
|
+
const choice = answer.trim();
|
|
267
|
+
if (choice === '1') {
|
|
268
|
+
installGlobal();
|
|
269
|
+
installProject();
|
|
270
|
+
} else if (choice === '2') {
|
|
271
|
+
installGlobal();
|
|
272
|
+
} else if (choice === '3') {
|
|
273
|
+
installProject();
|
|
274
|
+
} else if (choice === '4') {
|
|
275
|
+
removeRules();
|
|
276
|
+
} else {
|
|
277
|
+
console.log('Exiting without changes.');
|
|
278
|
+
}
|
|
279
|
+
rl.close();
|
|
280
|
+
});
|
|
281
|
+
}
|
package/package.json
CHANGED
|
@@ -1,38 +1,49 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "fluentcart-developer",
|
|
3
|
-
"version": "1.1.
|
|
4
|
-
"description": "CLI tool and developer knowledge base for FluentCart theme, plugin, shipping, and payment gateway development",
|
|
5
|
-
"main": "bin/index.js",
|
|
6
|
-
"bin": {
|
|
7
|
-
"fluentcart-developer": "bin/index.js",
|
|
8
|
-
"fluentcart-ai-skill": "bin/index.js"
|
|
9
|
-
},
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
"
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
"
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
"
|
|
27
|
-
"skills"
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
"
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
"
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "fluentcart-developer",
|
|
3
|
+
"version": "1.1.1",
|
|
4
|
+
"description": "CLI tool and developer knowledge base for FluentCart theme, plugin, shipping, and payment gateway development",
|
|
5
|
+
"main": "bin/index.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"fluentcart-developer": "bin/index.js",
|
|
8
|
+
"fluentcart-ai-skill": "bin/index.js"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"bin/",
|
|
12
|
+
"SKILL.md",
|
|
13
|
+
"CLAUDE.md",
|
|
14
|
+
"skills/fluentcart-developer/"
|
|
15
|
+
],
|
|
16
|
+
"scripts": {
|
|
17
|
+
"build": "node copy-skills.js",
|
|
18
|
+
"build:server": "npm --prefix server run build",
|
|
19
|
+
"verify:server": "npm --prefix server run verify",
|
|
20
|
+
"check:skills": "node scripts/validate-skills.mjs",
|
|
21
|
+
"check:package": "node scripts/check-package.mjs",
|
|
22
|
+
"ci": "npm run check:skills && npm run check:package",
|
|
23
|
+
"prepublishOnly": "npm run ci && npm run build"
|
|
24
|
+
},
|
|
25
|
+
"repository": {
|
|
26
|
+
"type": "git",
|
|
27
|
+
"url": "git+https://github.com/atifjubaer/skills.git"
|
|
28
|
+
},
|
|
29
|
+
"homepage": "https://github.com/atifjubaer/skills#readme",
|
|
30
|
+
"bugs": {
|
|
31
|
+
"url": "https://github.com/atifjubaer/skills/issues"
|
|
32
|
+
},
|
|
33
|
+
"keywords": [
|
|
34
|
+
"fluentcart-developer",
|
|
35
|
+
"fluentcart",
|
|
36
|
+
"wordpress",
|
|
37
|
+
"ai-skills",
|
|
38
|
+
"skills",
|
|
39
|
+
"antigravity",
|
|
40
|
+
"cursor",
|
|
41
|
+
"claude-code",
|
|
42
|
+
"windsurf",
|
|
43
|
+
"cline",
|
|
44
|
+
"zed",
|
|
45
|
+
"copilot"
|
|
46
|
+
],
|
|
47
|
+
"author": "Fastrsoft",
|
|
48
|
+
"license": "MIT"
|
|
38
49
|
}
|