@sylphx/flow 0.2.12 → 1.0.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.
- package/CHANGELOG.md +185 -0
- package/LOOP_MODE.md +446 -0
- package/package.json +44 -93
- package/README.md +0 -625
- package/assets/agents/coder.md +0 -32
- package/assets/agents/orchestrator.md +0 -36
- package/assets/agents/reviewer.md +0 -30
- package/assets/agents/writer.md +0 -30
- package/assets/knowledge/data/sql.md +0 -216
- package/assets/knowledge/guides/saas-template.md +0 -85
- package/assets/knowledge/guides/system-prompt.md +0 -344
- package/assets/knowledge/guides/tech-stack.md +0 -92
- package/assets/knowledge/guides/ui-ux.md +0 -44
- package/assets/knowledge/stacks/nextjs-app.md +0 -165
- package/assets/knowledge/stacks/node-api.md +0 -220
- package/assets/knowledge/stacks/react-app.md +0 -232
- package/assets/knowledge/universal/deployment.md +0 -109
- package/assets/knowledge/universal/performance.md +0 -121
- package/assets/knowledge/universal/security.md +0 -79
- package/assets/knowledge/universal/testing.md +0 -111
- package/assets/output-styles/silent.md +0 -23
- package/assets/rules/core.md +0 -144
- package/assets/slash-commands/commit.md +0 -23
- package/assets/slash-commands/context.md +0 -112
- package/assets/slash-commands/explain.md +0 -35
- package/assets/slash-commands/mep.md +0 -63
- package/assets/slash-commands/review.md +0 -39
- package/assets/slash-commands/test.md +0 -30
- package/dist/assets/agents/coder.md +0 -32
- package/dist/assets/agents/orchestrator.md +0 -36
- package/dist/assets/agents/reviewer.md +0 -30
- package/dist/assets/agents/writer.md +0 -30
- package/dist/assets/knowledge/data/sql.md +0 -216
- package/dist/assets/knowledge/guides/saas-template.md +0 -85
- package/dist/assets/knowledge/guides/system-prompt.md +0 -344
- package/dist/assets/knowledge/guides/tech-stack.md +0 -92
- package/dist/assets/knowledge/guides/ui-ux.md +0 -44
- package/dist/assets/knowledge/stacks/nextjs-app.md +0 -165
- package/dist/assets/knowledge/stacks/node-api.md +0 -220
- package/dist/assets/knowledge/stacks/react-app.md +0 -232
- package/dist/assets/knowledge/universal/deployment.md +0 -109
- package/dist/assets/knowledge/universal/performance.md +0 -121
- package/dist/assets/knowledge/universal/security.md +0 -79
- package/dist/assets/knowledge/universal/testing.md +0 -111
- package/dist/assets/output-styles/silent.md +0 -23
- package/dist/assets/rules/core.md +0 -144
- package/dist/assets/slash-commands/commit.md +0 -23
- package/dist/assets/slash-commands/context.md +0 -112
- package/dist/assets/slash-commands/explain.md +0 -35
- package/dist/assets/slash-commands/mep.md +0 -63
- package/dist/assets/slash-commands/review.md +0 -39
- package/dist/assets/slash-commands/test.md +0 -30
- package/dist/chunk-01gv4qey.js +0 -4
- package/dist/chunk-01gv4qey.js.map +0 -11
- package/dist/chunk-3m9whg4q.js +0 -4
- package/dist/chunk-3m9whg4q.js.map +0 -9
- package/dist/chunk-3w6pd43t.js +0 -25
- package/dist/chunk-3w6pd43t.js.map +0 -61
- package/dist/chunk-4nm4ere4.js +0 -4
- package/dist/chunk-4nm4ere4.js.map +0 -11
- package/dist/chunk-4vrj3f8r.js +0 -26
- package/dist/chunk-4vrj3f8r.js.map +0 -75
- package/dist/chunk-5njgv5k5.js +0 -161
- package/dist/chunk-5njgv5k5.js.map +0 -83
- package/dist/chunk-67n29s4q.js +0 -7
- package/dist/chunk-67n29s4q.js.map +0 -10
- package/dist/chunk-86ce45n6.js +0 -3
- package/dist/chunk-86ce45n6.js.map +0 -10
- package/dist/chunk-99pz5wm0.js +0 -75
- package/dist/chunk-99pz5wm0.js.map +0 -12
- package/dist/chunk-cv1nhr27.js +0 -2
- package/dist/chunk-cv1nhr27.js.map +0 -9
- package/dist/chunk-d409xn8f.js +0 -6
- package/dist/chunk-d409xn8f.js.map +0 -11
- package/dist/chunk-g0qpndpd.js +0 -23
- package/dist/chunk-g0qpndpd.js.map +0 -132
- package/dist/chunk-g4baca7p.js +0 -10
- package/dist/chunk-g4baca7p.js.map +0 -23
- package/dist/chunk-gc66xe7z.js +0 -4
- package/dist/chunk-gc66xe7z.js.map +0 -11
- package/dist/chunk-hj6qtsqp.js +0 -15
- package/dist/chunk-hj6qtsqp.js.map +0 -10
- package/dist/chunk-jbd95k1f.js +0 -14
- package/dist/chunk-jbd95k1f.js.map +0 -20
- package/dist/chunk-kn908zkk.js +0 -4
- package/dist/chunk-kn908zkk.js.map +0 -10
- package/dist/chunk-mw13a082.js +0 -4
- package/dist/chunk-mw13a082.js.map +0 -10
- package/dist/chunk-nke51f3c.js +0 -4
- package/dist/chunk-nke51f3c.js.map +0 -10
- package/dist/chunk-ns5atzyz.js +0 -3
- package/dist/chunk-ns5atzyz.js.map +0 -10
- package/dist/chunk-pp4r3hp4.js +0 -105
- package/dist/chunk-pp4r3hp4.js.map +0 -27
- package/dist/chunk-q4nh3vst.js +0 -54
- package/dist/chunk-q4nh3vst.js.map +0 -53
- package/dist/chunk-q5gqgs0p.js +0 -4
- package/dist/chunk-q5gqgs0p.js.map +0 -10
- package/dist/chunk-s9bsh0gp.js +0 -4
- package/dist/chunk-s9bsh0gp.js.map +0 -10
- package/dist/chunk-ss51dw5h.js +0 -27
- package/dist/chunk-ss51dw5h.js.map +0 -23
- package/dist/chunk-waemzsf4.js +0 -4
- package/dist/chunk-waemzsf4.js.map +0 -10
- package/dist/chunk-xs370t8p.js +0 -119
- package/dist/chunk-xs370t8p.js.map +0 -26
- package/dist/chunk-xtrn4wn0.js +0 -3
- package/dist/chunk-xtrn4wn0.js.map +0 -10
- package/dist/chunk-xvfz960r.js +0 -4
- package/dist/chunk-xvfz960r.js.map +0 -12
- package/dist/chunk-xytc0fks.js +0 -27
- package/dist/chunk-xytc0fks.js.map +0 -14
- package/dist/chunk-yxv7hqse.js +0 -23
- package/dist/chunk-yxv7hqse.js.map +0 -11
- package/dist/chunk-zv5y8yfq.js +0 -19
- package/dist/chunk-zv5y8yfq.js.map +0 -11
- package/dist/index.js +0 -854
- package/dist/index.js.map +0 -903
- package/drizzle/0000_wooden_lady_bullseye.sql +0 -52
- package/drizzle/0001_material_pyro.sql +0 -85
- package/drizzle/0002_lyrical_random.sql +0 -2
- package/drizzle/0003_romantic_lockjaw.sql +0 -4
- package/drizzle/0004_blushing_meteorite.sql +0 -6
- package/drizzle/meta/0000_snapshot.json +0 -310
- package/drizzle/meta/0001_snapshot.json +0 -906
- package/drizzle/meta/0002_snapshot.json +0 -920
- package/drizzle/meta/0003_snapshot.json +0 -920
- package/drizzle/meta/0004_snapshot.json +0 -921
- package/drizzle/meta/_journal.json +0 -41
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: Shared Agent Guidelines
|
|
3
|
-
description: Universal principles and standards for all agents
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# SHARED GUIDELINES
|
|
7
|
-
|
|
8
|
-
## Performance
|
|
9
|
-
|
|
10
|
-
**Parallel Execution**: Multiple tool calls in ONE message = parallel. Multiple messages = sequential.
|
|
11
|
-
|
|
12
|
-
Use parallel whenever tools are independent. Watch for dependencies and ordering requirements.
|
|
13
|
-
|
|
14
|
-
---
|
|
15
|
-
|
|
16
|
-
## Cognitive Framework
|
|
17
|
-
|
|
18
|
-
### Understanding Depth
|
|
19
|
-
- **Shallow OK**: Well-defined, low-risk, established patterns → Implement
|
|
20
|
-
- **Deep required**: Ambiguous, high-risk, novel, irreversible → Investigate first
|
|
21
|
-
|
|
22
|
-
### Complexity Navigation
|
|
23
|
-
- **Mechanical**: Known patterns → Execute fast
|
|
24
|
-
- **Analytical**: Multiple components → Design then build
|
|
25
|
-
- **Emergent**: Unknown domain → Research, prototype, design, build
|
|
26
|
-
|
|
27
|
-
### State Awareness
|
|
28
|
-
- **Flow**: Clear path, tests pass → Push forward
|
|
29
|
-
- **Friction**: Hard to implement, messy → Reassess, simplify
|
|
30
|
-
- **Uncertain**: Missing info → Assume reasonably, document, continue
|
|
31
|
-
|
|
32
|
-
**Signals to pause**: Can't explain simply, too many caveats, hesitant without reason, over-confident without alternatives.
|
|
33
|
-
|
|
34
|
-
---
|
|
35
|
-
|
|
36
|
-
## Principles
|
|
37
|
-
|
|
38
|
-
### Programming
|
|
39
|
-
- **Functional composition**: Pure functions, immutable data, explicit side effects
|
|
40
|
-
- **Composition over inheritance**: Prefer function composition, mixins, dependency injection
|
|
41
|
-
- **Declarative over imperative**: Express what you want, not how
|
|
42
|
-
- **Event-driven when appropriate**: Decouple components through events/messages
|
|
43
|
-
|
|
44
|
-
### Quality
|
|
45
|
-
- **YAGNI**: Build what's needed now, not hypothetical futures
|
|
46
|
-
- **KISS**: Choose simple solutions over complex ones
|
|
47
|
-
- **DRY**: Extract duplication on 3rd occurrence. Balance with readability
|
|
48
|
-
- **Separation of concerns**: Each module handles one responsibility
|
|
49
|
-
- **Dependency inversion**: Depend on abstractions, not implementations
|
|
50
|
-
|
|
51
|
-
---
|
|
52
|
-
|
|
53
|
-
## Technical Standards
|
|
54
|
-
|
|
55
|
-
**Code Quality**: Self-documenting names, test critical paths (100%) and business logic (80%+), comments explain WHY not WHAT, make illegal states unrepresentable.
|
|
56
|
-
|
|
57
|
-
**Security**: Validate inputs at boundaries, never log sensitive data, secure defaults (auth required, deny by default), include rollback plan for risky changes.
|
|
58
|
-
|
|
59
|
-
**Error Handling**: Handle explicitly at boundaries, use Result/Either for expected failures, never mask failures, log with context, actionable messages.
|
|
60
|
-
|
|
61
|
-
**Refactoring**: Extract on 3rd duplication, when function >20 lines or cognitive load high. When thinking "I'll clean later" → Clean NOW. When adding TODO → Implement NOW.
|
|
62
|
-
|
|
63
|
-
---
|
|
64
|
-
|
|
65
|
-
## Documentation
|
|
66
|
-
|
|
67
|
-
Communicate through code using inline comments and docstrings.
|
|
68
|
-
|
|
69
|
-
Separate documentation files only when explicitly requested.
|
|
70
|
-
|
|
71
|
-
---
|
|
72
|
-
|
|
73
|
-
## Anti-Patterns
|
|
74
|
-
|
|
75
|
-
**Technical Debt Rationalization**: "I'll clean this later" → You won't. "Just one more TODO" → Compounds. "Tests slow me down" → Bugs slow more. Refactor AS you make it work, not after.
|
|
76
|
-
|
|
77
|
-
**Reinventing the Wheel**: Before ANY feature: research best practices + search codebase + check package registry + check framework built-ins.
|
|
78
|
-
|
|
79
|
-
Example:
|
|
80
|
-
```typescript
|
|
81
|
-
Don't: Custom Result type → Do: import { Result } from 'neverthrow'
|
|
82
|
-
Don't: Custom validation → Do: import { z } from 'zod'
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
**Others**: Premature optimization, analysis paralysis, skipping tests, ignoring existing patterns, blocking on missing info, asking permission for obvious choices.
|
|
86
|
-
|
|
87
|
-
---
|
|
88
|
-
|
|
89
|
-
## Version Control
|
|
90
|
-
|
|
91
|
-
Feature branches `{type}/{description}`, semantic commits `<type>(<scope>): <description>`, atomic commits.
|
|
92
|
-
|
|
93
|
-
---
|
|
94
|
-
|
|
95
|
-
## File Handling
|
|
96
|
-
|
|
97
|
-
**Scratch work**: System temp directory (/tmp on Unix, %TEMP% on Windows)
|
|
98
|
-
**Final deliverables**: Working directory or user-specified location
|
|
99
|
-
|
|
100
|
-
---
|
|
101
|
-
|
|
102
|
-
## Autonomous Decisions
|
|
103
|
-
|
|
104
|
-
**Never block. Always proceed with assumptions.**
|
|
105
|
-
|
|
106
|
-
Safe assumptions: Standard patterns (REST, JWT), framework conventions, existing codebase patterns.
|
|
107
|
-
|
|
108
|
-
**Document in code**:
|
|
109
|
-
```javascript
|
|
110
|
-
// ASSUMPTION: JWT auth (REST standard, matches existing APIs)
|
|
111
|
-
// ALTERNATIVE: Session-based
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
**Decision hierarchy**: existing patterns > simplicity > maintainability
|
|
115
|
-
|
|
116
|
-
Important decisions: Document in commit message or PR description.
|
|
117
|
-
|
|
118
|
-
---
|
|
119
|
-
|
|
120
|
-
## High-Stakes Decisions
|
|
121
|
-
|
|
122
|
-
Use structured reasoning only for high-stakes decisions. Most decisions: decide autonomously without explanation.
|
|
123
|
-
|
|
124
|
-
**When to use**:
|
|
125
|
-
- Decision difficult to reverse (schema changes, architecture choices)
|
|
126
|
-
- Affects >3 major components
|
|
127
|
-
- Security-critical
|
|
128
|
-
- Long-term maintenance impact
|
|
129
|
-
|
|
130
|
-
**Quick check**: Easy to reverse? → Decide autonomously. Clear best practice? → Follow it.
|
|
131
|
-
|
|
132
|
-
### Decision Frameworks
|
|
133
|
-
|
|
134
|
-
**🎯 First Principles** - Break down to fundamentals, challenge assumptions. *Novel problems without precedent.*
|
|
135
|
-
|
|
136
|
-
**⚖️ Decision Matrix** - Score options against weighted criteria. *3+ options with multiple criteria.*
|
|
137
|
-
|
|
138
|
-
**🔄 Trade-off Analysis** - Compare competing aspects. *Performance vs cost, speed vs quality.*
|
|
139
|
-
|
|
140
|
-
### Process
|
|
141
|
-
1. Recognize trigger
|
|
142
|
-
2. Choose framework
|
|
143
|
-
3. Analyze decision
|
|
144
|
-
4. Document in commit message or PR description
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
description: Create a git commit with meaningful message
|
|
3
|
-
---
|
|
4
|
-
|
|
5
|
-
# Create Git Commit
|
|
6
|
-
|
|
7
|
-
## Context
|
|
8
|
-
|
|
9
|
-
- Current git status: !`git status`
|
|
10
|
-
- Current git diff (staged and unstaged changes): !`git diff HEAD`
|
|
11
|
-
- Current branch: !`git branch --show-current`
|
|
12
|
-
- Recent commits: !`git log --oneline -10`
|
|
13
|
-
|
|
14
|
-
## Your Task
|
|
15
|
-
|
|
16
|
-
Based on the above changes, create a single git commit with a meaningful commit message that:
|
|
17
|
-
|
|
18
|
-
1. Follows conventional commits format: `type(scope): description`
|
|
19
|
-
2. Accurately describes what changed and why
|
|
20
|
-
3. Includes any breaking changes or important notes
|
|
21
|
-
4. Uses present tense ("add" not "added")
|
|
22
|
-
|
|
23
|
-
After creating the commit, show the commit message for review.
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
description: Display current context window usage and token breakdown
|
|
3
|
-
---
|
|
4
|
-
|
|
5
|
-
# Context Window Usage
|
|
6
|
-
|
|
7
|
-
Display detailed information about the current context window usage, including token counts for different components.
|
|
8
|
-
|
|
9
|
-
## Your Task
|
|
10
|
-
|
|
11
|
-
Analyze and display the context window usage with the following sections:
|
|
12
|
-
|
|
13
|
-
### 1. Model Information
|
|
14
|
-
Show the current model being used and its token limits.
|
|
15
|
-
|
|
16
|
-
### 2. Visual Token Usage Bar
|
|
17
|
-
Create a visual bar chart (10 blocks wide) showing token usage breakdown using these Unicode characters:
|
|
18
|
-
- ⛁ (filled) - Used tokens
|
|
19
|
-
- ⛀ (half-filled) - Partially used blocks
|
|
20
|
-
- ⛶ (empty) - Reserved/System tokens
|
|
21
|
-
- ⛝ (light) - Free space/buffer
|
|
22
|
-
|
|
23
|
-
### 3. Token Breakdown
|
|
24
|
-
|
|
25
|
-
Calculate and display tokens for each category:
|
|
26
|
-
|
|
27
|
-
#### System Prompt
|
|
28
|
-
- Count tokens in the system prompt
|
|
29
|
-
- Show: `⛁ System prompt: X.Xk tokens (X.X%)`
|
|
30
|
-
|
|
31
|
-
#### System Tools
|
|
32
|
-
- Count tokens for all built-in tool definitions (filesystem, shell, search, interaction tools)
|
|
33
|
-
- Show: `⛁ System tools: X.Xk tokens (X.X%)`
|
|
34
|
-
|
|
35
|
-
#### MCP Tools
|
|
36
|
-
- Count tokens for all MCP tool definitions
|
|
37
|
-
- List each MCP tool with its token count
|
|
38
|
-
- Show: `⛁ MCP tools: X.Xk tokens (X.X%)`
|
|
39
|
-
|
|
40
|
-
#### Custom Agents
|
|
41
|
-
- Count tokens for custom agent definitions (if any)
|
|
42
|
-
- List each agent with token count
|
|
43
|
-
- Show: `⛁ Custom agents: X tokens (X.X%)`
|
|
44
|
-
|
|
45
|
-
#### Messages
|
|
46
|
-
- Count tokens in all messages in the current session
|
|
47
|
-
- Show: `⛁ Messages: X tokens (X.X%)`
|
|
48
|
-
|
|
49
|
-
#### Free Space
|
|
50
|
-
- Calculate remaining available tokens
|
|
51
|
-
- Show: `⛶ Free space: XXXk (XX.X%)`
|
|
52
|
-
|
|
53
|
-
#### Autocompact Buffer
|
|
54
|
-
- Calculate reserved buffer space (typically 22.5% of total)
|
|
55
|
-
- Show: `⛝ Autocompact buffer: XX.Xk tokens (XX.X%)`
|
|
56
|
-
|
|
57
|
-
### 4. Detailed Listings
|
|
58
|
-
|
|
59
|
-
Show expandable sections with details:
|
|
60
|
-
|
|
61
|
-
```
|
|
62
|
-
MCP tools · /mcp
|
|
63
|
-
└ mcp__tool_name (server-name): XXX tokens
|
|
64
|
-
└ ...
|
|
65
|
-
|
|
66
|
-
Custom agents · /agents
|
|
67
|
-
└ agent-name (Project): XX tokens
|
|
68
|
-
└ ...
|
|
69
|
-
|
|
70
|
-
SlashCommand Tool · X commands
|
|
71
|
-
└ Total: XXX tokens
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
## Display Format
|
|
75
|
-
|
|
76
|
-
Use this exact format for the output:
|
|
77
|
-
|
|
78
|
-
```
|
|
79
|
-
Context Usage
|
|
80
|
-
⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛀ ⛁ ⛁ model-name · XXk/XXXk tokens (XX%)
|
|
81
|
-
⛀ ⛀ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶
|
|
82
|
-
⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛁ System prompt: X.Xk tokens (X.X%)
|
|
83
|
-
⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛁ System tools: XX.Xk tokens (X.X%)
|
|
84
|
-
⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛁ MCP tools: X.Xk tokens (X.X%)
|
|
85
|
-
⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛁ Custom agents: XX tokens (X.X%)
|
|
86
|
-
⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛁ Messages: XXX tokens (X.X%)
|
|
87
|
-
⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛝ ⛝ ⛝ ⛶ Free space: XXXk (XX.X%)
|
|
88
|
-
⛝ ⛝ ⛝ ⛝ ⛝ ⛝ ⛝ ⛝ ⛝ ⛝ ⛝ Autocompact buffer: XX.Xk tokens (XX.X%)
|
|
89
|
-
⛝ ⛝ ⛝ ⛝ ⛝ ⛝ ⛝ ⛝ ⛝ ⛝
|
|
90
|
-
|
|
91
|
-
MCP tools · /mcp
|
|
92
|
-
└ tool_name (server-name): XXX tokens
|
|
93
|
-
└ ...
|
|
94
|
-
|
|
95
|
-
Custom agents · /agents
|
|
96
|
-
└ agent-name (Project): XX tokens
|
|
97
|
-
└ ...
|
|
98
|
-
|
|
99
|
-
SlashCommand Tool · X commands
|
|
100
|
-
└ Total: XXX tokens
|
|
101
|
-
```
|
|
102
|
-
|
|
103
|
-
## Implementation Notes
|
|
104
|
-
|
|
105
|
-
1. Use the `countTokens()` utility from `src/utils/token-counter.ts` with the current session model name
|
|
106
|
-
2. Get current session from app store to access model name and messages
|
|
107
|
-
3. Get system prompt from `src/core/ai-sdk.ts` (SYSTEM_PROMPT constant)
|
|
108
|
-
4. Get tool definitions from `src/tools/registry.ts` (getAISDKTools())
|
|
109
|
-
5. Calculate percentages based on the model's max token limit (e.g., 200k for Claude Sonnet 4.5)
|
|
110
|
-
6. Round token counts appropriately (show decimals for k, no decimals for raw numbers)
|
|
111
|
-
7. Ensure the bar chart accurately represents the proportions
|
|
112
|
-
8. Use proper indentation and alignment for readability
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
description: Explain code in detail
|
|
3
|
-
---
|
|
4
|
-
|
|
5
|
-
# Explain Code
|
|
6
|
-
|
|
7
|
-
## Context
|
|
8
|
-
|
|
9
|
-
$ARGUMENTS
|
|
10
|
-
|
|
11
|
-
## Your Task
|
|
12
|
-
|
|
13
|
-
Provide a comprehensive explanation of the code above (or at the specified location) that includes:
|
|
14
|
-
|
|
15
|
-
1. **Overview**
|
|
16
|
-
- What does this code do?
|
|
17
|
-
- What problem does it solve?
|
|
18
|
-
|
|
19
|
-
2. **How It Works**
|
|
20
|
-
- Step-by-step breakdown of the logic
|
|
21
|
-
- Key algorithms or patterns used
|
|
22
|
-
- Important design decisions
|
|
23
|
-
|
|
24
|
-
3. **Components**
|
|
25
|
-
- Main functions/classes/modules
|
|
26
|
-
- Their roles and responsibilities
|
|
27
|
-
- How they interact
|
|
28
|
-
|
|
29
|
-
4. **Important Details**
|
|
30
|
-
- Edge cases handled
|
|
31
|
-
- Performance considerations
|
|
32
|
-
- Security implications
|
|
33
|
-
- Dependencies and requirements
|
|
34
|
-
|
|
35
|
-
Use clear language and provide examples where helpful.
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
description: Convert verbose prompt to MEP (Minimal Effective Prompt)
|
|
3
|
-
---
|
|
4
|
-
|
|
5
|
-
# MEP - Minimal Effective Prompt
|
|
6
|
-
|
|
7
|
-
## Context
|
|
8
|
-
|
|
9
|
-
User's original prompt:
|
|
10
|
-
```
|
|
11
|
-
$ARGUMENTS
|
|
12
|
-
```
|
|
13
|
-
|
|
14
|
-
## Your Task
|
|
15
|
-
|
|
16
|
-
Analyze the user's prompt above and refactor it into a **Minimal Effective Prompt (MEP)** that:
|
|
17
|
-
|
|
18
|
-
### Remove Unnecessary Context
|
|
19
|
-
❌ Remove information that AI already knows:
|
|
20
|
-
- Current date/time (AI has access via hooks)
|
|
21
|
-
- System information (platform, CPU, memory - provided automatically)
|
|
22
|
-
- Project structure (AI can search codebase)
|
|
23
|
-
- Tech stack (AI can detect from package.json and code)
|
|
24
|
-
- File locations (AI can search)
|
|
25
|
-
- Existing code patterns (AI can search codebase)
|
|
26
|
-
|
|
27
|
-
### Keep Essential Information
|
|
28
|
-
✅ Keep only what AI cannot infer:
|
|
29
|
-
- Specific business requirements
|
|
30
|
-
- User preferences or constraints
|
|
31
|
-
- Domain-specific knowledge
|
|
32
|
-
- Desired outcome or behavior
|
|
33
|
-
- Acceptance criteria
|
|
34
|
-
|
|
35
|
-
### Apply MEP Principles
|
|
36
|
-
|
|
37
|
-
1. **Be Specific About What, Not How**
|
|
38
|
-
- ❌ "Create a React component with useState hook, useEffect for data fetching, proper error handling..."
|
|
39
|
-
- ✅ "Add user profile page with real-time data"
|
|
40
|
-
|
|
41
|
-
2. **Trust AI's Knowledge**
|
|
42
|
-
- ❌ "Using TypeScript with proper types, following our code style..."
|
|
43
|
-
- ✅ "Add user authentication" (AI will use TypeScript, follow existing patterns)
|
|
44
|
-
|
|
45
|
-
3. **Focus on Intent**
|
|
46
|
-
- ❌ "I need a function that takes an array and returns unique values using Set..."
|
|
47
|
-
- ✅ "Remove duplicate items from the list"
|
|
48
|
-
|
|
49
|
-
4. **Remove Redundancy**
|
|
50
|
-
- ❌ "Add comprehensive error handling with try-catch blocks and proper error messages..."
|
|
51
|
-
- ✅ "Add error handling" (comprehensive is default)
|
|
52
|
-
|
|
53
|
-
### Output Format
|
|
54
|
-
|
|
55
|
-
Provide the refactored MEP prompt as a single, concise statement (1-3 sentences max) that captures the essence of the user's intent.
|
|
56
|
-
|
|
57
|
-
**Original:** [quote the original]
|
|
58
|
-
|
|
59
|
-
**MEP Version:** [your refactored minimal prompt]
|
|
60
|
-
|
|
61
|
-
**Removed Context:** [list what was removed and why - explain that AI already has this info]
|
|
62
|
-
|
|
63
|
-
**Preserved Intent:** [confirm the core requirement is maintained]
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
description: Review code for quality, security, and best practices
|
|
3
|
-
---
|
|
4
|
-
|
|
5
|
-
# Code Review
|
|
6
|
-
|
|
7
|
-
## Context
|
|
8
|
-
|
|
9
|
-
$ARGUMENTS
|
|
10
|
-
|
|
11
|
-
## Your Task
|
|
12
|
-
|
|
13
|
-
Review the code above (or at the specified location) and provide feedback on:
|
|
14
|
-
|
|
15
|
-
1. **Code Quality**
|
|
16
|
-
- Readability and maintainability
|
|
17
|
-
- Code organization and structure
|
|
18
|
-
- Naming conventions
|
|
19
|
-
- Comments and documentation
|
|
20
|
-
|
|
21
|
-
2. **Security**
|
|
22
|
-
- Potential vulnerabilities
|
|
23
|
-
- Input validation
|
|
24
|
-
- Authentication/authorization issues
|
|
25
|
-
- Data exposure risks
|
|
26
|
-
|
|
27
|
-
3. **Performance**
|
|
28
|
-
- Algorithmic efficiency
|
|
29
|
-
- Resource usage
|
|
30
|
-
- Potential bottlenecks
|
|
31
|
-
- Scalability concerns
|
|
32
|
-
|
|
33
|
-
4. **Best Practices**
|
|
34
|
-
- Language-specific idioms
|
|
35
|
-
- Design patterns
|
|
36
|
-
- Error handling
|
|
37
|
-
- Testing coverage
|
|
38
|
-
|
|
39
|
-
Provide specific, actionable suggestions for improvement.
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
description: Write comprehensive tests for code
|
|
3
|
-
---
|
|
4
|
-
|
|
5
|
-
# Write Tests
|
|
6
|
-
|
|
7
|
-
## Context
|
|
8
|
-
|
|
9
|
-
$ARGUMENTS
|
|
10
|
-
|
|
11
|
-
## Your Task
|
|
12
|
-
|
|
13
|
-
Write comprehensive tests for the code above (or at the specified location) that include:
|
|
14
|
-
|
|
15
|
-
1. **Unit Tests**
|
|
16
|
-
- Test individual functions/methods
|
|
17
|
-
- Cover edge cases and boundary conditions
|
|
18
|
-
- Test error handling
|
|
19
|
-
|
|
20
|
-
2. **Integration Tests** (if applicable)
|
|
21
|
-
- Test component interactions
|
|
22
|
-
- Test with realistic data
|
|
23
|
-
|
|
24
|
-
3. **Test Coverage**
|
|
25
|
-
- Aim for high coverage of critical paths
|
|
26
|
-
- Include positive and negative test cases
|
|
27
|
-
- Test validation and error conditions
|
|
28
|
-
|
|
29
|
-
Use the project's existing testing framework and follow its conventions.
|
|
30
|
-
Ensure tests are readable, maintainable, and properly documented.
|
package/dist/chunk-01gv4qey.js
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{Sb as $}from"./chunk-4vrj3f8r.js";import M from"node:fs";import Z from"node:path";import{fileURLToPath as b}from"node:url";import{execFile as U}from"node:child_process";import Y from"node:path";import{promisify as I}from"node:util";var _=I(U),C={projectName:$.string().min(1,"Project name is required").max(100,"Project name too long").regex(/^[a-zA-Z0-9_-]+$/,"Project name can only contain letters, numbers, hyphens, and underscores").refine((G)=>!/^\.+$/.test(G),"Project name cannot be only dots").refine((G)=>!/[<>:"|?*]/.test(G),"Project name contains invalid characters"),branchName:$.string().min(1,"Branch name is required").max(255,"Branch name too long").regex(/^[a-zA-Z0-9/_-]+$/,"Branch name can only contain letters, numbers, slashes, hyphens, and underscores").refine((G)=>!G.includes(".."),'Branch name cannot contain ".."').refine((G)=>!/^[/\\]/.test(G),"Branch name cannot start with path separators").refine((G)=>!/[<>:"|?*$]/.test(G),"Branch name contains invalid characters"),filePath:$.string().min(1,"File path is required").max(1000,"File path too long").refine((G)=>!G.includes(".."),'File path cannot contain ".." for path traversal protection').refine((G)=>!/^[<>:"|?*]/.test(G),"File path contains invalid characters"),commandArg:$.string().max(1000,"Command argument too long").refine((G)=>!/[<>|;&$`'"\\]/.test(G),"Command argument contains potentially dangerous characters"),envVarName:$.string().regex(/^[A-Z_][A-Z0-9_]*$/,"Invalid environment variable name format").max(100,"Environment variable name too long"),url:$.string().url("Invalid URL format").refine((G)=>G.startsWith("https://")||G.startsWith("http://localhost"),"URL must be HTTPS or localhost").refine((G)=>!G.includes("javascript:"),"URL cannot contain javascript protocol"),apiKey:$.string().min(10,"API key too short").max(500,"API key too long").regex(/^[a-zA-Z0-9._-]+$/,"Invalid API key format")},F={validatePath:(G,K)=>{let H=C.filePath.parse(G),Q=Y.normalize(H);if(Q.includes(".."))throw Error("Path traversal detected in file path");if(K){let W=Y.resolve(K,Q),X=Y.resolve(K);if(!W.startsWith(X))throw Error("File path escapes allowed base directory");return W}return Q},isPathSafe:(G,K)=>{try{let H=Y.resolve(G),Q=Y.resolve(K);return H.startsWith(Q)}catch{return!1}},safeJoin:(G,...K)=>{let H=Y.join(G,...K),Q=Y.normalize(H),W=Y.resolve(G),X=Y.resolve(Q);if(!X.startsWith(W))throw Error("Path traversal attempt detected in safeJoin");return X}};var B={string:(G,K=1000)=>{if(typeof G!=="string")throw Error("Input must be a string");return G.replace(/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]/g,"").substring(0,K)},logMessage:(G)=>{return G.replace(/[\r\n]/g," ").replace(/\t/g," ").substring(0,500)},fileName:(G)=>{return G.replace(/[^a-zA-Z0-9._-]/g,"_").replace(/_{2,}/g,"_").replace(/^_|_$/g,"").toLowerCase()},yamlContent:(G)=>{return G.replace(/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]/g,"").replace(/<!\[CDATA\[.*?\]\]>/gs,"").replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,"")}},k={validateEnvVar:(G,K)=>{let H=C.envVarName.parse(G);if(K===void 0)throw Error(`Environment variable ${H} is required but not set`);if(H.includes("URL")||H.includes("BASE_URL"))C.url.parse(K);else if(H.includes("KEY")||H.includes("SECRET")){if(K.length<10)throw Error(`API key ${H} is too short`)}return{name:H,value:K}},getEnvVar:(G,K)=>{try{let H=process.env[G];if(H===void 0){if(K!==void 0)return K;throw Error(`Environment variable ${G} is not set`)}return k.validateEnvVar(G,H).value}catch(H){return console.warn(`Environment variable validation failed for ${G}:`,H),K}},validateEnvVars:(G)=>{let K={};for(let[H,Q]of Object.entries(G)){let W=process.env[H];if(W===void 0){if(Q.required)throw Error(`Required environment variable ${H} is not set`);continue}try{if(Q.schema)K[H]=Q.schema.parse(W);else{let X=k.validateEnvVar(H,W);K[H]=X.value}}catch(X){throw Error(`Environment variable ${H} validation failed: ${X}`)}}return K}};function L(G){let K=b(import.meta.url),H=Z.dirname(K);for(let W=0;W<10;W++){let X=Z.join(H,"package.json");if(M.existsSync(X))return H;let J=Z.dirname(H);if(J===H)break;H=J}let Q=G?`Cannot find package.json - ${G} location unknown`:"Cannot find package.json";throw Error(Q)}var j=Z.join(L(),"assets");function w(){return Z.join(j,"agents")}function q(){return Z.join(j,"rules")}function O(){return Z.join(j,"knowledge")}function P(){return Z.join(j,"output-styles")}function y(){return Z.join(j,"slash-commands")}function S(G){if(!G||typeof G!=="string")throw Error("Filename must be a non-empty string");if(G.includes("..")||G.includes("/")||G.includes("\\"))throw Error(`Invalid filename: ${G}. Path traversal not allowed.`);if(!/^[a-zA-Z0-9._-]+$/.test(G))throw Error(`Filename contains invalid characters: ${G}`);let K=q(),H=F.safeJoin(K,G);if(!M.existsSync(H))throw Error(`Rule file not found: ${G} (looked in ${K})`);return H}
|
|
2
|
-
export{C as na,F as oa,B as pa,k as qa,L as ra,w as sa,q as ta,O as ua,P as va,y as wa,S as xa};
|
|
3
|
-
|
|
4
|
-
//# debugId=B36B269C3826F9AF64756E2164756E21
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/utils/paths.ts", "../src/utils/security.ts"],
|
|
4
|
-
"sourcesContent": [
|
|
5
|
-
"/**\n * Centralized path resolution for all static assets\n *\n * Structure:\n * assets/ (at project root) - single source of truth\n *\n * Path resolution:\n * - Development: src/utils/paths.ts reads ../assets\n * - Production: dist/xxx.js reads ../assets\n * - No copying needed, both read same location\n */\n\nimport fs from 'node:fs';\nimport path from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport { pathSecurity } from './security.js';\n\n/**\n * Find package root by walking up directory tree\n * Pure function - finds package.json location\n *\n * @param context - Optional context for error message (e.g., 'assets', 'migrations')\n * @returns Absolute path to package root directory\n * @throws Error if package.json cannot be found within 10 levels\n *\n * @example\n * const root = findPackageRoot(); // 'Cannot find package.json'\n * const root = findPackageRoot('drizzle migrations'); // 'Cannot find package.json - drizzle migrations location unknown'\n */\nexport function findPackageRoot(context?: string): string {\n const __filename = fileURLToPath(import.meta.url);\n let currentDir = path.dirname(__filename);\n\n // Walk up max 10 levels to find package.json\n for (let i = 0; i < 10; i++) {\n const packageJsonPath = path.join(currentDir, 'package.json');\n if (fs.existsSync(packageJsonPath)) {\n return currentDir;\n }\n\n const parentDir = path.dirname(currentDir);\n if (parentDir === currentDir) break; // reached filesystem root\n currentDir = parentDir;\n }\n\n const errorMsg = context\n ? `Cannot find package.json - ${context} location unknown`\n : 'Cannot find package.json';\n throw new Error(errorMsg);\n}\n\nconst ASSETS_ROOT = path.join(findPackageRoot(), 'assets');\n\n/**\n * Get path to agents directory\n */\nexport function getAgentsDir(): string {\n return path.join(ASSETS_ROOT, 'agents');\n}\n\n/**\n * Get path to templates directory\n */\nexport function getTemplatesDir(): string {\n return path.join(ASSETS_ROOT, 'templates');\n}\n\n/**\n * Get path to rules directory\n */\nexport function getRulesDir(): string {\n return path.join(ASSETS_ROOT, 'rules');\n}\n\n/**\n * Get path to knowledge directory\n */\nexport function getKnowledgeDir(): string {\n return path.join(ASSETS_ROOT, 'knowledge');\n}\n\n/**\n * Get path to output styles directory\n */\nexport function getOutputStylesDir(): string {\n return path.join(ASSETS_ROOT, 'output-styles');\n}\n\n/**\n * Get path to slash commands directory\n */\nexport function getSlashCommandsDir(): string {\n return path.join(ASSETS_ROOT, 'slash-commands');\n}\n\n/**\n * Get path to a specific rule file with path traversal protection\n */\nexport function getRuleFile(filename: string): string {\n // Validate filename to prevent path traversal\n if (!filename || typeof filename !== 'string') {\n throw new Error('Filename must be a non-empty string');\n }\n\n // Check for path traversal attempts\n if (filename.includes('..') || filename.includes('/') || filename.includes('\\\\')) {\n throw new Error(`Invalid filename: ${filename}. Path traversal not allowed.`);\n }\n\n // Validate filename contains only safe characters\n if (!/^[a-zA-Z0-9._-]+$/.test(filename)) {\n throw new Error(`Filename contains invalid characters: ${filename}`);\n }\n\n // Safely join paths\n const rulesDir = getRulesDir();\n const filePath = pathSecurity.safeJoin(rulesDir, filename);\n\n if (!fs.existsSync(filePath)) {\n throw new Error(`Rule file not found: ${filename} (looked in ${rulesDir})`);\n }\n\n return filePath;\n}\n\n/**\n * Debug info - shows where assets are resolved from\n */\nexport function getPathsInfo() {\n return {\n assetsRoot: ASSETS_ROOT,\n agents: getAgentsDir(),\n templates: getTemplatesDir(),\n rules: getRulesDir(),\n outputStyles: getOutputStylesDir(),\n slashCommands: getSlashCommandsDir(),\n };\n}\n",
|
|
6
|
-
"/**\n * Security utilities for input validation, sanitization, and safe operations\n * Implements defense-in-depth security principles\n */\n\nimport { execFile } from 'node:child_process';\nimport crypto from 'node:crypto';\nimport path from 'node:path';\nimport { promisify } from 'node:util';\nimport { z } from 'zod';\n\nconst execFileAsync = promisify(execFile);\n\n// ============================================================================\n// INPUT VALIDATION SCHEMAS\n// ============================================================================\n\n/**\n * Security-focused validation schemas\n */\nexport const securitySchemas = {\n /** Project name validation - prevents command injection and path traversal */\n projectName: z\n .string()\n .min(1, 'Project name is required')\n .max(100, 'Project name too long')\n .regex(\n /^[a-zA-Z0-9_-]+$/,\n 'Project name can only contain letters, numbers, hyphens, and underscores'\n )\n .refine((name) => !/^\\.+$/.test(name), 'Project name cannot be only dots')\n .refine((name) => !/[<>:\"|?*]/.test(name), 'Project name contains invalid characters'),\n\n /** Branch name validation - prevents command injection */\n branchName: z\n .string()\n .min(1, 'Branch name is required')\n .max(255, 'Branch name too long')\n .regex(\n /^[a-zA-Z0-9/_-]+$/,\n 'Branch name can only contain letters, numbers, slashes, hyphens, and underscores'\n )\n .refine((name) => !name.includes('..'), 'Branch name cannot contain \"..\"')\n .refine((name) => !/^[/\\\\]/.test(name), 'Branch name cannot start with path separators')\n .refine((name) => !/[<>:\"|?*$]/.test(name), 'Branch name contains invalid characters'),\n\n /** File path validation - prevents path traversal */\n filePath: z\n .string()\n .min(1, 'File path is required')\n .max(1000, 'File path too long')\n .refine(\n (filePath) => !filePath.includes('..'),\n 'File path cannot contain \"..\" for path traversal protection'\n )\n .refine((filePath) => !/^[<>:\"|?*]/.test(filePath), 'File path contains invalid characters'),\n\n /** Command argument validation - prevents command injection */\n commandArg: z\n .string()\n .max(1000, 'Command argument too long')\n .refine(\n (arg) => !/[<>|;&$`'\"\\\\]/.test(arg),\n 'Command argument contains potentially dangerous characters'\n ),\n\n /** Environment variable validation */\n envVarName: z\n .string()\n .regex(/^[A-Z_][A-Z0-9_]*$/, 'Invalid environment variable name format')\n .max(100, 'Environment variable name too long'),\n\n /** URL validation for API endpoints */\n url: z\n .string()\n .url('Invalid URL format')\n .refine(\n (url) => url.startsWith('https://') || url.startsWith('http://localhost'),\n 'URL must be HTTPS or localhost'\n )\n .refine((url) => !url.includes('javascript:'), 'URL cannot contain javascript protocol'),\n\n /** API key validation */\n apiKey: z\n .string()\n .min(10, 'API key too short')\n .max(500, 'API key too long')\n .regex(/^[a-zA-Z0-9._-]+$/, 'Invalid API key format'),\n};\n\n// ============================================================================\n// PATH SECURITY UTILITIES\n// ============================================================================\n\n/**\n * Secure path utilities to prevent path traversal attacks\n */\nexport const pathSecurity = {\n /**\n * Validates and sanitizes a file path to prevent path traversal\n */\n validatePath: (inputPath: string, allowedBase?: string): string => {\n const validated = securitySchemas.filePath.parse(inputPath);\n\n // Normalize the path\n const normalizedPath = path.normalize(validated);\n\n // Check for path traversal attempts\n if (normalizedPath.includes('..')) {\n throw new Error('Path traversal detected in file path');\n }\n\n // If base path is provided, ensure the resolved path is within bounds\n if (allowedBase) {\n const resolvedPath = path.resolve(allowedBase, normalizedPath);\n const resolvedBase = path.resolve(allowedBase);\n\n if (!resolvedPath.startsWith(resolvedBase)) {\n throw new Error('File path escapes allowed base directory');\n }\n\n return resolvedPath;\n }\n\n return normalizedPath;\n },\n\n /**\n * Checks if a path is within allowed boundaries\n */\n isPathSafe: (targetPath: string, allowedBase: string): boolean => {\n try {\n const resolvedTarget = path.resolve(targetPath);\n const resolvedBase = path.resolve(allowedBase);\n return resolvedTarget.startsWith(resolvedBase);\n } catch {\n return false;\n }\n },\n\n /**\n * Creates a safe file path within a base directory\n */\n safeJoin: (basePath: string, ...paths: string[]): string => {\n const result = path.join(basePath, ...paths);\n\n // Normalize and verify it stays within base\n const normalized = path.normalize(result);\n const resolvedBase = path.resolve(basePath);\n const resolvedResult = path.resolve(normalized);\n\n if (!resolvedResult.startsWith(resolvedBase)) {\n throw new Error('Path traversal attempt detected in safeJoin');\n }\n\n return resolvedResult;\n },\n};\n\n// ============================================================================\n// COMMAND EXECUTION SECURITY\n// ============================================================================\n\n/**\n * Secure command execution utilities to prevent command injection\n */\nexport const commandSecurity = {\n /**\n * Safely executes a command with arguments, preventing command injection\n */\n async safeExecFile(\n command: string,\n args: string[],\n options: {\n cwd?: string;\n timeout?: number;\n maxBuffer?: number;\n env?: Record<string, string>;\n } = {}\n ): Promise<{ stdout: string; stderr: string }> {\n // Validate command\n if (!/^[a-zA-Z0-9._-]+$/.test(command)) {\n throw new Error(`Invalid command: ${command}`);\n }\n\n // Validate arguments\n const validatedArgs = args.map((arg) => {\n try {\n return securitySchemas.commandArg.parse(arg);\n } catch (_error) {\n throw new Error(`Invalid command argument: ${arg}`);\n }\n });\n\n // Set secure defaults\n const secureOptions = {\n timeout: options.timeout || 30000, // 30 seconds default\n maxBuffer: options.maxBuffer || 1024 * 1024, // 1MB default\n env: { ...process.env, ...options.env },\n cwd: options.cwd || process.cwd(),\n shell: false, // Never use shell to prevent injection\n encoding: 'utf8' as const,\n };\n\n // Validate working directory\n if (secureOptions.cwd) {\n pathSecurity.validatePath(secureOptions.cwd);\n }\n\n try {\n return await execFileAsync(command, validatedArgs, secureOptions);\n } catch (error: any) {\n // Sanitize error message to prevent information disclosure\n const sanitizedError = new Error(`Command execution failed: ${command}`);\n sanitizedError.code = error.code;\n sanitizedError.signal = error.signal;\n throw sanitizedError;\n }\n },\n\n /**\n * Validates that a command argument is safe for execution\n */\n validateCommandArgs: (args: string[]): string[] => {\n return args.map((arg) => {\n const validated = securitySchemas.commandArg.parse(arg);\n\n // Additional checks for common injection patterns\n const dangerousPatterns = [\n /[;&|`'\"\\\\$()]/,\n /\\.\\./,\n /\\/etc\\//,\n /\\/proc\\//,\n /windows\\\\system32/i,\n ];\n\n for (const pattern of dangerousPatterns) {\n if (pattern.test(validated)) {\n throw new Error(`Dangerous pattern detected in command argument: ${arg}`);\n }\n }\n\n return validated;\n });\n },\n};\n\n// ============================================================================\n// INPUT SANITIZATION UTILITIES\n// ============================================================================\n\n/**\n * Input sanitization utilities\n */\nexport const sanitize = {\n /**\n * Sanitizes a string for safe display\n */\n string: (input: string, maxLength = 1000): string => {\n if (typeof input !== 'string') {\n throw new Error('Input must be a string');\n }\n\n // Remove null bytes and control characters except newlines and tabs\n const sanitized = input\n .replace(/[\\x00-\\x08\\x0B\\x0C\\x0E-\\x1F\\x7F]/g, '')\n .substring(0, maxLength);\n\n return sanitized;\n },\n\n /**\n * Sanitizes text for log messages (prevents log injection)\n */\n logMessage: (input: string): string => {\n return input\n .replace(/[\\r\\n]/g, ' ') // Remove line breaks\n .replace(/\\t/g, ' ') // Replace tabs with spaces\n .substring(0, 500); // Limit length\n },\n\n /**\n * Sanitizes user input for file names\n */\n fileName: (input: string): string => {\n return input\n .replace(/[^a-zA-Z0-9._-]/g, '_') // Replace invalid chars with underscores\n .replace(/_{2,}/g, '_') // Replace multiple underscores\n .replace(/^_|_$/g, '') // Remove leading/trailing underscores\n .toLowerCase();\n },\n\n /**\n * Sanitizes content for YAML front matter\n */\n yamlContent: (input: string): string => {\n // Basic YAML sanitization - remove potentially dangerous content\n return input\n .replace(/[\\x00-\\x08\\x0B\\x0C\\x0E-\\x1F\\x7F]/g, '')\n .replace(/<!\\[CDATA\\[.*?\\]\\]>/gs, '') // Remove CDATA sections\n .replace(/<script\\b[^<]*(?:(?!<\\/script>)<[^<]*)*<\\/script>/gi, ''); // Remove scripts\n },\n};\n\n// ============================================================================\n// ENVIRONMENT VARIABLE SECURITY\n// ============================================================================\n\n/**\n * Environment variable validation utilities\n */\nexport const envSecurity = {\n /**\n * Validates an environment variable name and value\n */\n validateEnvVar: (name: string, value?: string): { name: string; value: string } => {\n const validatedName = securitySchemas.envVarName.parse(name);\n\n if (value === undefined) {\n throw new Error(`Environment variable ${validatedName} is required but not set`);\n }\n\n // Validate based on variable type\n if (validatedName.includes('URL') || validatedName.includes('BASE_URL')) {\n securitySchemas.url.parse(value);\n } else if (validatedName.includes('KEY') || validatedName.includes('SECRET')) {\n // For keys, check minimum length and allowed characters\n if (value.length < 10) {\n throw new Error(`API key ${validatedName} is too short`);\n }\n }\n\n return { name: validatedName, value };\n },\n\n /**\n * Safely gets an environment variable with validation\n */\n getEnvVar: (name: string, defaultValue?: string): string | undefined => {\n try {\n const value = process.env[name];\n if (value === undefined) {\n if (defaultValue !== undefined) {\n return defaultValue;\n }\n throw new Error(`Environment variable ${name} is not set`);\n }\n\n const validated = envSecurity.validateEnvVar(name, value);\n return validated.value;\n } catch (error) {\n console.warn(`Environment variable validation failed for ${name}:`, error);\n return defaultValue;\n }\n },\n\n /**\n * Validates multiple environment variables\n */\n validateEnvVars: (\n vars: Record<string, { required?: boolean; schema?: z.ZodSchema }>\n ): Record<string, string> => {\n const result: Record<string, string> = {};\n\n for (const [name, config] of Object.entries(vars)) {\n const value = process.env[name];\n\n if (value === undefined) {\n if (config.required) {\n throw new Error(`Required environment variable ${name} is not set`);\n }\n continue;\n }\n\n try {\n // Use custom schema if provided, otherwise use default validation\n if (config.schema) {\n result[name] = config.schema.parse(value);\n } else {\n const validated = envSecurity.validateEnvVar(name, value);\n result[name] = validated.value;\n }\n } catch (error) {\n throw new Error(`Environment variable ${name} validation failed: ${error}`);\n }\n }\n\n return result;\n },\n};\n\n// ============================================================================\n// CRYPTOGRAPHIC UTILITIES\n// ============================================================================\n\n/**\n * Cryptographic utilities for security\n */\nexport const cryptoUtils = {\n /**\n * Generates a secure random string\n */\n generateSecureRandom: (length = 32): string => {\n return crypto.randomBytes(length).toString('hex');\n },\n\n /**\n * Generates a cryptographically secure random ID\n */\n generateSecureId: (): string => {\n const timestamp = Date.now().toString(36);\n const random = crypto.randomBytes(16).toString('hex');\n return `${timestamp}-${random}`;\n },\n\n /**\n * Creates a secure hash of data\n */\n hash: (data: string): string => {\n return crypto.createHash('sha256').update(data).digest('hex');\n },\n\n /**\n * Verifies data integrity with HMAC\n */\n verifyHMAC: (data: string, signature: string, secret: string): boolean => {\n const expectedSignature = crypto.createHmac('sha256', secret).update(data).digest('hex');\n\n return crypto.timingSafeEqual(\n Buffer.from(signature, 'hex'),\n Buffer.from(expectedSignature, 'hex')\n );\n },\n};\n\n// ============================================================================\n// RATE LIMITING UTILITIES\n// ============================================================================\n\n/**\n * Simple in-memory rate limiting\n */\nexport class RateLimiter {\n private requests: Map<string, number[]> = new Map();\n\n constructor(\n private maxRequests = 100,\n private windowMs = 60000 // 1 minute\n ) {}\n\n isAllowed(identifier: string): boolean {\n const now = Date.now();\n const windowStart = now - this.windowMs;\n\n // Get existing requests for this identifier\n let timestamps = this.requests.get(identifier) || [];\n\n // Remove old requests outside the window\n timestamps = timestamps.filter((timestamp) => timestamp > windowStart);\n\n // Check if limit exceeded\n if (timestamps.length >= this.maxRequests) {\n return false;\n }\n\n // Add current request\n timestamps.push(now);\n this.requests.set(identifier, timestamps);\n\n return true;\n }\n\n cleanup(): void {\n const now = Date.now();\n const windowStart = now - this.windowMs;\n\n for (const [identifier, timestamps] of this.requests.entries()) {\n const filtered = timestamps.filter((timestamp) => timestamp > windowStart);\n if (filtered.length === 0) {\n this.requests.delete(identifier);\n } else {\n this.requests.set(identifier, filtered);\n }\n }\n }\n}\n\n// ============================================================================\n// SECURITY MIDDLEWARE\n// ============================================================================\n\n/**\n * Security middleware for common patterns\n */\nexport const securityMiddleware = {\n /**\n * Rate limiting middleware\n */\n rateLimit: (limiter: RateLimiter, getIdentifier: (req: any) => string) => {\n return (req: any, res: any, next: any) => {\n const identifier = getIdentifier(req);\n\n if (!limiter.isAllowed(identifier)) {\n return res.status(429).json({ error: 'Too many requests' });\n }\n\n next();\n };\n },\n\n /**\n * Input validation middleware\n */\n validateInput: (schema: z.ZodSchema, source: 'body' | 'query' | 'params' = 'body') => {\n return (req: any, res: any, next: any) => {\n try {\n const data = req[source];\n const validated = schema.parse(data);\n req[source] = validated;\n next();\n } catch (error) {\n return res.status(400).json({ error: 'Invalid input', details: error });\n }\n };\n },\n};\n\nexport default {\n securitySchemas,\n pathSecurity,\n commandSecurity,\n sanitize,\n envSecurity,\n cryptoUtils,\n RateLimiter,\n securityMiddleware,\n};\n"
|
|
7
|
-
],
|
|
8
|
-
"mappings": "yCAYA,uBACA,yBACA,wBAAS,iBCTT,mBAAS,2BAET,yBACA,oBAAS,kBAGT,IAAM,EAAgB,EAAU,CAAQ,EAS3B,EAAkB,CAE7B,YAAa,EACV,OAAO,EACP,IAAI,EAAG,0BAA0B,EACjC,IAAI,IAAK,uBAAuB,EAChC,MACC,mBACA,0EACF,EACC,OAAO,CAAC,IAAS,CAAC,QAAQ,KAAK,CAAI,EAAG,kCAAkC,EACxE,OAAO,CAAC,IAAS,CAAC,YAAY,KAAK,CAAI,EAAG,0CAA0C,EAGvF,WAAY,EACT,OAAO,EACP,IAAI,EAAG,yBAAyB,EAChC,IAAI,IAAK,sBAAsB,EAC/B,MACC,oBACA,kFACF,EACC,OAAO,CAAC,IAAS,CAAC,EAAK,SAAS,IAAI,EAAG,iCAAiC,EACxE,OAAO,CAAC,IAAS,CAAC,SAAS,KAAK,CAAI,EAAG,+CAA+C,EACtF,OAAO,CAAC,IAAS,CAAC,aAAa,KAAK,CAAI,EAAG,yCAAyC,EAGvF,SAAU,EACP,OAAO,EACP,IAAI,EAAG,uBAAuB,EAC9B,IAAI,KAAM,oBAAoB,EAC9B,OACC,CAAC,IAAa,CAAC,EAAS,SAAS,IAAI,EACrC,6DACF,EACC,OAAO,CAAC,IAAa,CAAC,aAAa,KAAK,CAAQ,EAAG,uCAAuC,EAG7F,WAAY,EACT,OAAO,EACP,IAAI,KAAM,2BAA2B,EACrC,OACC,CAAC,IAAQ,CAAC,gBAAgB,KAAK,CAAG,EAClC,4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AAS,SAAS,GAAG,GAAK,EAAS,SAAS,IAAI,EAC7E,MAAU,MAAM,qBAAqB,gCAAuC,EAI9E,GAAI,CAAC,oBAAoB,KAAK,CAAQ,EACpC,MAAU,MAAM,yCAAyC,GAAU,EAIrE,IAAM,EAAW,EAAY,EACvB,EAAW,EAAa,SAAS,EAAU,CAAQ,EAEzD,GAAI,CAAC,EAAG,WAAW,CAAQ,EACzB,MAAU,MAAM,wBAAwB,gBAAuB,IAAW,EAG5E,OAAO",
|
|
9
|
-
"debugId": "B36B269C3826F9AF64756E2164756E21",
|
|
10
|
-
"names": []
|
|
11
|
-
}
|
package/dist/chunk-3m9whg4q.js
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{createRequire as k}from"node:module";var g=Object.create;var{getPrototypeOf:h,defineProperty:f,getOwnPropertyNames:i}=Object;var j=Object.prototype.hasOwnProperty;var l=(a,b,c)=>{c=a!=null?g(h(a)):{};let d=b||!a||!a.__esModule?f(c,"default",{value:a,enumerable:!0}):c;for(let e of i(a))if(!j.call(d,e))f(d,e,{get:()=>a[e],enumerable:!0});return d};var m=(a,b)=>()=>(b||a((b={exports:{}}).exports,b),b.exports);var n=(a,b)=>{for(var c in b)f(a,c,{get:b[c],enumerable:!0,configurable:!0,set:(d)=>b[c]=()=>d})};var p=k(import.meta.url);
|
|
2
|
-
export{l as Tb,m as Ub,n as Vb,p as Wb};
|
|
3
|
-
|
|
4
|
-
//# debugId=1090B4E729FE0A2764756E2164756E21
|