plan-flow-skill 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/.claude/commands/create-contract.md +468 -0
- package/.claude/commands/create-plan.md +512 -0
- package/.claude/commands/discovery-plan.md +561 -0
- package/.claude/commands/execute-plan.md +682 -0
- package/.claude/commands/review-code.md +459 -0
- package/.claude/commands/review-pr.md +651 -0
- package/.claude/commands/setup.md +1609 -0
- package/.claude/commands/write-tests.md +543 -0
- package/.claude/rules/core/allowed-patterns.md +175 -0
- package/.claude/rules/core/complexity-scoring.md +225 -0
- package/.claude/rules/core/forbidden-patterns.md +253 -0
- package/.claude/rules/languages/python-patterns.md +6 -0
- package/.claude/rules/languages/typescript-patterns.md +7 -0
- package/.claude/rules/patterns/contract-patterns.md +332 -0
- package/.claude/rules/patterns/discovery-patterns.md +342 -0
- package/.claude/rules/patterns/discovery-templates.md +319 -0
- package/.claude/rules/patterns/jest-patterns.md +482 -0
- package/.claude/rules/patterns/plans-patterns.md +225 -0
- package/.claude/rules/patterns/plans-templates.md +227 -0
- package/.claude/rules/patterns/pytest-patterns.md +457 -0
- package/.claude/rules/patterns/review-code-templates.md +305 -0
- package/.claude/rules/patterns/review-pr-patterns.md +360 -0
- package/.claude/rules/tools/auth-pr-tool.md +30 -0
- package/.claude/rules/tools/interactive-questions-tool.md +235 -0
- package/.claude/rules/tools/jest-testing-tool.md +73 -0
- package/.claude/rules/tools/plan-mode-tool.md +164 -0
- package/.claude/rules/tools/pytest-testing-tool.md +121 -0
- package/.claude/rules/tools/reference-expansion-tool.md +326 -0
- package/LICENSE +21 -0
- package/README.md +167 -0
- package/dist/cli/commands/init.d.ts +6 -0
- package/dist/cli/commands/init.d.ts.map +1 -0
- package/dist/cli/commands/init.js +139 -0
- package/dist/cli/commands/init.js.map +1 -0
- package/dist/cli/handlers/claude.d.ts +9 -0
- package/dist/cli/handlers/claude.d.ts.map +1 -0
- package/dist/cli/handlers/claude.js +119 -0
- package/dist/cli/handlers/claude.js.map +1 -0
- package/dist/cli/handlers/codex.d.ts +9 -0
- package/dist/cli/handlers/codex.d.ts.map +1 -0
- package/dist/cli/handlers/codex.js +100 -0
- package/dist/cli/handlers/codex.js.map +1 -0
- package/dist/cli/handlers/cursor.d.ts +8 -0
- package/dist/cli/handlers/cursor.d.ts.map +1 -0
- package/dist/cli/handlers/cursor.js +34 -0
- package/dist/cli/handlers/cursor.js.map +1 -0
- package/dist/cli/handlers/openclaw.d.ts +8 -0
- package/dist/cli/handlers/openclaw.d.ts.map +1 -0
- package/dist/cli/handlers/openclaw.js +34 -0
- package/dist/cli/handlers/openclaw.js.map +1 -0
- package/dist/cli/handlers/shared.d.ts +9 -0
- package/dist/cli/handlers/shared.d.ts.map +1 -0
- package/dist/cli/handlers/shared.js +44 -0
- package/dist/cli/handlers/shared.js.map +1 -0
- package/dist/cli/index.d.ts +8 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +43 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/types.d.ts +26 -0
- package/dist/cli/types.d.ts.map +1 -0
- package/dist/cli/types.js +5 -0
- package/dist/cli/types.js.map +1 -0
- package/dist/cli/utils/files.d.ts +37 -0
- package/dist/cli/utils/files.d.ts.map +1 -0
- package/dist/cli/utils/files.js +122 -0
- package/dist/cli/utils/files.js.map +1 -0
- package/dist/cli/utils/logger.d.ts +11 -0
- package/dist/cli/utils/logger.d.ts.map +1 -0
- package/dist/cli/utils/logger.js +34 -0
- package/dist/cli/utils/logger.js.map +1 -0
- package/dist/cli/utils/prompts.d.ts +10 -0
- package/dist/cli/utils/prompts.d.ts.map +1 -0
- package/dist/cli/utils/prompts.js +65 -0
- package/dist/cli/utils/prompts.js.map +1 -0
- package/dist/test/setup.d.ts +5 -0
- package/dist/test/setup.d.ts.map +1 -0
- package/dist/test/setup.js +7 -0
- package/dist/test/setup.js.map +1 -0
- package/package.json +63 -0
- package/rules/core/_index.mdc +89 -0
- package/rules/core/allowed-patterns.mdc +185 -0
- package/rules/core/complexity-scoring.mdc +235 -0
- package/rules/core/forbidden-patterns.mdc +263 -0
- package/rules/languages/_index.mdc +80 -0
- package/rules/languages/python-patterns.mdc +188 -0
- package/rules/languages/typescript-patterns.mdc +128 -0
- package/rules/patterns/_index.mdc +185 -0
- package/rules/patterns/contract-patterns.mdc +344 -0
- package/rules/patterns/discovery-patterns.mdc +354 -0
- package/rules/patterns/discovery-templates.mdc +329 -0
- package/rules/patterns/jest-patterns.mdc +492 -0
- package/rules/patterns/plans-patterns.mdc +237 -0
- package/rules/patterns/plans-templates.mdc +237 -0
- package/rules/patterns/pytest-patterns.mdc +467 -0
- package/rules/patterns/review-code-templates.mdc +315 -0
- package/rules/patterns/review-pr-patterns.mdc +370 -0
- package/rules/skills/_index.mdc +174 -0
- package/rules/skills/create-contract-skill.mdc +239 -0
- package/rules/skills/create-plan-skill.mdc +271 -0
- package/rules/skills/discovery-skill.mdc +295 -0
- package/rules/skills/execute-plan-skill.mdc +388 -0
- package/rules/skills/review-code-skill.mdc +308 -0
- package/rules/skills/review-pr-skill.mdc +496 -0
- package/rules/skills/setup-skill.mdc +923 -0
- package/rules/skills/write-tests-skill.mdc +294 -0
- package/rules/templates/index-template.mdc +126 -0
- package/rules/tools/_index.mdc +114 -0
- package/rules/tools/auth-pr-tool.mdc +362 -0
- package/rules/tools/interactive-questions-tool.mdc +337 -0
- package/rules/tools/jest-testing-tool.mdc +96 -0
- package/rules/tools/plan-mode-tool.mdc +229 -0
- package/rules/tools/pytest-testing-tool.mdc +144 -0
- package/rules/tools/reference-expansion-tool.mdc +338 -0
- package/skills/plan-flow/SKILL.md +109 -0
- package/skills/plan-flow/create-contract/SKILL.md +139 -0
- package/skills/plan-flow/create-plan/SKILL.md +93 -0
- package/skills/plan-flow/discovery/SKILL.md +85 -0
- package/skills/plan-flow/execute-plan/SKILL.md +89 -0
- package/skills/plan-flow/review-code/SKILL.md +100 -0
- package/skills/plan-flow/review-pr/SKILL.md +122 -0
- package/skills/plan-flow/setup/SKILL.md +73 -0
- package/skills/plan-flow/write-tests/SKILL.md +115 -0
- package/templates/shared/AGENTS.md.template +60 -0
- package/templates/shared/CLAUDE.md.template +62 -0
|
@@ -0,0 +1,362 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: "Include when PR authentication is needed for GitHub or Azure DevOps access"
|
|
3
|
+
alwaysApply: false
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# PR Authentication Tool
|
|
7
|
+
|
|
8
|
+
## Purpose
|
|
9
|
+
|
|
10
|
+
Provides authentication mechanism for accessing Pull Requests from GitHub or Azure DevOps using Personal Access Tokens (PATs). This tool handles platform detection, credential loading, authentication, and access verification.
|
|
11
|
+
|
|
12
|
+
## Usage
|
|
13
|
+
|
|
14
|
+
This tool can be used by skills or commands that need to authenticate and access PRs from GitHub or Azure DevOps.
|
|
15
|
+
|
|
16
|
+
**Example**: Used by the `review-pr` skill to authenticate before fetching PR information.
|
|
17
|
+
|
|
18
|
+
## Inputs
|
|
19
|
+
|
|
20
|
+
| Input | Required | Description |
|
|
21
|
+
| ---------- | -------- | ------------------------------------------------ |
|
|
22
|
+
| `pr_link` | Yes | The URL of the Pull Request |
|
|
23
|
+
|
|
24
|
+
The tool automatically detects the platform from the PR URL:
|
|
25
|
+
- **GitHub**: URLs contain `github.com`
|
|
26
|
+
- **Azure DevOps**: URLs contain `dev.azure.com` or `visualstudio.com`
|
|
27
|
+
|
|
28
|
+
## Configuration
|
|
29
|
+
|
|
30
|
+
### Environment Variables
|
|
31
|
+
|
|
32
|
+
Store authentication tokens in `.plan.flow.env` (this file is gitignored for security):
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
# GitHub Authentication
|
|
36
|
+
GITHUB_TOKEN=ghp_your_token_here
|
|
37
|
+
|
|
38
|
+
# Azure DevOps Authentication
|
|
39
|
+
AZURE_DEVOPS_PAT=your_pat_here
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Workflow
|
|
43
|
+
|
|
44
|
+
### Step 1: Detect Platform
|
|
45
|
+
|
|
46
|
+
Analyze the PR URL to determine the platform:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
# Extract platform from PR URL
|
|
50
|
+
# GitHub: github.com
|
|
51
|
+
# Azure DevOps: dev.azure.com or visualstudio.com
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### Step 2: Load Credentials from `.plan.flow.env` (REQUIRED FIRST STEP)
|
|
55
|
+
|
|
56
|
+
**ALWAYS start by reading the `.plan.flow.env` file:**
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
# Read .plan.flow.env and extract credentials
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
| Platform | Environment Variable | Purpose |
|
|
63
|
+
| ------------ | -------------------- | ------------------------------------------------- |
|
|
64
|
+
| GitHub | `GITHUB_TOKEN` | GitHub Personal Access Token |
|
|
65
|
+
| Azure DevOps | `AZURE_DEVOPS_PAT` | Azure DevOps Personal Access Token |
|
|
66
|
+
|
|
67
|
+
### Step 3: Authenticate Using Credentials
|
|
68
|
+
|
|
69
|
+
#### For GitHub PRs:
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
# Authenticate using token from .plan.flow.env
|
|
73
|
+
echo "$GITHUB_TOKEN" | gh auth login --with-token
|
|
74
|
+
|
|
75
|
+
# Verify authentication
|
|
76
|
+
gh auth status
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
#### For Azure DevOps PRs:
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
# Set the PAT for Azure DevOps CLI
|
|
83
|
+
export AZURE_DEVOPS_EXT_PAT="$AZURE_DEVOPS_PAT"
|
|
84
|
+
|
|
85
|
+
# Or use directly in curl requests with Basic Auth
|
|
86
|
+
curl -u ":$AZURE_DEVOPS_PAT" "https://dev.azure.com/{org}/{project}/_apis/git/pullrequests/{pr_id}?api-version=7.0"
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
**Alternative method using curl with Bearer token:**
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
# Azure DevOps API call using PAT
|
|
93
|
+
curl -H "Authorization: Basic $(echo -n ":$AZURE_DEVOPS_PAT" | base64)" \
|
|
94
|
+
"https://dev.azure.com/{org}/{project}/_apis/git/pullrequests/{pr_id}?api-version=7.0"
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### Step 4: Verify Access
|
|
98
|
+
|
|
99
|
+
Test that the credentials work by fetching the PR:
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
# For GitHub
|
|
103
|
+
gh pr view {pr_number} --repo {owner/repo}
|
|
104
|
+
|
|
105
|
+
# For Azure DevOps (using curl with PAT)
|
|
106
|
+
curl -s -u ":$AZURE_DEVOPS_PAT" \
|
|
107
|
+
"https://dev.azure.com/{org}/{project}/_apis/git/pullrequests/{pr_id}?api-version=7.0"
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### Step 5: Handle Missing or Invalid Credentials
|
|
111
|
+
|
|
112
|
+
**ONLY if `.plan.flow.env` credentials are missing or empty**, inform the user:
|
|
113
|
+
|
|
114
|
+
```
|
|
115
|
+
⚠️ Credentials not found in .plan.flow.env
|
|
116
|
+
|
|
117
|
+
Please add your credentials to .plan.flow.env:
|
|
118
|
+
|
|
119
|
+
For GitHub:
|
|
120
|
+
GITHUB_TOKEN=ghp_your_token_here
|
|
121
|
+
|
|
122
|
+
For Azure DevOps:
|
|
123
|
+
AZURE_DEVOPS_PAT=your_pat_here
|
|
124
|
+
|
|
125
|
+
See .example.plan.flow.env for the template.
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
**If authentication fails:**
|
|
129
|
+
|
|
130
|
+
```
|
|
131
|
+
⚠️ Authentication failed
|
|
132
|
+
|
|
133
|
+
Please verify your credentials in .plan.flow.env are valid.
|
|
134
|
+
|
|
135
|
+
For GitHub:
|
|
136
|
+
- Check your GITHUB_TOKEN is valid
|
|
137
|
+
- Create a new token at: https://github.com/settings/tokens
|
|
138
|
+
|
|
139
|
+
For Azure DevOps:
|
|
140
|
+
- Check your AZURE_DEVOPS_PAT is valid
|
|
141
|
+
- Create a new token at: https://dev.azure.com/{org}/_usersSettings/tokens
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
## Authentication Methods
|
|
145
|
+
|
|
146
|
+
### GitHub Authentication
|
|
147
|
+
|
|
148
|
+
#### Method 1: GitHub CLI (gh) - Recommended
|
|
149
|
+
|
|
150
|
+
```bash
|
|
151
|
+
# Authenticate using token from .plan.flow.env
|
|
152
|
+
echo "$GITHUB_TOKEN" | gh auth login --with-token
|
|
153
|
+
|
|
154
|
+
# Verify access
|
|
155
|
+
gh auth status
|
|
156
|
+
|
|
157
|
+
# Use gh commands
|
|
158
|
+
gh pr view {pr_number} --repo {owner/repo}
|
|
159
|
+
gh api repos/{owner}/{repo}/pulls/{pr_number}
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
#### Method 2: Direct API Calls with curl
|
|
163
|
+
|
|
164
|
+
```bash
|
|
165
|
+
curl -H "Authorization: token $GITHUB_TOKEN" \
|
|
166
|
+
-H "Accept: application/vnd.github.v3+json" \
|
|
167
|
+
"https://api.github.com/repos/{owner}/{repo}/pulls/{pr_number}"
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
### Azure DevOps Authentication
|
|
171
|
+
|
|
172
|
+
#### Method 1: Azure DevOps CLI (az)
|
|
173
|
+
|
|
174
|
+
```bash
|
|
175
|
+
# Set PAT for Azure DevOps CLI
|
|
176
|
+
export AZURE_DEVOPS_EXT_PAT="$AZURE_DEVOPS_PAT"
|
|
177
|
+
|
|
178
|
+
# Use az commands
|
|
179
|
+
az repos pr show --id {pr_id} --organization {org} --project {project}
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
#### Method 2: Direct API Calls with curl (Basic Auth)
|
|
183
|
+
|
|
184
|
+
```bash
|
|
185
|
+
# Using Basic Auth with PAT
|
|
186
|
+
curl -u ":$AZURE_DEVOPS_PAT" \
|
|
187
|
+
"https://dev.azure.com/{org}/{project}/_apis/git/pullrequests/{pr_id}?api-version=7.0"
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
#### Method 3: Direct API Calls with curl (Bearer Token)
|
|
191
|
+
|
|
192
|
+
```bash
|
|
193
|
+
# Using Bearer token
|
|
194
|
+
curl -H "Authorization: Basic $(echo -n ":$AZURE_DEVOPS_PAT" | base64)" \
|
|
195
|
+
-H "Content-Type: application/json" \
|
|
196
|
+
"https://dev.azure.com/{org}/{project}/_apis/git/pullrequests/{pr_id}?api-version=7.0"
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
## Allowed Commands
|
|
200
|
+
|
|
201
|
+
### GitHub Commands
|
|
202
|
+
|
|
203
|
+
| Allowed Action | Purpose |
|
|
204
|
+
| ---------------------------- | -------------------------------------------- |
|
|
205
|
+
| `gh auth status` | Check authentication status |
|
|
206
|
+
| `gh auth login --with-token` | Authenticate using PAT from `.plan.flow.env` |
|
|
207
|
+
| `gh pr view` | Read PR information |
|
|
208
|
+
| `gh pr diff` | Read PR diff/changes |
|
|
209
|
+
| `gh pr files` | List files changed in PR |
|
|
210
|
+
| `gh api` (GET requests only) | Fetch additional PR data |
|
|
211
|
+
|
|
212
|
+
### Azure DevOps Commands
|
|
213
|
+
|
|
214
|
+
| Allowed Action | Purpose |
|
|
215
|
+
| ----------------------------------------------------- | --------------------------------------- |
|
|
216
|
+
| `az devops configure` | Configure Azure DevOps defaults |
|
|
217
|
+
| `az devops invoke --area git --resource pullRequests` | Fetch PR details |
|
|
218
|
+
| `az devops invoke --area git --resource blobs` | Fetch file contents |
|
|
219
|
+
| `az devops invoke --area git --resource diffs` | Fetch PR diff |
|
|
220
|
+
| `az devops invoke --area git --resource commits` | Fetch commit information |
|
|
221
|
+
| `az repos pr show` | Show PR details |
|
|
222
|
+
| `az repos pr list` | List PRs (for finding existing reviews) |
|
|
223
|
+
| `curl` with GET + PAT auth | Direct API calls to Azure DevOps |
|
|
224
|
+
|
|
225
|
+
## Security Notes
|
|
226
|
+
|
|
227
|
+
- **NEVER** commit `.plan.flow.env` to version control
|
|
228
|
+
- **NEVER** use browser authentication or interactive login (`gh auth login`) in automated contexts
|
|
229
|
+
- **ALWAYS** use PAT from `.plan.flow.env` for programmatic access
|
|
230
|
+
- **ALWAYS** try `.plan.flow.env` credentials FIRST before any other method
|
|
231
|
+
- Tokens should have minimal required scopes for the operation
|
|
232
|
+
|
|
233
|
+
## Required Scopes
|
|
234
|
+
|
|
235
|
+
### GitHub
|
|
236
|
+
|
|
237
|
+
Common scopes needed:
|
|
238
|
+
|
|
239
|
+
- `repo` - Full control of private repositories (for private repos)
|
|
240
|
+
- `public_repo` - Access public repositories (for public repos)
|
|
241
|
+
- `read:org` - Read org membership (if reviewing org repos)
|
|
242
|
+
|
|
243
|
+
### Azure DevOps
|
|
244
|
+
|
|
245
|
+
Common scopes needed:
|
|
246
|
+
|
|
247
|
+
- `Code (read)` - Read code and pull requests
|
|
248
|
+
- `Code (read & write)` - Read and write code (if needed)
|
|
249
|
+
- `Pull Request Threads (read & write)` - Read and write PR comments (if needed)
|
|
250
|
+
|
|
251
|
+
## Example Usage in Skills/Commands
|
|
252
|
+
|
|
253
|
+
```markdown
|
|
254
|
+
### Step 0: Authenticate for PR Access
|
|
255
|
+
|
|
256
|
+
Use the PR authentication tool:
|
|
257
|
+
|
|
258
|
+
1. Provide PR URL: `{pr_link}`
|
|
259
|
+
2. Tool detects platform (GitHub or Azure DevOps)
|
|
260
|
+
3. Tool loads credentials from `.plan.flow.env`
|
|
261
|
+
4. Tool authenticates using appropriate method
|
|
262
|
+
5. Tool verifies access by fetching PR
|
|
263
|
+
|
|
264
|
+
After authentication, you can proceed to fetch PR information.
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
## Error Handling
|
|
268
|
+
|
|
269
|
+
### Missing Credentials
|
|
270
|
+
|
|
271
|
+
If credentials are not found in `.plan.flow.env`:
|
|
272
|
+
|
|
273
|
+
```
|
|
274
|
+
⚠️ Credentials not found in .plan.flow.env
|
|
275
|
+
|
|
276
|
+
Please add your credentials to .plan.flow.env:
|
|
277
|
+
|
|
278
|
+
For GitHub:
|
|
279
|
+
GITHUB_TOKEN=ghp_your_token_here
|
|
280
|
+
|
|
281
|
+
For Azure DevOps:
|
|
282
|
+
AZURE_DEVOPS_PAT=your_pat_here
|
|
283
|
+
|
|
284
|
+
See .example.plan.flow.env for the template.
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
### Invalid Credentials
|
|
288
|
+
|
|
289
|
+
If authentication fails:
|
|
290
|
+
|
|
291
|
+
```
|
|
292
|
+
⚠️ Authentication failed
|
|
293
|
+
|
|
294
|
+
Please verify your credentials in .plan.flow.env are valid.
|
|
295
|
+
|
|
296
|
+
For GitHub:
|
|
297
|
+
- Check your GITHUB_TOKEN is valid
|
|
298
|
+
- Create a new token at: https://github.com/settings/tokens
|
|
299
|
+
|
|
300
|
+
For Azure DevOps:
|
|
301
|
+
- Check your AZURE_DEVOPS_PAT is valid
|
|
302
|
+
- Create a new token at: https://dev.azure.com/{org}/_usersSettings/tokens
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
### Platform Detection Failure
|
|
306
|
+
|
|
307
|
+
If the platform cannot be determined from the URL:
|
|
308
|
+
|
|
309
|
+
```
|
|
310
|
+
⚠️ Unable to determine platform from PR URL
|
|
311
|
+
|
|
312
|
+
Please provide a valid PR URL from:
|
|
313
|
+
- GitHub: https://github.com/{owner}/{repo}/pull/{number}
|
|
314
|
+
- Azure DevOps: https://dev.azure.com/{org}/{project}/_git/{repo}/pullrequest/{id}
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
## Output
|
|
318
|
+
|
|
319
|
+
After successful authentication, the tool provides:
|
|
320
|
+
|
|
321
|
+
- **Platform**: Detected platform (GitHub or Azure DevOps)
|
|
322
|
+
- **Authentication Status**: Confirmed authenticated
|
|
323
|
+
- **Ready for PR Operations**: Can now fetch PR information, diffs, files, etc.
|
|
324
|
+
|
|
325
|
+
## Related Files
|
|
326
|
+
|
|
327
|
+
| File | Purpose |
|
|
328
|
+
| ------------------------------- | ------------------------------------ |
|
|
329
|
+
| `.plan.flow.env` | Authentication tokens (gitignored) |
|
|
330
|
+
| `.example.plan.flow.env` | Example env file template |
|
|
331
|
+
|
|
332
|
+
---
|
|
333
|
+
|
|
334
|
+
## Examples
|
|
335
|
+
|
|
336
|
+
For detailed error handling examples, see the Error Handling section above.
|
|
337
|
+
|
|
338
|
+
### Correct Usage (GOOD)
|
|
339
|
+
|
|
340
|
+
```bash
|
|
341
|
+
# Always load credentials from .plan.flow.env first
|
|
342
|
+
source .plan.flow.env
|
|
343
|
+
|
|
344
|
+
# Then authenticate using the loaded token
|
|
345
|
+
echo "$GITHUB_TOKEN" | gh auth login --with-token
|
|
346
|
+
|
|
347
|
+
# Verify access before proceeding
|
|
348
|
+
gh auth status
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
### Incorrect Usage (BAD - NEVER Do This)
|
|
352
|
+
|
|
353
|
+
```bash
|
|
354
|
+
# BAD - Using interactive login
|
|
355
|
+
gh auth login # Never use interactive login in automated contexts
|
|
356
|
+
|
|
357
|
+
# BAD - Hardcoding tokens
|
|
358
|
+
GITHUB_TOKEN="ghp_hardcoded_token" # Never hardcode tokens
|
|
359
|
+
|
|
360
|
+
# BAD - Skipping .plan.flow.env
|
|
361
|
+
gh auth login --with-token <<< "ghp_token" # Always use .plan.flow.env
|
|
362
|
+
```
|
|
@@ -0,0 +1,337 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: "Include when multiple-choice questions need to be asked via Plan mode's Questions UI"
|
|
3
|
+
alwaysApply: false
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Interactive Questions Tool
|
|
7
|
+
|
|
8
|
+
## Purpose
|
|
9
|
+
|
|
10
|
+
Provides a standardized way to ask interactive questions using Plan mode's Questions UI. This tool automatically switches to Plan mode, presents questions via the Questions UI, waits for user responses, and switches back to Agent mode.
|
|
11
|
+
|
|
12
|
+
## Usage
|
|
13
|
+
|
|
14
|
+
This tool is used by:
|
|
15
|
+
- Commands that need to gather information from users (e.g., `discovery-plan`, `create-plan`)
|
|
16
|
+
- Skills that require user input before proceeding
|
|
17
|
+
- Any process that needs interactive question-answer sessions
|
|
18
|
+
|
|
19
|
+
**Example**: Used by the `discovery-plan` command to ask clarifying questions about requirements.
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## How to Use Interactive Questions
|
|
24
|
+
|
|
25
|
+
**⚠️ CRITICAL INSTRUCTION**: You must **ACTUALLY CALL** the tools using the tool calling mechanism. Do NOT write text describing what you would do. Do NOT say "Switching to Plan mode" or "I will switch". **ACTUALLY INVOKE** the `SwitchMode` and `AskQuestion` tools. If you cannot call the tools, use the fallback instructions provided.
|
|
26
|
+
|
|
27
|
+
**MANDATORY WORKFLOW**:
|
|
28
|
+
|
|
29
|
+
1. **IMMEDIATELY CALL** `SwitchMode` tool to enter Plan mode (auto-switch, no asking) - **ACTUALLY CALL THE TOOL, DO NOT DESCRIBE IT**
|
|
30
|
+
2. **IMMEDIATELY CALL** `AskQuestion` tool for each question - **ACTUALLY CALL THE TOOL, DO NOT DESCRIBE IT**
|
|
31
|
+
3. Wait for responses
|
|
32
|
+
4. **IMMEDIATELY CALL** `SwitchMode` tool to return to Agent mode (auto-switch, no asking) - **ACTUALLY CALL THE TOOL, DO NOT DESCRIBE IT**
|
|
33
|
+
|
|
34
|
+
**CRITICAL**: You must use the tool calling mechanism to invoke these tools. Do not write text describing what you would do. Actually make the tool calls.
|
|
35
|
+
|
|
36
|
+
**DO NOT check if tools are available. DO NOT ask permission. DO NOT describe the action. Just call the tools directly.**
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
### Step 1: Automatically Switch to Plan Mode
|
|
41
|
+
|
|
42
|
+
**MANDATORY - AUTO-SWITCH**: Before asking questions, **IMMEDIATELY CALL** the `SwitchMode` tool to switch to Plan mode. Do not describe switching. Do not say "Switching to Plan mode". **ACTUALLY CALL THE TOOL**. Do not ask the user if they want to switch - just call the tool:
|
|
43
|
+
|
|
44
|
+
**YOU MUST ACTUALLY CALL THIS TOOL - DO NOT JUST DESCRIBE IT**:
|
|
45
|
+
|
|
46
|
+
```
|
|
47
|
+
SwitchMode(target_mode_id: "plan", explanation: "Discovery phase: Gathering requirements via interactive questions")
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
**CRITICAL**: You must use the tool calling mechanism to invoke `SwitchMode`. Do not write text saying you're switching. Actually make the tool call.
|
|
51
|
+
|
|
52
|
+
**Parameters**:
|
|
53
|
+
- `target_mode_id`: Always `"plan"` for Plan mode
|
|
54
|
+
- `explanation`: Brief description of why switching (include context about what questions will be asked)
|
|
55
|
+
|
|
56
|
+
**Example Usage**:
|
|
57
|
+
|
|
58
|
+
```
|
|
59
|
+
// For discovery questions
|
|
60
|
+
SwitchMode(target_mode_id: "plan", explanation: "Discovery phase: Gathering requirements via interactive questions")
|
|
61
|
+
|
|
62
|
+
// For contract creation questions
|
|
63
|
+
SwitchMode(target_mode_id: "plan", explanation: "Contract creation: Asking clarifying questions about integration scope")
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
**Fallback (if SwitchMode tool not available)**:
|
|
67
|
+
If the `SwitchMode` tool is not available or the tool call fails, provide clear instructions to the user:
|
|
68
|
+
|
|
69
|
+
```markdown
|
|
70
|
+
## Switching to Plan Mode
|
|
71
|
+
|
|
72
|
+
**Action Required**: Please switch to Plan mode to proceed with questions.
|
|
73
|
+
|
|
74
|
+
**Context**: [Context description]
|
|
75
|
+
|
|
76
|
+
Once in Plan mode, I will present questions via the Questions UI.
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
**After switching to Plan mode (or providing instructions), proceed immediately to Step 2.**
|
|
80
|
+
|
|
81
|
+
---
|
|
82
|
+
|
|
83
|
+
### Step 2: Ask Questions Using AskQuestion Tool
|
|
84
|
+
|
|
85
|
+
**MANDATORY**: After entering Plan mode, **IMMEDIATELY CALL** the `AskQuestion` tool for each question. Do NOT check if it's available. Do NOT use text format if the tool is available. **ACTUALLY CALL THE TOOL** - do not just describe asking questions. Just call the tool directly.
|
|
86
|
+
|
|
87
|
+
**Question Topics**:
|
|
88
|
+
- **Functional Requirements**: What the feature must do
|
|
89
|
+
- **Non-Functional Requirements**: Performance, security, scalability
|
|
90
|
+
- **Technical Questions**: Architecture, dependencies, patterns
|
|
91
|
+
- **UI/UX Questions**: User experience, design considerations
|
|
92
|
+
|
|
93
|
+
**Question Format**:
|
|
94
|
+
|
|
95
|
+
```
|
|
96
|
+
AskQuestion({
|
|
97
|
+
question: "What is the primary user action for this feature?",
|
|
98
|
+
options: [
|
|
99
|
+
"A. Create new items",
|
|
100
|
+
"B. View existing items",
|
|
101
|
+
"C. Edit existing items",
|
|
102
|
+
"D. Delete items",
|
|
103
|
+
"E. All of the above"
|
|
104
|
+
],
|
|
105
|
+
explanation: "Understanding the core functionality helps scope the implementation"
|
|
106
|
+
})
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
**Parameters**:
|
|
110
|
+
- `question`: The question text (clear and specific)
|
|
111
|
+
- `options`: Array of multiple-choice options (2-6 options recommended)
|
|
112
|
+
- `explanation`: Optional context for why this question is being asked
|
|
113
|
+
|
|
114
|
+
**Best Practices**:
|
|
115
|
+
- Use 2-6 options per question
|
|
116
|
+
- Make options mutually exclusive when possible
|
|
117
|
+
- Use clear labels (A, B, C, etc.)
|
|
118
|
+
- Keep questions focused on one topic
|
|
119
|
+
- Provide context in the explanation
|
|
120
|
+
|
|
121
|
+
**Important**:
|
|
122
|
+
- Ask all questions in one Plan mode session
|
|
123
|
+
- Wait for each response before asking the next question
|
|
124
|
+
- Use 2-6 options per question
|
|
125
|
+
- Label options with A, B, C, D, E, F
|
|
126
|
+
|
|
127
|
+
**Fallback (if AskQuestion tool not available)**:
|
|
128
|
+
If the `AskQuestion` tool is not available, use this text format:
|
|
129
|
+
|
|
130
|
+
```markdown
|
|
131
|
+
## Questions
|
|
132
|
+
|
|
133
|
+
1. What is the primary user action for this feature?
|
|
134
|
+
A. Create new items
|
|
135
|
+
B. View existing items
|
|
136
|
+
C. Edit existing items
|
|
137
|
+
D. Delete items
|
|
138
|
+
E. All of the above
|
|
139
|
+
|
|
140
|
+
2. Should this feature support real-time updates?
|
|
141
|
+
A. Yes, real-time updates required
|
|
142
|
+
B. No, periodic refresh is sufficient
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
**Wait for user responses before proceeding to the next question.**
|
|
146
|
+
|
|
147
|
+
---
|
|
148
|
+
|
|
149
|
+
### Step 3: Wait for All Responses
|
|
150
|
+
|
|
151
|
+
**DO NOT** continue until the user has answered all questions via the Questions UI (or text responses if using fallback).
|
|
152
|
+
|
|
153
|
+
**If user doesn't respond**:
|
|
154
|
+
1. Wait a reasonable amount of time
|
|
155
|
+
2. Gently remind about pending questions
|
|
156
|
+
3. Offer to continue with assumptions (clearly marked)
|
|
157
|
+
4. Only proceed if user explicitly agrees to assumptions
|
|
158
|
+
|
|
159
|
+
---
|
|
160
|
+
|
|
161
|
+
### Step 4: Process Responses
|
|
162
|
+
|
|
163
|
+
After receiving all responses:
|
|
164
|
+
|
|
165
|
+
1. **Extract the selected options** (A, B, C, etc.) from each question
|
|
166
|
+
2. **Map them to corresponding answers** (e.g., "A" → "Create new items")
|
|
167
|
+
3. **Document the answers** appropriately
|
|
168
|
+
4. **Use the answers** to inform next steps
|
|
169
|
+
|
|
170
|
+
---
|
|
171
|
+
|
|
172
|
+
### Step 5: Automatically Switch Back to Agent Mode
|
|
173
|
+
|
|
174
|
+
**MANDATORY - AUTO-SWITCH**: After all questions are answered, **IMMEDIATELY CALL** the `SwitchMode` tool to switch back to Agent mode. Do not describe switching. Do not say "Switching back to Agent mode". **ACTUALLY CALL THE TOOL**. Do not ask the user if they want to switch - just call the tool:
|
|
175
|
+
|
|
176
|
+
**YOU MUST ACTUALLY CALL THIS TOOL - DO NOT JUST DESCRIBE IT**:
|
|
177
|
+
|
|
178
|
+
```
|
|
179
|
+
SwitchMode(target_mode_id: "agent", explanation: "Discovery questions complete, returning to Agent mode")
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
**CRITICAL**: You must use the tool calling mechanism to invoke `SwitchMode`. Do not write text saying you're switching. Actually make the tool call.
|
|
183
|
+
|
|
184
|
+
**Fallback (if SwitchMode tool not available)**:
|
|
185
|
+
If the `SwitchMode` tool is not available or the tool call fails, provide clear instructions:
|
|
186
|
+
|
|
187
|
+
```markdown
|
|
188
|
+
## Returning to Agent Mode
|
|
189
|
+
|
|
190
|
+
**Action Required**: Please switch back to Agent mode to continue.
|
|
191
|
+
|
|
192
|
+
All questions have been answered. I will now proceed with the next steps.
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
---
|
|
196
|
+
|
|
197
|
+
## Complete Workflow Example
|
|
198
|
+
|
|
199
|
+
```markdown
|
|
200
|
+
## Gathering Requirements via Interactive Questions
|
|
201
|
+
|
|
202
|
+
**Step 1**: [SwitchMode tool called - actually invoked, not described]
|
|
203
|
+
|
|
204
|
+
**Step 2**: [AskQuestion tool called for Question 1 - actually invoked]
|
|
205
|
+
**Question 1**: What is the primary user action?
|
|
206
|
+
- A. Create new items
|
|
207
|
+
- B. View existing items
|
|
208
|
+
- C. Edit existing items
|
|
209
|
+
- D. Delete items
|
|
210
|
+
|
|
211
|
+
[User selects: B]
|
|
212
|
+
|
|
213
|
+
[AskQuestion tool called for Question 2 - actually invoked]
|
|
214
|
+
**Question 2**: Should this feature support real-time updates?
|
|
215
|
+
- A. Yes, real-time updates required
|
|
216
|
+
- B. No, periodic refresh is sufficient
|
|
217
|
+
|
|
218
|
+
[User selects: A]
|
|
219
|
+
|
|
220
|
+
**Step 3**: All questions answered. [SwitchMode tool called to return to Agent mode - actually invoked]
|
|
221
|
+
|
|
222
|
+
**Step 4**: Processing responses...
|
|
223
|
+
- Primary action: View existing items
|
|
224
|
+
- Real-time updates: Required
|
|
225
|
+
|
|
226
|
+
**Step 5**: Continuing with next steps based on answers...
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
---
|
|
230
|
+
|
|
231
|
+
## When to Use Interactive Questions
|
|
232
|
+
|
|
233
|
+
### Use For:
|
|
234
|
+
|
|
235
|
+
1. **Discovery Phase**: Gathering requirements and clarifying unknowns
|
|
236
|
+
2. **Planning Phase**: Understanding scope, priorities, and constraints
|
|
237
|
+
3. **Critical Decisions**: When user input is required before proceeding
|
|
238
|
+
4. **Multiple Related Questions**: When you need to ask several questions in sequence
|
|
239
|
+
5. **Complex Choices**: When options need to be clearly presented
|
|
240
|
+
|
|
241
|
+
### Don't Use For:
|
|
242
|
+
|
|
243
|
+
1. **Simple Yes/No Questions**: Use regular chat for these
|
|
244
|
+
2. **Single Simple Questions**: Regular chat is faster
|
|
245
|
+
3. **Information Already Available**: Don't ask if you can find the answer
|
|
246
|
+
4. **Read-Only Operations**: No questions needed for reading/searching
|
|
247
|
+
|
|
248
|
+
---
|
|
249
|
+
|
|
250
|
+
## Question Format Guidelines
|
|
251
|
+
|
|
252
|
+
### Good Question Format
|
|
253
|
+
|
|
254
|
+
```
|
|
255
|
+
AskQuestion({
|
|
256
|
+
question: "Where should the new button be placed?",
|
|
257
|
+
options: [
|
|
258
|
+
"A. Before 'Library' (per Figma order)",
|
|
259
|
+
"B. After 'Library'",
|
|
260
|
+
"C. In a separate toolbar",
|
|
261
|
+
"D. As a dropdown option"
|
|
262
|
+
],
|
|
263
|
+
explanation: "Button placement affects user workflow and visual hierarchy"
|
|
264
|
+
})
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
### Bad Question Format
|
|
268
|
+
|
|
269
|
+
```
|
|
270
|
+
// ❌ Too vague
|
|
271
|
+
AskQuestion({
|
|
272
|
+
question: "What do you want?",
|
|
273
|
+
options: ["A. Yes", "B. No"]
|
|
274
|
+
})
|
|
275
|
+
|
|
276
|
+
// ❌ Too many options (hard to choose)
|
|
277
|
+
AskQuestion({
|
|
278
|
+
question: "Choose an option",
|
|
279
|
+
options: ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J"]
|
|
280
|
+
})
|
|
281
|
+
|
|
282
|
+
// ❌ No context
|
|
283
|
+
AskQuestion({
|
|
284
|
+
question: "Option A or B?",
|
|
285
|
+
options: ["A", "B"]
|
|
286
|
+
})
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
---
|
|
290
|
+
|
|
291
|
+
## Error Handling
|
|
292
|
+
|
|
293
|
+
### If SwitchMode Tool Fails
|
|
294
|
+
|
|
295
|
+
If the `SwitchMode` tool is not available or fails:
|
|
296
|
+
|
|
297
|
+
1. **Inform the user** that manual mode switch is required
|
|
298
|
+
2. **Provide clear instructions** on how to switch
|
|
299
|
+
3. **Wait for confirmation** before proceeding
|
|
300
|
+
4. **Continue with the workflow** once in Plan mode
|
|
301
|
+
|
|
302
|
+
### If AskQuestion Tool Not Available
|
|
303
|
+
|
|
304
|
+
If the `AskQuestion` tool is not available:
|
|
305
|
+
|
|
306
|
+
1. **Fall back to regular chat questions**
|
|
307
|
+
2. **Present questions in a clear format**
|
|
308
|
+
3. **Wait for text responses**
|
|
309
|
+
4. **Process responses as usual**
|
|
310
|
+
|
|
311
|
+
### If User Doesn't Respond
|
|
312
|
+
|
|
313
|
+
If the user doesn't respond to questions:
|
|
314
|
+
|
|
315
|
+
1. Wait a reasonable amount of time
|
|
316
|
+
2. Gently remind about pending questions
|
|
317
|
+
3. Offer to continue with assumptions (clearly marked)
|
|
318
|
+
4. Only proceed if user explicitly agrees to assumptions
|
|
319
|
+
|
|
320
|
+
---
|
|
321
|
+
|
|
322
|
+
## Benefits of Interactive Questions
|
|
323
|
+
|
|
324
|
+
1. **Better UX**: Visual multiple-choice options are easier to answer
|
|
325
|
+
2. **Faster Responses**: Users can click instead of typing
|
|
326
|
+
3. **Clearer Options**: Structured choices reduce ambiguity
|
|
327
|
+
4. **Batch Processing**: Ask multiple questions in one session
|
|
328
|
+
5. **Consistent Format**: Standardized question presentation
|
|
329
|
+
6. **Reduced Errors**: Multiple-choice reduces typos and misunderstandings
|
|
330
|
+
|
|
331
|
+
---
|
|
332
|
+
|
|
333
|
+
## Related Tools
|
|
334
|
+
|
|
335
|
+
- [Plan Mode Tool](.cursor/rules/tools/plan-mode-tool.mdc) - For switching to Plan mode
|
|
336
|
+
- Discovery patterns: `.cursor/rules/patterns/discovery-patterns.mdc`
|
|
337
|
+
- Discovery command: `.cursor/commands/discovery-plan.md`
|