@donotdev/cli 0.1.0 → 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/dependencies-matrix.json +100 -50
- package/dist/bin/commands/agent-setup.js +245 -12
- package/dist/bin/commands/build.js +3339 -208
- package/dist/bin/commands/bump.js +245 -12
- package/dist/bin/commands/cacheout.js +245 -12
- package/dist/bin/commands/coach.js +361 -60
- package/dist/bin/commands/create-app.js +245 -12
- package/dist/bin/commands/create-project.js +253 -12
- package/dist/bin/commands/db.js +9114 -2327
- package/dist/bin/commands/deploy.js +4074 -694
- package/dist/bin/commands/dev.js +347 -33
- package/dist/bin/commands/doctor.js +408 -107
- package/dist/bin/commands/emu.js +386 -52
- package/dist/bin/commands/format.js +245 -12
- package/dist/bin/commands/get-demo.js +245 -12
- package/dist/bin/commands/make-admin.js +8356 -1516
- package/dist/bin/commands/preview.js +347 -33
- package/dist/bin/commands/seed.js +9114 -2327
- package/dist/bin/commands/setup-cicd.js +452 -132
- package/dist/bin/commands/setup.js +407 -107
- package/dist/bin/commands/staging.js +4074 -694
- package/dist/bin/commands/sync-secrets.js +246 -13
- package/dist/bin/commands/type-check.js +245 -12
- package/dist/bin/commands/wai.js +245 -12
- package/dist/bin/dndev.js +13 -4
- package/dist/bin/donotdev.js +13 -4
- package/dist/index.js +4169 -812
- package/{templates/root-consumer/guides/dndev/advanced/VERSION_CONTROL.md.example → guidelines/VERSION_CONTROL.md} +7 -11
- package/package.json +2 -1
- 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/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/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/build/SKILL.md.example +103 -25
- package/templates/root-consumer/.claude/skills/grill/SKILL.md.example +26 -15
- 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 +10 -5
- 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 -175
- package/templates/root-consumer/.claude/commands/build.md.example +0 -131
- package/templates/root-consumer/.claude/commands/design.md.example +0 -184
- package/templates/root-consumer/.claude/commands/grill.md.example +0 -135
- 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
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
# Version Control
|
|
1
|
+
# Version Control
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
How to upgrade DoNotDev framework packages in consumer projects.
|
|
4
4
|
|
|
5
5
|
---
|
|
6
6
|
|
|
@@ -26,22 +26,22 @@ dndev bump --dry-run
|
|
|
26
26
|
**Patch versions (0.0.x):**
|
|
27
27
|
- Handled automatically by `bun install`
|
|
28
28
|
- No action needed - `^` ranges allow automatic patch updates
|
|
29
|
-
- Example: `^0.0.2`
|
|
29
|
+
- Example: `^0.0.2` - `0.0.3`, `0.0.4`, etc.
|
|
30
30
|
|
|
31
31
|
**Minor versions (0.x.y):**
|
|
32
32
|
- Handled automatically by `dndev bump`
|
|
33
33
|
- **RISK FREE:** All changes are backward compatible via deprecation
|
|
34
34
|
- No breaking changes in 0.x.y range
|
|
35
|
-
- Example: `^0.0.2`
|
|
35
|
+
- Example: `^0.0.2` - `^0.1.0` (auto-updated, safe)
|
|
36
36
|
|
|
37
37
|
### Manual Validation Required
|
|
38
38
|
|
|
39
|
-
**Major versions (0.*.*
|
|
39
|
+
**Major versions (0.*.* - 1.x.y):**
|
|
40
40
|
- `dndev bump` detects major version changes
|
|
41
41
|
- Shows migration guide with breaking changes
|
|
42
42
|
- **You must validate manually** before updating
|
|
43
43
|
- **Only place where breaking changes occur**
|
|
44
|
-
- Example: `^0.1.0`
|
|
44
|
+
- Example: `^0.1.0` - `^1.0.0` (requires validation)
|
|
45
45
|
|
|
46
46
|
---
|
|
47
47
|
|
|
@@ -126,7 +126,7 @@ When upgrading major versions, migration guides are provided:
|
|
|
126
126
|
|
|
127
127
|
**Example:**
|
|
128
128
|
```
|
|
129
|
-
|
|
129
|
+
Warning: Major version update detected: @donotdev/core 0.1.0 - 1.0.0
|
|
130
130
|
|
|
131
131
|
Migration guide: docs/migration/v0.1-to-v1.0.md
|
|
132
132
|
|
|
@@ -168,7 +168,3 @@ Review the migration guide before updating.
|
|
|
168
168
|
3. **Review major changes:** Always read migration guides for major versions
|
|
169
169
|
4. **Use `--dry-run`:** Preview changes before applying
|
|
170
170
|
5. **Commit changes:** Commit updated `package.json` files after successful updates
|
|
171
|
-
|
|
172
|
-
---
|
|
173
|
-
|
|
174
|
-
**Keep your dependencies up to date. Stay secure. Stay compatible.**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@donotdev/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Command-line interface for DoNotDev Framework",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"private": false,
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
"files": [
|
|
20
20
|
"dist",
|
|
21
21
|
"templates",
|
|
22
|
+
"guidelines",
|
|
22
23
|
"dependencies-matrix.json",
|
|
23
24
|
"README.md",
|
|
24
25
|
"LICENSE.md"
|
|
@@ -332,3 +332,24 @@
|
|
|
332
332
|
background: transparent;
|
|
333
333
|
box-shadow: none;
|
|
334
334
|
}
|
|
335
|
+
|
|
336
|
+
/* ===========================
|
|
337
|
+
INTERACTION EFFECTS
|
|
338
|
+
Micro-interactions for buttons. Set to 0/1 to disable.
|
|
339
|
+
=========================== */
|
|
340
|
+
/*
|
|
341
|
+
:root {
|
|
342
|
+
--hover-lift: -2px;
|
|
343
|
+
--click-scale: 0.97;
|
|
344
|
+
--ripple-opacity: 0.2;
|
|
345
|
+
}
|
|
346
|
+
*/
|
|
347
|
+
|
|
348
|
+
/* Disable all effects (flat/minimal style) */
|
|
349
|
+
/*
|
|
350
|
+
:root {
|
|
351
|
+
--hover-lift: 0;
|
|
352
|
+
--click-scale: 1;
|
|
353
|
+
--ripple-opacity: 0;
|
|
354
|
+
}
|
|
355
|
+
*/
|
|
@@ -13,9 +13,6 @@
|
|
|
13
13
|
<!-- ✅ DnDev: Asset manifest injection point -->
|
|
14
14
|
<!-- window.__DNDEV_ASSETS__ and __DNDEV_ASSET_MANIFEST__ injected here -->
|
|
15
15
|
|
|
16
|
-
<!-- ✅ PWA: Manifest link (if exists) -->
|
|
17
|
-
<link rel="manifest" href="/manifest.json" />
|
|
18
|
-
|
|
19
16
|
<!-- Fonts: Inter, Space Grotesk, Playfair, Roboto loaded via @donotdev/ui/dndev.css (bundled). -->
|
|
20
17
|
<!-- DNDEV_FONT_PRELOADS -->
|
|
21
18
|
|
|
@@ -156,6 +156,27 @@
|
|
|
156
156
|
--radius-floating: 0.5rem;
|
|
157
157
|
}
|
|
158
158
|
|
|
159
|
+
/* ===========================
|
|
160
|
+
INTERACTION EFFECTS
|
|
161
|
+
Micro-interactions for buttons. Set to 0/1 to disable.
|
|
162
|
+
=========================== */
|
|
163
|
+
/*
|
|
164
|
+
:root {
|
|
165
|
+
--hover-lift: -2px;
|
|
166
|
+
--click-scale: 0.97;
|
|
167
|
+
--ripple-opacity: 0.2;
|
|
168
|
+
}
|
|
169
|
+
*/
|
|
170
|
+
|
|
171
|
+
/* Disable all effects (flat/minimal style) */
|
|
172
|
+
/*
|
|
173
|
+
:root {
|
|
174
|
+
--hover-lift: 0;
|
|
175
|
+
--click-scale: 1;
|
|
176
|
+
--ripple-opacity: 0;
|
|
177
|
+
}
|
|
178
|
+
*/
|
|
179
|
+
|
|
159
180
|
/* ===========================
|
|
160
181
|
CUSTOM THEMES
|
|
161
182
|
Add your brand themes below (same pattern: class + --theme-label, --theme-icon, --theme-is-dark).
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Metadata } from 'next';
|
|
2
2
|
|
|
3
|
+
import { getMetadataForPath } from '@donotdev/core/next';
|
|
3
4
|
import { FontPreloadLinks } from '@donotdev/ui/next';
|
|
4
5
|
|
|
5
6
|
import '../globals.css';
|
|
@@ -10,10 +11,18 @@ import { ClientLayout } from './ClientLayout';
|
|
|
10
11
|
* Font preload links are injected at build time; FontPreloadLinks reads the manifest for SSR.
|
|
11
12
|
*/
|
|
12
13
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
/**
|
|
15
|
+
* Dynamic metadata generation from PageMeta exports.
|
|
16
|
+
* Same PageMeta convention works in Vite (AutoMetaTags) and Next.js (this function).
|
|
17
|
+
* Priority: i18n meta.fullTitle > seo.fullTitle > i18n title | siteName > siteName
|
|
18
|
+
*
|
|
19
|
+
* For dynamic pages with runtime data, use <Seo> component instead.
|
|
20
|
+
*/
|
|
21
|
+
export async function generateMetadata(): Promise<Metadata> {
|
|
22
|
+
// Root layout handles the home page metadata
|
|
23
|
+
// Other pages override via their own generateMetadata or <Seo> component
|
|
24
|
+
return getMetadataForPath('/');
|
|
25
|
+
}
|
|
17
26
|
|
|
18
27
|
/**
|
|
19
28
|
* Root layout for Next.js App Router
|
|
@@ -125,6 +125,27 @@
|
|
|
125
125
|
See guides/dndev/essences_reference.css for full .brutalist and .luxury blocks.
|
|
126
126
|
=========================== */
|
|
127
127
|
|
|
128
|
+
/* ===========================
|
|
129
|
+
INTERACTION EFFECTS
|
|
130
|
+
Micro-interactions for buttons. Set to 0/1 to disable.
|
|
131
|
+
=========================== */
|
|
132
|
+
/*
|
|
133
|
+
:root {
|
|
134
|
+
--hover-lift: -2px;
|
|
135
|
+
--click-scale: 0.97;
|
|
136
|
+
--ripple-opacity: 0.2;
|
|
137
|
+
}
|
|
138
|
+
*/
|
|
139
|
+
|
|
140
|
+
/* Disable all effects (flat/minimal style) */
|
|
141
|
+
/*
|
|
142
|
+
:root {
|
|
143
|
+
--hover-lift: 0;
|
|
144
|
+
--click-scale: 1;
|
|
145
|
+
--ripple-opacity: 0;
|
|
146
|
+
}
|
|
147
|
+
*/
|
|
148
|
+
|
|
128
149
|
/* ===========================
|
|
129
150
|
CUSTOM THEMES
|
|
130
151
|
=========================== */
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"_comment": "Content Security Policy baseline for DoNotDev apps. Copy the relevant directives into your hosting config (vercel.json headers, netlify _headers, etc.).",
|
|
3
|
+
|
|
4
|
+
"default-src": "'self'",
|
|
5
|
+
"script-src": "'self'",
|
|
6
|
+
"style-src": "'self' 'unsafe-inline'",
|
|
7
|
+
"img-src": "'self' data: blob: https:",
|
|
8
|
+
"font-src": "'self' https://fonts.gstatic.com",
|
|
9
|
+
"object-src": "'none'",
|
|
10
|
+
"base-uri": "'self'",
|
|
11
|
+
"form-action": "'self'",
|
|
12
|
+
|
|
13
|
+
"_supabase": {
|
|
14
|
+
"_comment": "Add these if your app uses Supabase",
|
|
15
|
+
"connect-src": "'self' https://*.supabase.co wss://*.supabase.co",
|
|
16
|
+
"frame-src": "https://*.supabase.co"
|
|
17
|
+
},
|
|
18
|
+
|
|
19
|
+
"_firebase": {
|
|
20
|
+
"_comment": "Add these if your app uses Firebase",
|
|
21
|
+
"connect-src": "'self' https://*.firebaseio.com https://*.googleapis.com wss://*.firebaseio.com",
|
|
22
|
+
"frame-src": "https://*.firebaseapp.com"
|
|
23
|
+
},
|
|
24
|
+
|
|
25
|
+
"_google_maps": {
|
|
26
|
+
"_comment": "Add these if your app uses Google Maps (AddressField)",
|
|
27
|
+
"script-src": "'self' https://maps.googleapis.com",
|
|
28
|
+
"connect-src": "'self' https://maps.googleapis.com",
|
|
29
|
+
"img-src": "'self' data: blob: https: https://*.googleapis.com https://*.gstatic.com"
|
|
30
|
+
},
|
|
31
|
+
|
|
32
|
+
"_google_oauth": {
|
|
33
|
+
"_comment": "Add these if your app uses Google OAuth",
|
|
34
|
+
"connect-src": "'self' https://accounts.google.com https://oauth2.googleapis.com https://www.googleapis.com",
|
|
35
|
+
"frame-src": "https://accounts.google.com"
|
|
36
|
+
},
|
|
37
|
+
|
|
38
|
+
"_rules": [
|
|
39
|
+
"NEVER mix 'none' with URLs in the same directive (e.g., frame-src 'none' https://... is invalid)",
|
|
40
|
+
"NEVER use 'unsafe-eval' — Vite HMR works without it in dev, production never needs it",
|
|
41
|
+
"Merge connect-src values from all providers you use into a single directive",
|
|
42
|
+
"credentials: 'omit' is set by the framework on cross-origin fetches — CSP does not need to allow cookies for these"
|
|
43
|
+
]
|
|
44
|
+
}
|
|
@@ -13,9 +13,6 @@
|
|
|
13
13
|
<!-- ✅ DnDev: Asset manifest injection point -->
|
|
14
14
|
<!-- window.__DNDEV_ASSETS__ and __DNDEV_ASSET_MANIFEST__ injected here -->
|
|
15
15
|
|
|
16
|
-
<!-- ✅ PWA: Manifest link (if exists) -->
|
|
17
|
-
<link rel="manifest" href="/manifest.json" />
|
|
18
|
-
|
|
19
16
|
<!-- Fonts: Inter, Space Grotesk, Playfair, Roboto loaded via @donotdev/ui/dndev.css (bundled). -->
|
|
20
17
|
<!-- DNDEV_FONT_PRELOADS -->
|
|
21
18
|
|
|
@@ -156,6 +156,27 @@
|
|
|
156
156
|
--radius-floating: 0.5rem;
|
|
157
157
|
}
|
|
158
158
|
|
|
159
|
+
/* ===========================
|
|
160
|
+
INTERACTION EFFECTS
|
|
161
|
+
Micro-interactions for buttons. Set to 0/1 to disable.
|
|
162
|
+
=========================== */
|
|
163
|
+
/*
|
|
164
|
+
:root {
|
|
165
|
+
--hover-lift: -2px;
|
|
166
|
+
--click-scale: 0.97;
|
|
167
|
+
--ripple-opacity: 0.2;
|
|
168
|
+
}
|
|
169
|
+
*/
|
|
170
|
+
|
|
171
|
+
/* Disable all effects (flat/minimal style) */
|
|
172
|
+
/*
|
|
173
|
+
:root {
|
|
174
|
+
--hover-lift: 0;
|
|
175
|
+
--click-scale: 1;
|
|
176
|
+
--ripple-opacity: 0;
|
|
177
|
+
}
|
|
178
|
+
*/
|
|
179
|
+
|
|
159
180
|
/* ===========================
|
|
160
181
|
CUSTOM THEMES
|
|
161
182
|
Add your brand themes below (same pattern: class + --theme-label, --theme-icon, --theme-is-dark).
|
|
@@ -13,6 +13,9 @@ CREATE TABLE IF NOT EXISTS idempotency (
|
|
|
13
13
|
expires_at TIMESTAMPTZ NOT NULL -- TTL for cleanup (default: 24h)
|
|
14
14
|
);
|
|
15
15
|
|
|
16
|
+
-- Only service_role accesses this table; lock out anon/authenticated keys
|
|
17
|
+
ALTER TABLE idempotency ENABLE ROW LEVEL SECURITY;
|
|
18
|
+
|
|
16
19
|
-- Indexes for efficient lookups
|
|
17
20
|
CREATE INDEX IF NOT EXISTS idx_idempotency_expires ON idempotency(expires_at);
|
|
18
21
|
CREATE INDEX IF NOT EXISTS idx_idempotency_key ON idempotency(idempotency_key);
|
|
@@ -11,6 +11,9 @@ CREATE TABLE IF NOT EXISTS rate_limits (
|
|
|
11
11
|
last_updated TIMESTAMPTZ NOT NULL DEFAULT now()
|
|
12
12
|
);
|
|
13
13
|
|
|
14
|
+
-- Only service_role accesses this table; lock out anon/authenticated keys
|
|
15
|
+
ALTER TABLE rate_limits ENABLE ROW LEVEL SECURITY;
|
|
16
|
+
|
|
14
17
|
-- Indexes for efficient lookups and cleanup
|
|
15
18
|
CREATE INDEX IF NOT EXISTS idx_rate_limits_window ON rate_limits(window_start);
|
|
16
19
|
CREATE INDEX IF NOT EXISTS idx_rate_limits_block ON rate_limits(block_until) WHERE block_until IS NOT NULL;
|
package/templates/functions-supabase/supabase/migrations/20250101000003_operation_metrics.sql
CHANGED
|
@@ -15,6 +15,9 @@ CREATE TABLE IF NOT EXISTS operation_metrics (
|
|
|
15
15
|
error_message TEXT -- If status = 'failed'
|
|
16
16
|
);
|
|
17
17
|
|
|
18
|
+
-- Only service_role accesses this table; lock out anon/authenticated keys
|
|
19
|
+
ALTER TABLE operation_metrics ENABLE ROW LEVEL SECURITY;
|
|
20
|
+
|
|
18
21
|
-- Indexes for efficient queries
|
|
19
22
|
CREATE INDEX IF NOT EXISTS idx_metrics_operation ON operation_metrics(operation, timestamp DESC);
|
|
20
23
|
CREATE INDEX IF NOT EXISTS idx_metrics_user ON operation_metrics(user_id, timestamp DESC) WHERE user_id IS NOT NULL;
|
|
@@ -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
|