@donotdev/cli 0.0.37 → 0.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/LICENSE.md +21 -48
- package/dependencies-matrix.json +108 -58
- package/dist/bin/commands/agent-setup.js +7196 -123
- package/dist/bin/commands/build.js +3341 -207
- package/dist/bin/commands/bump.js +268 -24
- package/dist/bin/commands/cacheout.js +262 -13
- package/dist/bin/commands/coach.js +365 -61
- package/dist/bin/commands/create-app.js +261 -14
- package/dist/bin/commands/create-project.js +270 -15
- package/dist/bin/commands/db.js +10743 -2346
- package/dist/bin/commands/deploy.js +4202 -776
- package/dist/bin/commands/dev.js +353 -38
- package/dist/bin/commands/doctor.js +412 -108
- package/dist/bin/commands/emu.js +392 -57
- package/dist/bin/commands/format.js +250 -15
- package/dist/bin/commands/get-demo.js +261 -14
- package/dist/bin/commands/make-admin.js +10022 -1552
- package/dist/bin/commands/preview.js +353 -38
- package/dist/bin/commands/seed.js +10743 -2346
- package/dist/bin/commands/setup-cicd.js +456 -133
- package/dist/bin/commands/setup.js +428 -125
- package/dist/bin/commands/staging.js +4202 -776
- package/dist/bin/commands/sync-secrets.js +250 -14
- package/dist/bin/commands/type-check.js +249 -13
- package/dist/bin/commands/wai.js +249 -13
- package/dist/bin/dndev.js +33 -4
- package/dist/bin/donotdev.js +33 -4
- package/dist/index.js +4278 -856
- package/{templates/root-consumer/guides/dndev/advanced/VERSION_CONTROL.md.example → guidelines/VERSION_CONTROL.md} +7 -11
- package/package.json +3 -2
- package/templates/app-demo/src/themes.css.example +21 -0
- package/templates/app-dndev/index.html.example +0 -3
- package/templates/app-dndev/src/themes.css.example +21 -0
- package/templates/app-next/src/app/layout.tsx.example +13 -4
- package/templates/app-next/src/themes.css.example +21 -0
- package/templates/app-vite/csp.example.json +44 -0
- package/templates/app-vite/index.html.example +0 -3
- package/templates/app-vite/src/themes.css.example +21 -0
- package/templates/functions-supabase/supabase/functions/.env.example +12 -0
- package/templates/functions-supabase/supabase/functions/disconnect-oauth/index.ts.example +7 -0
- package/templates/functions-supabase/supabase/functions/exchange-token/index.ts.example +7 -0
- package/templates/functions-supabase/supabase/functions/get-connections/index.ts.example +7 -0
- package/templates/functions-supabase/supabase/functions/refresh-token/index.ts.example +7 -0
- package/templates/functions-supabase/supabase/migrations/20250101000000_idempotency.sql +3 -0
- package/templates/functions-supabase/supabase/migrations/20250101000001_rate_limits.sql +3 -0
- package/templates/functions-supabase/supabase/migrations/20250101000003_operation_metrics.sql +3 -0
- package/templates/preset-admin/src/pages/DashboardPage.tsx.example +189 -0
- package/templates/preset-admin/src/pages/EntityPage.tsx.example +84 -0
- package/templates/preset-admin/src/pages/ReportsPage.tsx.example +243 -0
- package/templates/preset-admin/src/pages/SettingsPage.tsx.example +283 -0
- package/templates/preset-admin/src/pages/UsersPage.tsx.example +128 -0
- package/templates/preset-ecommerce/src/pages/CartPage.tsx.example +167 -0
- package/templates/preset-ecommerce/src/pages/CatalogPage.tsx.example +187 -0
- package/templates/preset-ecommerce/src/pages/CheckoutPage.tsx.example +244 -0
- package/templates/preset-ecommerce/src/pages/HomePage.tsx.example +268 -0
- package/templates/preset-ecommerce/src/pages/ProductPage.tsx.example +228 -0
- package/templates/preset-landing/src/pages/AboutPage.tsx.example +237 -0
- package/templates/preset-landing/src/pages/ContactPage.tsx.example +192 -0
- package/templates/preset-landing/src/pages/HomePage.tsx.example +399 -0
- package/templates/preset-saas/src/pages/DashboardPage.tsx.example +195 -0
- package/templates/preset-saas/src/pages/HomePage.tsx.example +270 -0
- package/templates/preset-saas/src/pages/PricingPage.tsx.example +204 -0
- package/templates/preset-saas/src/pages/ProfilePage.tsx.example +191 -0
- package/templates/preset-saas/src/pages/SettingsPage.tsx.example +292 -0
- package/templates/root-consumer/.claude/hooks/framework-compliance.sh.example +56 -0
- package/templates/root-consumer/.claude/hooks/guard-bash.sh.example +61 -0
- package/templates/root-consumer/.claude/hooks/guard-files.sh.example +46 -0
- package/templates/root-consumer/.claude/hooks/guard-mcp.sh.example +91 -0
- package/templates/root-consumer/.claude/hooks/guard-secrets.sh.example +67 -0
- package/templates/root-consumer/.claude/hooks/guard-write.sh.example +89 -0
- package/templates/root-consumer/.claude/hooks/session-start.sh.example +50 -0
- package/templates/root-consumer/.claude/hooks/track-mcp-lookup.sh.example +20 -0
- package/templates/root-consumer/.claude/hooks/typecheck-stop.sh.example +18 -0
- package/templates/root-consumer/.claude/rules/consumer-ux.md.example +32 -0
- package/templates/root-consumer/.claude/rules/definition-of-done.md.example +32 -0
- package/templates/root-consumer/.claude/rules/framework.md.example +39 -0
- package/templates/root-consumer/.claude/rules/git.md.example +14 -0
- package/templates/root-consumer/.claude/rules/security.md.example +13 -0
- package/templates/root-consumer/.claude/settings.json.example +123 -1
- package/templates/root-consumer/.claude/skills/brainstorm/SKILL.md.example +16 -0
- package/templates/root-consumer/.claude/skills/build/SKILL.md.example +103 -25
- package/templates/root-consumer/.claude/skills/design/SKILL.md.example +17 -0
- package/templates/root-consumer/.claude/skills/grill/SKILL.md.example +33 -16
- package/templates/root-consumer/.claude/skills/polish/SKILL.md.example +50 -37
- package/templates/root-consumer/AI.md.example +2 -2
- package/templates/root-consumer/CLAUDE.md.example +33 -1
- package/templates/root-consumer/guides/dndev/INDEX.md.example +23 -27
- package/templates/root-consumer/guides/dndev/SETUP_AUTH.md.example +3 -2
- package/templates/root-consumer/guides/dndev/SETUP_OAUTH.md.example +12 -6
- package/templates/root-consumer/guides/dndev/SETUP_SUPABASE.md.example +50 -3
- package/templates/root-consumer/guides/wai-way/blueprints/3_compose.md.example +13 -15
- package/templates/app-demo/public/manifest.json.example +0 -10
- package/templates/app-dndev/public/manifest.json.example +0 -10
- package/templates/root-consumer/.claude/commands/brainstorm.md.example +0 -147
- package/templates/root-consumer/.claude/commands/build.md.example +0 -131
- package/templates/root-consumer/.claude/commands/design.md.example +0 -153
- package/templates/root-consumer/.claude/commands/grill.md.example +0 -108
- package/templates/root-consumer/.claude/commands/polish.md.example +0 -146
- package/templates/root-consumer/.claude/commands/techdebt.md.example +0 -28
- package/templates/root-consumer/guides/dndev/COMPONENTS_ATOMIC.md.example +0 -180
- package/templates/root-consumer/guides/dndev/COMPONENTS_CRUD.md.example +0 -234
- package/templates/root-consumer/guides/dndev/COMPONENTS_UI.md.example +0 -136
- package/templates/root-consumer/guides/dndev/COMPONENT_API.md.example +0 -195
- package/templates/root-consumer/guides/dndev/ENV_SETUP.md.example +0 -219
- package/templates/root-consumer/guides/dndev/GOTCHAS.md.example +0 -197
- package/templates/root-consumer/guides/dndev/SETUP_APP_CONFIG.md.example +0 -132
- package/templates/root-consumer/guides/dndev/SETUP_BLOG.md.example +0 -280
- package/templates/root-consumer/guides/dndev/SETUP_CICD.md.example +0 -115
- package/templates/root-consumer/guides/dndev/SETUP_CRUD.md.example +0 -334
- package/templates/root-consumer/guides/dndev/SETUP_FUNCTIONS.md.example +0 -9
- package/templates/root-consumer/guides/dndev/SETUP_I18N.md.example +0 -233
- package/templates/root-consumer/guides/dndev/SETUP_LAYOUTS.md.example +0 -158
- package/templates/root-consumer/guides/dndev/SETUP_PAGES.md.example +0 -205
- package/templates/root-consumer/guides/dndev/SETUP_PWA.md.example +0 -213
- package/templates/root-consumer/guides/dndev/SETUP_TESTING.md.example +0 -184
- package/templates/root-consumer/guides/dndev/SETUP_THEMES.md.example +0 -111
- package/templates/root-consumer/guides/dndev/SETUP_VERCEL.md.example +0 -260
- package/templates/root-consumer/guides/dndev/USE_ROUTING.md.example +0 -499
- package/templates/root-consumer/guides/dndev/essences_reference.css.example +0 -288
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
// {{appName}} - Settings Page
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
Settings,
|
|
6
|
+
User,
|
|
7
|
+
Bell,
|
|
8
|
+
Lock,
|
|
9
|
+
Mail,
|
|
10
|
+
Smartphone,
|
|
11
|
+
ShieldCheck,
|
|
12
|
+
Key,
|
|
13
|
+
} from 'lucide-react';
|
|
14
|
+
|
|
15
|
+
import {
|
|
16
|
+
Alert,
|
|
17
|
+
Button,
|
|
18
|
+
BUTTON_VARIANT,
|
|
19
|
+
Card,
|
|
20
|
+
Grid,
|
|
21
|
+
Input,
|
|
22
|
+
Section,
|
|
23
|
+
Select,
|
|
24
|
+
Separator,
|
|
25
|
+
Stack,
|
|
26
|
+
Switch,
|
|
27
|
+
Tabs,
|
|
28
|
+
Text,
|
|
29
|
+
} from '@donotdev/components';
|
|
30
|
+
import { useTranslation } from '@donotdev/core';
|
|
31
|
+
import { PageContainer } from '@donotdev/ui';
|
|
32
|
+
import { useAuth } from '@donotdev/auth';
|
|
33
|
+
|
|
34
|
+
import type { PageMeta } from '@donotdev/core';
|
|
35
|
+
|
|
36
|
+
export const NAMESPACE = 'settings';
|
|
37
|
+
|
|
38
|
+
export const meta: PageMeta = {
|
|
39
|
+
namespace: NAMESPACE,
|
|
40
|
+
icon: <Settings />,
|
|
41
|
+
auth: true,
|
|
42
|
+
preset: 'admin',
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
function ProfileTab() {
|
|
46
|
+
const { t } = useTranslation(NAMESPACE);
|
|
47
|
+
const user = useAuth('user');
|
|
48
|
+
|
|
49
|
+
return (
|
|
50
|
+
<Stack gap="large">
|
|
51
|
+
<Card
|
|
52
|
+
title={t('settings.profile.personalInfo', 'Personal Information')}
|
|
53
|
+
subtitle={t('settings.profile.personalInfoDesc', 'Update your personal details and public profile.')}
|
|
54
|
+
content={
|
|
55
|
+
<Stack gap="medium">
|
|
56
|
+
<Grid cols={[1, 1, 2, 2]} gap="medium">
|
|
57
|
+
<Input
|
|
58
|
+
label={t('settings.profile.firstName', 'First Name')}
|
|
59
|
+
placeholder={t('settings.profile.firstNamePlaceholder', 'Enter your first name')}
|
|
60
|
+
icon={User}
|
|
61
|
+
/>
|
|
62
|
+
<Input
|
|
63
|
+
label={t('settings.profile.lastName', 'Last Name')}
|
|
64
|
+
placeholder={t('settings.profile.lastNamePlaceholder', 'Enter your last name')}
|
|
65
|
+
/>
|
|
66
|
+
</Grid>
|
|
67
|
+
<Input
|
|
68
|
+
label={t('settings.profile.email', 'Email Address')}
|
|
69
|
+
placeholder={user?.email ?? t('settings.profile.emailPlaceholder', 'your@email.com')}
|
|
70
|
+
icon={Mail}
|
|
71
|
+
/>
|
|
72
|
+
<Select
|
|
73
|
+
label={t('settings.profile.language', 'Language')}
|
|
74
|
+
placeholder={t('settings.profile.languagePlaceholder', 'Select your language')}
|
|
75
|
+
options={[
|
|
76
|
+
{ label: 'English', value: 'en' },
|
|
77
|
+
{ label: 'Francais', value: 'fr' },
|
|
78
|
+
{ label: 'Deutsch', value: 'de' },
|
|
79
|
+
{ label: 'Espanol', value: 'es' },
|
|
80
|
+
]}
|
|
81
|
+
value="en"
|
|
82
|
+
onValueChange={() => {}}
|
|
83
|
+
/>
|
|
84
|
+
</Stack>
|
|
85
|
+
}
|
|
86
|
+
footer={
|
|
87
|
+
<Stack direction="row" justify="end" gap="medium">
|
|
88
|
+
<Button variant={BUTTON_VARIANT.GHOST}>
|
|
89
|
+
{t('settings.profile.cancel', 'Cancel')}
|
|
90
|
+
</Button>
|
|
91
|
+
<Button variant={BUTTON_VARIANT.PRIMARY}>
|
|
92
|
+
{t('settings.profile.save', 'Save Changes')}
|
|
93
|
+
</Button>
|
|
94
|
+
</Stack>
|
|
95
|
+
}
|
|
96
|
+
/>
|
|
97
|
+
</Stack>
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function NotificationsTab() {
|
|
102
|
+
const { t } = useTranslation(NAMESPACE);
|
|
103
|
+
|
|
104
|
+
const emailPreferences = [
|
|
105
|
+
{
|
|
106
|
+
label: t('settings.notifications.productUpdates', 'Product updates'),
|
|
107
|
+
description: t('settings.notifications.productUpdatesDesc', 'Receive emails about new features and improvements.'),
|
|
108
|
+
defaultChecked: true,
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
label: t('settings.notifications.securityAlerts', 'Security alerts'),
|
|
112
|
+
description: t('settings.notifications.securityAlertsDesc', 'Get notified about security events on your account.'),
|
|
113
|
+
defaultChecked: true,
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
label: t('settings.notifications.billing', 'Billing notifications'),
|
|
117
|
+
description: t('settings.notifications.billingDesc', 'Receive invoices and payment confirmations.'),
|
|
118
|
+
defaultChecked: true,
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
label: t('settings.notifications.marketing', 'Marketing emails'),
|
|
122
|
+
description: t('settings.notifications.marketingDesc', 'Tips, best practices, and promotional offers.'),
|
|
123
|
+
defaultChecked: false,
|
|
124
|
+
},
|
|
125
|
+
];
|
|
126
|
+
|
|
127
|
+
const pushPreferences = [
|
|
128
|
+
{
|
|
129
|
+
label: t('settings.notifications.pushActivity', 'Activity notifications'),
|
|
130
|
+
description: t('settings.notifications.pushActivityDesc', 'Get push notifications for team activity and mentions.'),
|
|
131
|
+
defaultChecked: true,
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
label: t('settings.notifications.pushReminders', 'Reminders'),
|
|
135
|
+
description: t('settings.notifications.pushRemindersDesc', 'Receive reminders for upcoming deadlines and events.'),
|
|
136
|
+
defaultChecked: false,
|
|
137
|
+
},
|
|
138
|
+
];
|
|
139
|
+
|
|
140
|
+
return (
|
|
141
|
+
<Stack gap="large">
|
|
142
|
+
<Card
|
|
143
|
+
title={t('settings.notifications.emailTitle', 'Email Notifications')}
|
|
144
|
+
subtitle={t('settings.notifications.emailSubtitle', 'Choose which emails you would like to receive.')}
|
|
145
|
+
icon={Mail}
|
|
146
|
+
content={
|
|
147
|
+
<Stack gap="medium">
|
|
148
|
+
{emailPreferences.map((pref) => (
|
|
149
|
+
<Stack key={pref.label} direction="row" justify="space-between" align="center" gap="medium">
|
|
150
|
+
<Stack gap="none">
|
|
151
|
+
<Text level="body" weight="medium">{pref.label}</Text>
|
|
152
|
+
<Text level="small" variant="muted">{pref.description}</Text>
|
|
153
|
+
</Stack>
|
|
154
|
+
<Switch checked={pref.defaultChecked} onCheckedChange={() => {}} />
|
|
155
|
+
</Stack>
|
|
156
|
+
))}
|
|
157
|
+
</Stack>
|
|
158
|
+
}
|
|
159
|
+
/>
|
|
160
|
+
|
|
161
|
+
<Card
|
|
162
|
+
title={t('settings.notifications.pushTitle', 'Push Notifications')}
|
|
163
|
+
subtitle={t('settings.notifications.pushSubtitle', 'Manage your mobile and desktop push notifications.')}
|
|
164
|
+
icon={Smartphone}
|
|
165
|
+
content={
|
|
166
|
+
<Stack gap="medium">
|
|
167
|
+
{pushPreferences.map((pref) => (
|
|
168
|
+
<Stack key={pref.label} direction="row" justify="space-between" align="center" gap="medium">
|
|
169
|
+
<Stack gap="none">
|
|
170
|
+
<Text level="body" weight="medium">{pref.label}</Text>
|
|
171
|
+
<Text level="small" variant="muted">{pref.description}</Text>
|
|
172
|
+
</Stack>
|
|
173
|
+
<Switch checked={pref.defaultChecked} onCheckedChange={() => {}} />
|
|
174
|
+
</Stack>
|
|
175
|
+
))}
|
|
176
|
+
</Stack>
|
|
177
|
+
}
|
|
178
|
+
/>
|
|
179
|
+
</Stack>
|
|
180
|
+
);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
function SecurityTab() {
|
|
184
|
+
const { t } = useTranslation(NAMESPACE);
|
|
185
|
+
|
|
186
|
+
return (
|
|
187
|
+
<Stack gap="large">
|
|
188
|
+
<Card
|
|
189
|
+
title={t('settings.security.passwordTitle', 'Change Password')}
|
|
190
|
+
subtitle={t('settings.security.passwordSubtitle', 'Update your password to keep your account secure.')}
|
|
191
|
+
icon={Key}
|
|
192
|
+
content={
|
|
193
|
+
<Stack gap="medium">
|
|
194
|
+
<Input
|
|
195
|
+
label={t('settings.security.currentPassword', 'Current Password')}
|
|
196
|
+
placeholder="********"
|
|
197
|
+
icon={Lock}
|
|
198
|
+
/>
|
|
199
|
+
<Input
|
|
200
|
+
label={t('settings.security.newPassword', 'New Password')}
|
|
201
|
+
placeholder="********"
|
|
202
|
+
icon={Lock}
|
|
203
|
+
/>
|
|
204
|
+
<Input
|
|
205
|
+
label={t('settings.security.confirmPassword', 'Confirm New Password')}
|
|
206
|
+
placeholder="********"
|
|
207
|
+
icon={Lock}
|
|
208
|
+
/>
|
|
209
|
+
</Stack>
|
|
210
|
+
}
|
|
211
|
+
footer={
|
|
212
|
+
<Stack direction="row" justify="end">
|
|
213
|
+
<Button variant={BUTTON_VARIANT.PRIMARY}>
|
|
214
|
+
{t('settings.security.updatePassword', 'Update Password')}
|
|
215
|
+
</Button>
|
|
216
|
+
</Stack>
|
|
217
|
+
}
|
|
218
|
+
/>
|
|
219
|
+
|
|
220
|
+
<Card
|
|
221
|
+
title={t('settings.security.twoFactorTitle', 'Two-Factor Authentication')}
|
|
222
|
+
subtitle={t('settings.security.twoFactorSubtitle', 'Add an extra layer of security to your account.')}
|
|
223
|
+
icon={ShieldCheck}
|
|
224
|
+
content={
|
|
225
|
+
<Stack gap="medium">
|
|
226
|
+
<Alert
|
|
227
|
+
variant="info"
|
|
228
|
+
title={t('settings.security.twoFactorInfo', '2FA is currently disabled')}
|
|
229
|
+
description={t('settings.security.twoFactorInfoDesc', 'Enable two-factor authentication for enhanced account security. You will need an authenticator app like Google Authenticator or Authy.')}
|
|
230
|
+
/>
|
|
231
|
+
<Stack direction="row" justify="space-between" align="center">
|
|
232
|
+
<Stack gap="none">
|
|
233
|
+
<Text level="body" weight="medium">
|
|
234
|
+
{t('settings.security.enable2FA', 'Enable 2FA')}
|
|
235
|
+
</Text>
|
|
236
|
+
<Text level="small" variant="muted">
|
|
237
|
+
{t('settings.security.enable2FADesc', 'Require a verification code on each sign-in.')}
|
|
238
|
+
</Text>
|
|
239
|
+
</Stack>
|
|
240
|
+
<Switch checked={false} onCheckedChange={() => {}} />
|
|
241
|
+
</Stack>
|
|
242
|
+
</Stack>
|
|
243
|
+
}
|
|
244
|
+
/>
|
|
245
|
+
|
|
246
|
+
<Card
|
|
247
|
+
title={t('settings.security.sessionsTitle', 'Active Sessions')}
|
|
248
|
+
subtitle={t('settings.security.sessionsSubtitle', 'Manage your active sessions across devices.')}
|
|
249
|
+
content={
|
|
250
|
+
<Stack gap="medium">
|
|
251
|
+
<Text level="small" variant="muted">
|
|
252
|
+
{t('settings.security.sessionsDesc', 'You are currently signed in on this device. If you notice any suspicious activity, sign out of all other sessions immediately.')}
|
|
253
|
+
</Text>
|
|
254
|
+
<Button variant={BUTTON_VARIANT.DESTRUCTIVE}>
|
|
255
|
+
{t('settings.security.signOutAll', 'Sign Out of All Other Sessions')}
|
|
256
|
+
</Button>
|
|
257
|
+
</Stack>
|
|
258
|
+
}
|
|
259
|
+
/>
|
|
260
|
+
</Stack>
|
|
261
|
+
);
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
export default function SettingsPage() {
|
|
265
|
+
const { t } = useTranslation(NAMESPACE);
|
|
266
|
+
|
|
267
|
+
const tabItems = [
|
|
268
|
+
{
|
|
269
|
+
value: 'profile',
|
|
270
|
+
label: t('settings.tabs.profile', 'Profile'),
|
|
271
|
+
content: <ProfileTab />,
|
|
272
|
+
},
|
|
273
|
+
{
|
|
274
|
+
value: 'notifications',
|
|
275
|
+
label: t('settings.tabs.notifications', 'Notifications'),
|
|
276
|
+
content: <NotificationsTab />,
|
|
277
|
+
},
|
|
278
|
+
{
|
|
279
|
+
value: 'security',
|
|
280
|
+
label: t('settings.tabs.security', 'Security'),
|
|
281
|
+
content: <SecurityTab />,
|
|
282
|
+
},
|
|
283
|
+
];
|
|
284
|
+
|
|
285
|
+
return (
|
|
286
|
+
<PageContainer variant="standard">
|
|
287
|
+
<Section title={t('settings.title', 'Settings')}>
|
|
288
|
+
<Tabs items={tabItems} defaultValue="profile" />
|
|
289
|
+
</Section>
|
|
290
|
+
</PageContainer>
|
|
291
|
+
);
|
|
292
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# .claude/hooks/framework-compliance.sh
|
|
3
|
+
# PostToolUse: after Edit/Write, check for framework violations.
|
|
4
|
+
# Catches native HTML, Tailwind, CSS imports in source files.
|
|
5
|
+
|
|
6
|
+
set -euo pipefail
|
|
7
|
+
|
|
8
|
+
INPUT=$(cat)
|
|
9
|
+
FILE_PATH=$(echo "$INPUT" | bun -e "
|
|
10
|
+
const input = JSON.parse(await Bun.stdin.text());
|
|
11
|
+
process.stdout.write(
|
|
12
|
+
input.tool_response?.filePath
|
|
13
|
+
?? input.tool_input?.file_path
|
|
14
|
+
?? ''
|
|
15
|
+
);
|
|
16
|
+
")
|
|
17
|
+
|
|
18
|
+
[ -z "$FILE_PATH" ] && exit 0
|
|
19
|
+
|
|
20
|
+
# Only check component files (tsx/jsx)
|
|
21
|
+
case "$FILE_PATH" in
|
|
22
|
+
*.tsx|*.jsx) ;;
|
|
23
|
+
*) exit 0 ;;
|
|
24
|
+
esac
|
|
25
|
+
|
|
26
|
+
# Skip non-component files
|
|
27
|
+
case "$FILE_PATH" in
|
|
28
|
+
*Store.ts|*store.ts|*.store.ts) exit 0 ;;
|
|
29
|
+
*Hook.ts|*hook.ts|*.hook.ts) exit 0 ;;
|
|
30
|
+
*/utils/*|*/hooks/*|*/stores/*|*/types/*|*/locales/*) exit 0 ;;
|
|
31
|
+
esac
|
|
32
|
+
|
|
33
|
+
VIOLATIONS=""
|
|
34
|
+
|
|
35
|
+
# Native HTML elements
|
|
36
|
+
if grep -nE '<(div|span|p|h[1-6]|button|a|input|textarea|select|table|tr|td|th|ul|ol|li|form|label|img|section|header|footer|nav|main|aside|article)[\s>/]' "$FILE_PATH" 2>/dev/null; then
|
|
37
|
+
VIOLATIONS="${VIOLATIONS}Native HTML elements found. Use framework components (Stack, Card, Text, Button, Link, TextInput, DataTable, etc.).\n"
|
|
38
|
+
fi
|
|
39
|
+
|
|
40
|
+
# Tailwind utility classes
|
|
41
|
+
if grep -nE 'className="[^"]*\b(bg-[a-z]|text-[a-z]|p-[0-9]|m-[0-9]|px-|py-|mx-|my-|\bflex\b|\bgrid\b|w-[0-9]|h-[0-9]|gap-|rounded-|border-|shadow-|overflow-)' "$FILE_PATH" 2>/dev/null; then
|
|
42
|
+
VIOLATIONS="${VIOLATIONS}Tailwind utility classes found. Use component props + theme tokens.\n"
|
|
43
|
+
fi
|
|
44
|
+
|
|
45
|
+
# CSS imports
|
|
46
|
+
if grep -nE "import.*\.(css|scss|less|module\.css)['\"]" "$FILE_PATH" 2>/dev/null; then
|
|
47
|
+
VIOLATIONS="${VIOLATIONS}CSS import found. No custom CSS - use component props + theme tokens.\n"
|
|
48
|
+
fi
|
|
49
|
+
|
|
50
|
+
if [ -n "$VIOLATIONS" ]; then
|
|
51
|
+
echo -e "FRAMEWORK VIOLATIONS in $FILE_PATH:\n$VIOLATIONS" >&2
|
|
52
|
+
echo "{\"hookSpecificOutput\":{\"hookEventName\":\"PostToolUse\",\"additionalContext\":\"FRAMEWORK VIOLATION in $FILE_PATH. Fix before proceeding: ${VIOLATIONS}\"}}"
|
|
53
|
+
exit 0
|
|
54
|
+
fi
|
|
55
|
+
|
|
56
|
+
exit 0
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# .claude/hooks/guard-bash.sh
|
|
3
|
+
# PreToolUse hook for Bash commands.
|
|
4
|
+
# Blocks dangerous/wrong commands. Exit 2 = block, exit 0 = allow.
|
|
5
|
+
# Uses bun -e for JSON parsing (bun-first project).
|
|
6
|
+
|
|
7
|
+
set -euo pipefail
|
|
8
|
+
|
|
9
|
+
INPUT=$(cat)
|
|
10
|
+
COMMAND=$(echo "$INPUT" | bun -e "process.stdout.write(JSON.parse(await Bun.stdin.text()).tool_input?.command ?? '')")
|
|
11
|
+
[ -z "$COMMAND" ] && exit 0
|
|
12
|
+
|
|
13
|
+
# --- HARD BLOCKS (exit 2) ---
|
|
14
|
+
|
|
15
|
+
# Block raw TypeScript compiler (must use dndev tc)
|
|
16
|
+
if echo "$COMMAND" | grep -qE '(^|\s|;|&&|\|)(bunx|npx|pnpx)\s+tsc(\s|$)'; then
|
|
17
|
+
echo "BLOCKED: Use 'dndev tc' for type-checking, never bunx/npx tsc." >&2
|
|
18
|
+
exit 2
|
|
19
|
+
fi
|
|
20
|
+
if echo "$COMMAND" | grep -qE '(^|\s|;|&&|\|)tsc(\s|$)'; then
|
|
21
|
+
echo "BLOCKED: Use 'dndev tc' for type-checking, never raw tsc." >&2
|
|
22
|
+
exit 2
|
|
23
|
+
fi
|
|
24
|
+
|
|
25
|
+
# Block full reinstall (deps are managed by the workspace)
|
|
26
|
+
# bun add IS allowed — consumer projects may need additional packages
|
|
27
|
+
if echo "$COMMAND" | grep -qE '(^|\s|;|&&|\|)(bun|npm|yarn|pnpm)\s+install(\s|$)'; then
|
|
28
|
+
echo "BLOCKED: Use 'bun add <pkg>' to add specific packages. Full reinstall is not needed." >&2
|
|
29
|
+
exit 2
|
|
30
|
+
fi
|
|
31
|
+
|
|
32
|
+
# Block force push
|
|
33
|
+
if echo "$COMMAND" | grep -qE 'git\s+push\s.*(-f|--force)'; then
|
|
34
|
+
echo "BLOCKED: Force push is forbidden. Push normally or resolve conflicts." >&2
|
|
35
|
+
exit 2
|
|
36
|
+
fi
|
|
37
|
+
|
|
38
|
+
# Block destructive git operations
|
|
39
|
+
if echo "$COMMAND" | grep -qE 'git\s+reset\s+--hard'; then
|
|
40
|
+
echo "BLOCKED: git reset --hard destroys work. Use git stash or git checkout <file> instead." >&2
|
|
41
|
+
exit 2
|
|
42
|
+
fi
|
|
43
|
+
if echo "$COMMAND" | grep -qE 'git\s+clean\s+-f'; then
|
|
44
|
+
echo "BLOCKED: git clean -f destroys untracked files. Review them manually first." >&2
|
|
45
|
+
exit 2
|
|
46
|
+
fi
|
|
47
|
+
|
|
48
|
+
# Block rm -rf on project-critical paths
|
|
49
|
+
if echo "$COMMAND" | grep -qE 'rm\s+-rf\s+(/|\.|\*|src|apps|packages|node_modules)'; then
|
|
50
|
+
echo "BLOCKED: Destructive rm -rf on critical path. Be specific about what to remove." >&2
|
|
51
|
+
exit 2
|
|
52
|
+
fi
|
|
53
|
+
|
|
54
|
+
# Block skip hooks
|
|
55
|
+
if echo "$COMMAND" | grep -qE '--no-verify'; then
|
|
56
|
+
echo "BLOCKED: --no-verify skips safety hooks. Fix the root cause instead." >&2
|
|
57
|
+
exit 2
|
|
58
|
+
fi
|
|
59
|
+
|
|
60
|
+
# --- ALLOW ---
|
|
61
|
+
exit 0
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# .claude/hooks/guard-files.sh
|
|
3
|
+
# PreToolUse hook for Edit and Write operations.
|
|
4
|
+
# Blocks edits to protected files. Exit 2 = block, exit 0 = allow.
|
|
5
|
+
# Uses bun -e for JSON parsing (bun-first project).
|
|
6
|
+
|
|
7
|
+
set -euo pipefail
|
|
8
|
+
|
|
9
|
+
INPUT=$(cat)
|
|
10
|
+
FILE_PATH=$(echo "$INPUT" | bun -e "process.stdout.write(JSON.parse(await Bun.stdin.text()).tool_input?.file_path ?? '')")
|
|
11
|
+
|
|
12
|
+
# No file path = nothing to guard
|
|
13
|
+
[ -z "$FILE_PATH" ] && exit 0
|
|
14
|
+
|
|
15
|
+
BASENAME=$(basename "$FILE_PATH")
|
|
16
|
+
|
|
17
|
+
# Lock files - never edit directly
|
|
18
|
+
case "$BASENAME" in
|
|
19
|
+
bun.lock|bun.lockb|package-lock.json|yarn.lock|pnpm-lock.yaml)
|
|
20
|
+
echo "BLOCKED: Lock files are auto-generated. Do not edit directly." >&2
|
|
21
|
+
exit 2
|
|
22
|
+
;;
|
|
23
|
+
esac
|
|
24
|
+
|
|
25
|
+
# Environment files - secrets, never edit via agent
|
|
26
|
+
case "$BASENAME" in
|
|
27
|
+
.env|.env.local|.env.production|.dndev.secrets)
|
|
28
|
+
echo "BLOCKED: Environment files may contain secrets. Edit manually or use dndev sync-secrets." >&2
|
|
29
|
+
exit 2
|
|
30
|
+
;;
|
|
31
|
+
esac
|
|
32
|
+
|
|
33
|
+
# Generated files
|
|
34
|
+
if echo "$FILE_PATH" | grep -qE '\.(generated|g)\.(ts|js|json)$'; then
|
|
35
|
+
echo "BLOCKED: Generated files should not be edited manually. Regenerate from source." >&2
|
|
36
|
+
exit 2
|
|
37
|
+
fi
|
|
38
|
+
|
|
39
|
+
# AI.md - the SSOT, should not be casually edited by agents
|
|
40
|
+
if [ "$BASENAME" = "AI.md" ]; then
|
|
41
|
+
echo "BLOCKED: AI.md is the agent instruction SSOT. Do not modify it." >&2
|
|
42
|
+
exit 2
|
|
43
|
+
fi
|
|
44
|
+
|
|
45
|
+
# --- ALLOW ---
|
|
46
|
+
exit 0
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# .claude/hooks/guard-mcp.sh
|
|
3
|
+
# PreToolUse: enforce lookup_symbol() before @donotdev imports.
|
|
4
|
+
# Reads lookup history from track-mcp-lookup.sh (PostToolUse marker file).
|
|
5
|
+
# Creates GitHub issue when custom component is needed.
|
|
6
|
+
# Cross-platform: bun-first, no grep -P, TMPDIR-safe.
|
|
7
|
+
|
|
8
|
+
set -euo pipefail
|
|
9
|
+
|
|
10
|
+
GATE_DIR="${TMPDIR:-/tmp}"
|
|
11
|
+
TRACK_FILE="$GATE_DIR/claude-mcp-lookups.txt"
|
|
12
|
+
|
|
13
|
+
INPUT=$(cat)
|
|
14
|
+
|
|
15
|
+
PARSED=$(echo "$INPUT" | bun -e "
|
|
16
|
+
const d = JSON.parse(await Bun.stdin.text());
|
|
17
|
+
const tn = d.tool_name ?? '';
|
|
18
|
+
const fp = d.tool_input?.file_path ?? '';
|
|
19
|
+
let content = '';
|
|
20
|
+
if (tn === 'Edit') content = d.tool_input?.new_string ?? '';
|
|
21
|
+
else if (tn === 'Write') content = d.tool_input?.content ?? '';
|
|
22
|
+
process.stdout.write([tn, fp, content].join('\n'));
|
|
23
|
+
")
|
|
24
|
+
|
|
25
|
+
TOOL_NAME=$(echo "$PARSED" | sed -n '1p')
|
|
26
|
+
FILE_PATH=$(echo "$PARSED" | sed -n '2p')
|
|
27
|
+
CONTENT=$(echo "$PARSED" | tail -n +3)
|
|
28
|
+
|
|
29
|
+
case "$TOOL_NAME" in
|
|
30
|
+
Edit|Write) ;;
|
|
31
|
+
*) exit 0 ;;
|
|
32
|
+
esac
|
|
33
|
+
|
|
34
|
+
# Only check app source files
|
|
35
|
+
if ! echo "$FILE_PATH" | grep -qE '(apps|src)/.*\.(tsx?|jsx?)$'; then
|
|
36
|
+
exit 0
|
|
37
|
+
fi
|
|
38
|
+
|
|
39
|
+
# Check if content has @donotdev imports
|
|
40
|
+
if ! echo "$CONTENT" | grep -qE "from ['\"]@donotdev/"; then
|
|
41
|
+
exit 0
|
|
42
|
+
fi
|
|
43
|
+
|
|
44
|
+
# Extract symbols and check against tracking file — single bun call
|
|
45
|
+
RESULT=$(echo "$CONTENT" | bun -e "
|
|
46
|
+
const content = await Bun.stdin.text();
|
|
47
|
+
const importRe = /import\s*\{([^}]+)\}\s*from\s*['\"]@donotdev\//g;
|
|
48
|
+
const symbols = new Set();
|
|
49
|
+
for (const m of content.matchAll(importRe)) {
|
|
50
|
+
for (const sym of m[1].split(',')) {
|
|
51
|
+
const name = sym.replace(/\s+as\s+\w+/, '').trim();
|
|
52
|
+
if (/^[A-Z]/.test(name)) symbols.add(name);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
if (symbols.size === 0) { process.stdout.write('OK'); process.exit(); }
|
|
56
|
+
|
|
57
|
+
let lookups = new Set();
|
|
58
|
+
try {
|
|
59
|
+
const text = await Bun.file('$TRACK_FILE').text();
|
|
60
|
+
for (const line of text.split('\n')) {
|
|
61
|
+
const trimmed = line.trim();
|
|
62
|
+
if (trimmed) lookups.add(trimmed);
|
|
63
|
+
}
|
|
64
|
+
} catch {}
|
|
65
|
+
|
|
66
|
+
const missing = [...symbols].filter(s => !lookups.has(s));
|
|
67
|
+
process.stdout.write(missing.length ? 'MISSING:' + missing.join(',') : 'OK');
|
|
68
|
+
")
|
|
69
|
+
|
|
70
|
+
if [ "${RESULT#MISSING:}" != "$RESULT" ]; then
|
|
71
|
+
MISSING="${RESULT#MISSING:}"
|
|
72
|
+
echo "BLOCKED: @donotdev imports without lookup_symbol() verification: ${MISSING//,/, }" >&2
|
|
73
|
+
echo "Call lookup_symbol({ symbol: \"Name\" }) for each component before importing." >&2
|
|
74
|
+
exit 2
|
|
75
|
+
fi
|
|
76
|
+
|
|
77
|
+
# --- CUSTOM COMPONENT DETECTION ---
|
|
78
|
+
if echo "$FILE_PATH" | grep -qE 'src/components/' && echo "$CONTENT" | grep -q '@custom-component'; then
|
|
79
|
+
COMPONENT_NAME=$(basename "$FILE_PATH" | sed 's/\.\(tsx\|ts\|jsx\|js\)$//')
|
|
80
|
+
if command -v gh &>/dev/null && git remote get-url origin &>/dev/null 2>&1; then
|
|
81
|
+
EXISTING=$(gh issue list --label "framework-evolution" --search "$COMPONENT_NAME" --json number --jq '.[0].number' 2>/dev/null || true)
|
|
82
|
+
if [ -z "$EXISTING" ]; then
|
|
83
|
+
gh issue create \
|
|
84
|
+
--title "Framework gap: $COMPONENT_NAME" \
|
|
85
|
+
--body "Custom component \`$COMPONENT_NAME\` at \`$FILE_PATH\`. Auto-created by guard hook." \
|
|
86
|
+
--label "framework-evolution" 2>/dev/null || true
|
|
87
|
+
fi
|
|
88
|
+
fi
|
|
89
|
+
fi
|
|
90
|
+
|
|
91
|
+
exit 0
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# .claude/hooks/guard-secrets.sh
|
|
3
|
+
# PreToolUse hook for Edit and Write operations.
|
|
4
|
+
# Scans content for accidentally leaked secrets. Exit 2 = block, exit 0 = allow.
|
|
5
|
+
|
|
6
|
+
set -euo pipefail
|
|
7
|
+
|
|
8
|
+
INPUT=$(cat)
|
|
9
|
+
|
|
10
|
+
# Extract content being written (one bun call)
|
|
11
|
+
CONTENT=$(echo "$INPUT" | bun -e "
|
|
12
|
+
const d = JSON.parse(await Bun.stdin.text());
|
|
13
|
+
const tn = d.tool_name ?? '';
|
|
14
|
+
let c = '';
|
|
15
|
+
if (tn === 'Edit') c = d.tool_input?.new_string ?? '';
|
|
16
|
+
else if (tn === 'Write') c = d.tool_input?.content ?? '';
|
|
17
|
+
process.stdout.write(c);
|
|
18
|
+
")
|
|
19
|
+
|
|
20
|
+
[ -z "$CONTENT" ] && exit 0
|
|
21
|
+
|
|
22
|
+
# Skip hook/script files (they contain detection patterns, not actual secrets)
|
|
23
|
+
FILE_PATH_EARLY=$(echo "$INPUT" | bun -e "process.stdout.write(JSON.parse(await Bun.stdin.text()).tool_input?.file_path ?? '')")
|
|
24
|
+
case "$FILE_PATH_EARLY" in
|
|
25
|
+
*.sh|*.sh.example|*guard-secrets*) exit 0 ;;
|
|
26
|
+
esac
|
|
27
|
+
|
|
28
|
+
VIOLATIONS=""
|
|
29
|
+
|
|
30
|
+
# AWS Access Key
|
|
31
|
+
if echo "$CONTENT" | grep -qE '(AKIA|ASIA)[A-Z0-9]{16}'; then
|
|
32
|
+
VIOLATIONS="${VIOLATIONS}AWS access key detected.\n"
|
|
33
|
+
fi
|
|
34
|
+
|
|
35
|
+
# GitHub token
|
|
36
|
+
if echo "$CONTENT" | grep -qE 'gh[pousr]_[A-Za-z0-9_]{36,}'; then
|
|
37
|
+
VIOLATIONS="${VIOLATIONS}GitHub token detected.\n"
|
|
38
|
+
fi
|
|
39
|
+
|
|
40
|
+
# Private key block
|
|
41
|
+
if echo "$CONTENT" | grep -q -- '-----BEGIN.*PRIVATE KEY-----'; then
|
|
42
|
+
VIOLATIONS="${VIOLATIONS}Private key detected.\n"
|
|
43
|
+
fi
|
|
44
|
+
|
|
45
|
+
# Generic secret assignment (password/secret/api_key/token = "long_value")
|
|
46
|
+
if echo "$CONTENT" | grep -qEi '(password|secret|api[_-]?key|token|credential)\s*[:=]\s*["'"'"'][A-Za-z0-9+/=_-]{20,}'; then
|
|
47
|
+
# Skip if it's a placeholder/example pattern
|
|
48
|
+
if ! echo "$CONTENT" | grep -qEi '(password|secret|api[_-]?key|token|credential)\s*[:=]\s*["'"'"'](your-|example-|replace-|xxx|process\.env)'; then
|
|
49
|
+
VIOLATIONS="${VIOLATIONS}Possible secret assignment detected.\n"
|
|
50
|
+
fi
|
|
51
|
+
fi
|
|
52
|
+
|
|
53
|
+
# JWT (3 dot-separated base64url segments) — skip test/mock files
|
|
54
|
+
if echo "$CONTENT" | grep -qE 'eyJ[A-Za-z0-9_-]{10,}\.eyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}'; then
|
|
55
|
+
FILE_PATH=$(echo "$INPUT" | bun -e "process.stdout.write(JSON.parse(await Bun.stdin.text()).tool_input?.file_path ?? '')")
|
|
56
|
+
case "$FILE_PATH" in
|
|
57
|
+
*test*|*fixture*|*mock*|*.d.ts) ;;
|
|
58
|
+
*) VIOLATIONS="${VIOLATIONS}JWT/service-role key detected.\n" ;;
|
|
59
|
+
esac
|
|
60
|
+
fi
|
|
61
|
+
|
|
62
|
+
if [ -n "$VIOLATIONS" ]; then
|
|
63
|
+
echo -e "BLOCKED: Secret detected in file content:\n${VIOLATIONS}Move secrets to .env and reference via process.env." >&2
|
|
64
|
+
exit 2
|
|
65
|
+
fi
|
|
66
|
+
|
|
67
|
+
exit 0
|