create-tigra 2.0.4 → 2.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/bin/create-tigra.js
CHANGED
|
@@ -124,11 +124,11 @@ async function main() {
|
|
|
124
124
|
program
|
|
125
125
|
.name('create-tigra')
|
|
126
126
|
.description('Create a production-ready full-stack app with Next.js + Fastify + Prisma + Redis')
|
|
127
|
-
.version('2.0
|
|
127
|
+
.version('2.1.0')
|
|
128
128
|
.argument('[project-name]', 'Name for your new project')
|
|
129
129
|
.action(async (projectNameArg) => {
|
|
130
130
|
console.log();
|
|
131
|
-
console.log(chalk.bold(' Create Tigra') + chalk.dim(' v2.0
|
|
131
|
+
console.log(chalk.bold(' Create Tigra') + chalk.dim(' v2.1.0'));
|
|
132
132
|
console.log();
|
|
133
133
|
|
|
134
134
|
let projectName = projectNameArg;
|
|
@@ -213,6 +213,9 @@ async function main() {
|
|
|
213
213
|
}
|
|
214
214
|
}
|
|
215
215
|
|
|
216
|
+
// Create .developer-role file (default: fullstack = no restrictions)
|
|
217
|
+
await fs.writeFile(path.join(targetDir, '.developer-role'), 'fullstack\n', 'utf-8');
|
|
218
|
+
|
|
216
219
|
spinner.succeed('Project scaffolded successfully!');
|
|
217
220
|
} catch (error) {
|
|
218
221
|
spinner.fail('Failed to scaffold project');
|
package/package.json
CHANGED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# Restrict Claude's WRITE access based on the .developer-role file.
|
|
3
|
+
# Claude can always READ any file for full project context.
|
|
4
|
+
# Only Edit/Write operations are blocked on the other side's directory.
|
|
5
|
+
#
|
|
6
|
+
# To switch roles, either:
|
|
7
|
+
# 1. Edit .developer-role and type: frontend, backend, or fullstack
|
|
8
|
+
# 2. Use /role command in Claude
|
|
9
|
+
#
|
|
10
|
+
# fullstack (or empty/missing file) = no restrictions
|
|
11
|
+
|
|
12
|
+
ROLE_FILE="$CLAUDE_PROJECT_DIR/.developer-role"
|
|
13
|
+
|
|
14
|
+
# Read role from file, trim whitespace
|
|
15
|
+
if [ -f "$ROLE_FILE" ]; then
|
|
16
|
+
ROLE=$(tr -d '[:space:]' < "$ROLE_FILE")
|
|
17
|
+
else
|
|
18
|
+
ROLE=""
|
|
19
|
+
fi
|
|
20
|
+
|
|
21
|
+
# No file, empty, or fullstack = full access
|
|
22
|
+
if [ -z "$ROLE" ] || [ "$ROLE" = "fullstack" ]; then
|
|
23
|
+
exit 0
|
|
24
|
+
fi
|
|
25
|
+
|
|
26
|
+
# Read stdin (JSON from Claude Code)
|
|
27
|
+
INPUT=$(cat)
|
|
28
|
+
|
|
29
|
+
# Extract tool_name from JSON
|
|
30
|
+
TOOL_NAME=$(echo "$INPUT" | grep -oP '"tool_name"\s*:\s*"[^"]*"' | head -1 | sed 's/.*:.*"\(.*\)"/\1/')
|
|
31
|
+
|
|
32
|
+
# Only block write operations (Edit, Write). Allow Read, Glob, Grep.
|
|
33
|
+
if [ "$TOOL_NAME" != "Edit" ] && [ "$TOOL_NAME" != "Write" ]; then
|
|
34
|
+
exit 0
|
|
35
|
+
fi
|
|
36
|
+
|
|
37
|
+
# Extract file_path or path from JSON
|
|
38
|
+
FILE_PATH=""
|
|
39
|
+
for field in file_path path; do
|
|
40
|
+
value=$(echo "$INPUT" | grep -oP "\"${field}\"\s*:\s*\"[^\"]*\"" | head -1 | sed 's/.*:.*"\(.*\)"/\1/')
|
|
41
|
+
if [ -n "$value" ]; then
|
|
42
|
+
FILE_PATH="$value"
|
|
43
|
+
break
|
|
44
|
+
fi
|
|
45
|
+
done
|
|
46
|
+
|
|
47
|
+
# No file path found = allow
|
|
48
|
+
if [ -z "$FILE_PATH" ]; then
|
|
49
|
+
exit 0
|
|
50
|
+
fi
|
|
51
|
+
|
|
52
|
+
deny_with_reason() {
|
|
53
|
+
cat <<DENY_EOF
|
|
54
|
+
{"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecision":"deny","permissionDecisionReason":"$1"}}
|
|
55
|
+
DENY_EOF
|
|
56
|
+
exit 0
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if [ "$ROLE" = "frontend" ]; then
|
|
60
|
+
if echo "$FILE_PATH" | grep -qiE "(^|/|\\\\)server(/|\\\\|$)"; then
|
|
61
|
+
deny_with_reason "BLOCKED: Role is set to frontend. You can read server/ files but cannot modify them. Only the backend developer can edit server/ code."
|
|
62
|
+
fi
|
|
63
|
+
elif [ "$ROLE" = "backend" ]; then
|
|
64
|
+
if echo "$FILE_PATH" | grep -qiE "(^|/|\\\\)client(/|\\\\|$)"; then
|
|
65
|
+
deny_with_reason "BLOCKED: Role is set to backend. You can read client/ files but cannot modify them. Only the frontend developer can edit client/ code."
|
|
66
|
+
fi
|
|
67
|
+
fi
|
|
68
|
+
|
|
69
|
+
exit 0
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: role
|
|
3
|
+
description: Switch developer role to restrict Claude's access to frontend-only, backend-only, or full access
|
|
4
|
+
argument-hint: "[frontend | backend | fullstack]"
|
|
5
|
+
disable-model-invocation: true
|
|
6
|
+
allowed-tools: Read, Write
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
The user wants to switch their developer role. The argument is: $ARGUMENTS
|
|
10
|
+
|
|
11
|
+
Read the file `.developer-role` in the project root to see the current role.
|
|
12
|
+
|
|
13
|
+
## Rules
|
|
14
|
+
|
|
15
|
+
- If the argument is `frontend`, `backend`, or `fullstack` — write that word to `.developer-role` and confirm the switch.
|
|
16
|
+
- If no argument is given — read `.developer-role` and tell the user their current role, then ask which role they want.
|
|
17
|
+
- If the argument is not one of the three valid roles — tell the user the valid options.
|
|
18
|
+
|
|
19
|
+
## What each role does
|
|
20
|
+
|
|
21
|
+
Claude can always READ all files for full project context. Only WRITE access is restricted.
|
|
22
|
+
|
|
23
|
+
| Role | Can edit |
|
|
24
|
+
|------|---------|
|
|
25
|
+
| `frontend` | `client/` only. Cannot edit `server/` files. |
|
|
26
|
+
| `backend` | `server/` only. Cannot edit `client/` files. |
|
|
27
|
+
| `fullstack` | Everything. No restrictions. |
|
|
28
|
+
|
|
29
|
+
## Response format
|
|
30
|
+
|
|
31
|
+
After switching, confirm like this:
|
|
32
|
+
|
|
33
|
+
```
|
|
34
|
+
Role switched to **{role}**.
|
|
35
|
+
|
|
36
|
+
- frontend → can edit client/ only (can read everything)
|
|
37
|
+
- backend → can edit server/ only (can read everything)
|
|
38
|
+
- fullstack → can edit everything
|
|
39
|
+
```
|