@codigodoleo/wp-kit 3.4.1 → 3.5.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.
@@ -21,8 +21,16 @@ export async function runPrompts({ defaults = false } = {}) {
21
21
  {
22
22
  type: 'input',
23
23
  name: 'projectName',
24
- message: 'Project name:',
24
+ message: 'Project name (lowercase, hyphens only):',
25
25
  default: 'wordpress-dev',
26
+ filter: (val) =>
27
+ val
28
+ .trim()
29
+ .toLowerCase()
30
+ .replace(/\s+/g, '-')
31
+ .replace(/[^a-z0-9-]/g, ''),
32
+ validate: (val) =>
33
+ /^[a-z0-9][a-z0-9-]*$/.test(val) || 'Use only lowercase letters, numbers and hyphens.',
26
34
  },
27
35
  {
28
36
  type: 'input',
package/lib/utils/git.js CHANGED
@@ -6,6 +6,9 @@ import fs from 'fs-extra';
6
6
 
7
7
  import { log, color } from './logger.js';
8
8
 
9
+ const CLAUDE_PLUGIN_SUPERPOWERS_SAGE = '.claude/plugins/superpowers-sage';
10
+ const CLAUDE_PLUGIN_SUPERPOWERS = '.claude/plugins/superpowers';
11
+
9
12
  export function getGitUserDefaults() {
10
13
  const exec = (cmd) => {
11
14
  try {
@@ -28,7 +31,7 @@ export function getGitUserDefaults() {
28
31
  */
29
32
  const TARGET_CONFIG = {
30
33
  claude: {
31
- dest: '.claude/plugins/superpowers-sage',
34
+ dest: CLAUDE_PLUGIN_SUPERPOWERS_SAGE,
32
35
  dirs: ['.claude-plugin', 'skills', 'agents', 'hooks'],
33
36
  label: 'Claude Code (.claude/)',
34
37
  },
@@ -44,6 +47,78 @@ const TARGET_CONFIG = {
44
47
  },
45
48
  };
46
49
 
50
+ const CLAUDE_SETTINGS_BASELINE = {
51
+ $schema: 'https://json.schemastore.org/claude-code-settings.json',
52
+ permissions: {
53
+ deny: [
54
+ 'Read(./.env)',
55
+ 'Read(./.env.*)',
56
+ 'Read(./secrets/**)',
57
+ 'Read(./config/credentials.json)',
58
+ ],
59
+ },
60
+ };
61
+
62
+ function mergeUnique(base = [], extra = []) {
63
+ return [...new Set([...(Array.isArray(base) ? base : []), ...extra])];
64
+ }
65
+
66
+ function mergeClaudeSettings(existing = {}, incoming = {}) {
67
+ const merged = { ...existing, ...incoming };
68
+
69
+ const existingPermissions = existing.permissions ?? {};
70
+ const incomingPermissions = incoming.permissions ?? {};
71
+
72
+ merged.permissions = {
73
+ ...existingPermissions,
74
+ ...incomingPermissions,
75
+ deny: mergeUnique(existingPermissions.deny, incomingPermissions.deny),
76
+ };
77
+
78
+ merged.enabledPlugins = {
79
+ ...(existing.enabledPlugins ?? {}),
80
+ ...(incoming.enabledPlugins ?? {}),
81
+ };
82
+
83
+ return merged;
84
+ }
85
+
86
+ async function updateClaudeProjectSettings(targetDir, enabledPlugins = {}) {
87
+ const claudeDir = path.join(targetDir, '.claude');
88
+ const settingsPath = path.join(claudeDir, 'settings.json');
89
+
90
+ await fs.ensureDir(claudeDir);
91
+
92
+ let existing = {};
93
+ if (await fs.pathExists(settingsPath)) {
94
+ try {
95
+ existing = await fs.readJson(settingsPath);
96
+ } catch {
97
+ log(
98
+ color.orange,
99
+ '[skills] .claude/settings.json invalido. Recriando com baseline seguro + plugins instalados.'
100
+ );
101
+ }
102
+ }
103
+
104
+ const nextSettings = mergeClaudeSettings(existing, {
105
+ ...CLAUDE_SETTINGS_BASELINE,
106
+ enabledPlugins,
107
+ });
108
+
109
+ await fs.writeJson(settingsPath, nextSettings, { spaces: 2 });
110
+ log(
111
+ color.green,
112
+ '✅ .claude/settings.json atualizado com plugins locais e baseline de seguranca.'
113
+ );
114
+ }
115
+
116
+ function cloneRepo(repo, tmpDir) {
117
+ return spawnSync('git', ['clone', '--depth=1', repo, tmpDir], {
118
+ stdio: 'inherit',
119
+ });
120
+ }
121
+
47
122
  /**
48
123
  * Clona codigodoleo/superpowers-sage e copia o conteúdo para os destinos selecionados.
49
124
  * Requer git instalado no host.
@@ -52,8 +127,10 @@ const TARGET_CONFIG = {
52
127
  * @param {string[]} targets - Lista de destinos: 'claude' | 'cursor' | 'ai'
53
128
  */
54
129
  export async function installSuperpowersSage(targetDir, targets = ['claude']) {
55
- const repo = 'https://github.com/codigodoleo/superpowers-sage.git';
130
+ const sageRepo = 'https://github.com/codigodoleo/superpowers-sage.git';
131
+ const baseRepo = 'https://github.com/obra/superpowers.git';
56
132
  const tmpDir = path.join(os.tmpdir(), `superpowers-sage-${Date.now()}`);
133
+ const tmpBaseDir = path.join(os.tmpdir(), `superpowers-base-${Date.now()}`);
57
134
 
58
135
  const validTargets = targets.filter((t) => TARGET_CONFIG[t]);
59
136
  if (validTargets.length === 0) {
@@ -63,9 +140,7 @@ export async function installSuperpowersSage(targetDir, targets = ['claude']) {
63
140
 
64
141
  log(color.blue, `🔌 Clonando superpowers-sage para: ${validTargets.join(', ')}...`);
65
142
 
66
- const result = spawnSync('git', ['clone', '--depth=1', repo, tmpDir], {
67
- stdio: 'inherit',
68
- });
143
+ const result = cloneRepo(sageRepo, tmpDir);
69
144
 
70
145
  if (result.status !== 0) {
71
146
  log(
@@ -92,5 +167,34 @@ export async function installSuperpowersSage(targetDir, targets = ['claude']) {
92
167
  log(color.green, `✅ superpowers-sage instalado em ${cfg.dest}`);
93
168
  }
94
169
 
170
+ const claudeEnabledPlugins = {
171
+ 'superpowers-sage@superpowers-sage-marketplace': true,
172
+ };
173
+
174
+ if (validTargets.includes('claude')) {
175
+ log(color.blue, '🔌 Clonando superpowers (base) para Claude Code...');
176
+
177
+ const baseResult = cloneRepo(baseRepo, tmpBaseDir);
178
+ if (baseResult.status !== 0) {
179
+ log(
180
+ color.orange,
181
+ '⚠️ Nao foi possivel clonar obra/superpowers. O plugin base nao foi instalado localmente.'
182
+ );
183
+ } else {
184
+ const baseDest = path.join(targetDir, CLAUDE_PLUGIN_SUPERPOWERS);
185
+ await fs.ensureDir(baseDest);
186
+ await fs.copy(tmpBaseDir, baseDest, {
187
+ overwrite: true,
188
+ filter: (src) =>
189
+ !src.includes(`${path.sep}.git${path.sep}`) && !src.endsWith(`${path.sep}.git`),
190
+ });
191
+ claudeEnabledPlugins['superpowers@superpowers-dev'] = true;
192
+ log(color.green, `✅ superpowers instalado em ${CLAUDE_PLUGIN_SUPERPOWERS}`);
193
+ }
194
+
195
+ await updateClaudeProjectSettings(targetDir, claudeEnabledPlugins);
196
+ }
197
+
95
198
  await fs.remove(tmpDir);
199
+ await fs.remove(tmpBaseDir);
96
200
  }
@@ -16,6 +16,17 @@ tooling:
16
16
  service: build
17
17
  description: Run the Sage/Vite development server
18
18
  cmd: npm run dev --prefix /app/content/themes/{{projectName}}
19
+ flush:
20
+ service: appserver
21
+ description: Flush WordPress, Acorn and Redis caches
22
+ cmd:
23
+ - appserver: wp acorn optimize:clear
24
+ - appserver: wp acorn cache:clear
25
+ - appserver: wp acorn view:clear
26
+ - appserver: wp acorn route:clear
27
+ - appserver: wp rewrite flush
28
+ - appserver: wp cache flush
29
+ - cache: redis-cli FLUSHDB
19
30
  theme-bootstrap:
20
31
  service: appserver
21
32
  description: Install theme dependencies
@@ -43,19 +54,3 @@ tooling:
43
54
  cmd: npx stylelint --fix "resources/**/*.{css,scss}" --config /app/content/themes/{{projectName}}/.stylelintrc.json
44
55
  dir: /app/content/themes/{{projectName}}
45
56
  {{/if}}
46
- acorn:
47
- service: appserver
48
- description: Run Acorn artisan commands
49
- dir: /app/content/themes/{{projectName}}
50
- cmd: wp acorn $ACORN_COMMAND
51
- options:
52
- command:
53
- passthrough: true
54
- alias:
55
- - c
56
- describe: Acorn command to execute
57
- interactive:
58
- type: input
59
- message: "Acorn command (example: make:component Hero)"
60
- weight: 100
61
- env: ACORN_COMMAND
@@ -2,7 +2,7 @@ export default [
2
2
  {
3
3
  type: 'confirm',
4
4
  name: 'enable_skills',
5
- message: 'Instalar AI skills (superpowers-sage) no projeto?',
5
+ message: 'Instalar AI skills no projeto (superpowers-sage + dependencias)?',
6
6
  default: true,
7
7
  },
8
8
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codigodoleo/wp-kit",
3
- "version": "3.4.1",
3
+ "version": "3.5.0",
4
4
  "description": "Kit opinativo para padronizar projetos WordPress com CI/CD dinâmico.",
5
5
  "main": "bin/index.js",
6
6
  "bin": {
@@ -21,7 +21,7 @@ lando theme-build # Production build
21
21
 
22
22
  ## AI Co-Pilot
23
23
 
24
- This project includes [superpowers-sage](https://github.com/codigodoleo/superpowers-sage) skills in `.claude/`.
24
+ This project includes [superpowers](https://github.com/obra/superpowers) and [superpowers-sage](https://github.com/codigodoleo/superpowers-sage) in `.claude/`.
25
25
  Start a session with:
26
26
 
27
27
  ```