@cubocicloide/stack-frappe 2.1.0 → 2.2.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cubocicloide/stack-frappe",
3
- "version": "2.1.0",
3
+ "version": "2.2.1",
4
4
  "description": "Frappe Framework + Frappe Helpdesk ticketing stack plugin for the dude CLI.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -18,16 +18,16 @@
18
18
  },
19
19
  "dependencies": {
20
20
  "pathe": "^1.1.2",
21
- "@cubocicloide/dude": "0.16.0"
21
+ "@cubocicloide/dude": "0.17.1"
22
22
  },
23
23
  "devDependencies": {
24
- "@types/node": "^26.1.2",
24
+ "@types/node": "^26.2.0",
25
25
  "tsup": "^8.3.0",
26
26
  "typescript": "^5.6.3",
27
27
  "vitest": "^2.1.9"
28
28
  },
29
29
  "engines": {
30
- "node": ">=20"
30
+ "node": ">=20.19"
31
31
  },
32
32
  "scripts": {
33
33
  "build": "tsup",
@@ -0,0 +1,245 @@
1
+ ---
2
+ name: issue-fixer
3
+ description: Fix a Jira issue (feature, bug, or task) — fetch the ticket, implement the change on a dedicated branch, verify it passes lint and tests, and open a PR.
4
+ tools: Bash, Read, Write, Edit, Grep, Glob, mcp__atlassian__getJiraIssue, mcp__atlassian__getTransitionsForJiraIssue, mcp__atlassian__transitionJiraIssue, mcp__atlassian__createPullRequest, mcp__atlassian__getRepository, PushNotification
5
+ model: sonnet
6
+ ---
7
+
8
+ You are a software engineer working on this project. Your job is to fix a Jira issue end-to-end: read the ticket, implement the fix on a dedicated branch, verify it passes lint and tests, and open a pull request.
9
+
10
+ ## Project context
11
+
12
+ - Stack: Frappe Framework, custom apps in `apps/<app>/`, running on a dockerised bench
13
+ - Jira URL: provided in the invocation prompt
14
+ - Bitbucket workspace and repo: provided in the invocation prompt
15
+ - Base branch: `develop`
16
+
17
+ **What is in the repo and what is not.** Only `apps/` is source you edit. The
18
+ bench itself (`frappe-bench/`, the `frappe` app, Helpdesk) lives inside a Docker
19
+ volume and is created on first `dude up` — never edit or commit anything from
20
+ there. Custom apps are symlinked into the bench in editable mode, so a host-side
21
+ edit under `apps/` is live immediately.
22
+
23
+ ## Workflow
24
+
25
+ ### Step 1 — Fetch the issue
26
+
27
+ Use `mcp__atlassian__getJiraIssue` to read the issue. Extract:
28
+ - Summary (used as PR title)
29
+ - Description (used to understand what to fix)
30
+ - Issue type, priority, labels
31
+
32
+ If the issue cannot be fetched, stop and report the error.
33
+
34
+ ### Step 2 — Prepare the branch
35
+
36
+ ```bash
37
+ git fetch origin
38
+ git checkout develop && git pull origin develop --rebase
39
+ git checkout -b <issue-id>
40
+ ```
41
+
42
+ Replace `<issue-id>` with the **lowercase** issue key (e.g. `proj-52`).
43
+ If the branch already exists locally, check it out and rebase onto develop.
44
+
45
+ ### Step 3 — Implement the fix
46
+
47
+ Read the issue description carefully. Locate the relevant files with Grep/Glob/Read.
48
+ `apps/ticketing/README.md` maps every Frappe building block to a concrete file —
49
+ use it to find the right layer fast.
50
+
51
+ Apply a minimal, targeted fix — do not refactor surrounding code or introduce
52
+ abstractions beyond what the issue requires. Follow existing code conventions
53
+ (check nearby files for patterns). Python in `apps/` is **tab-indented** (ruff,
54
+ Frappe style) — match it. Do not add comments unless the fix introduces a
55
+ non-obvious invariant.
56
+
57
+ **Where things live** (`apps/<app>/<app>/`):
58
+
59
+ | Change | File | Rule to respect |
60
+ |--------|------|-----------------|
61
+ | DocType schema / fields | `<module>/doctype/<name>/<name>.json` | DT002 (permissions non-empty), DT003 (module ↔ path), DT004 (snake_case `fieldname`) |
62
+ | DocType business logic | `<module>/doctype/<name>/<name>.py` (`validate`, `on_update`, …) | DT001 (bundle stays complete), PY003 (tests alongside) |
63
+ | Desk form behaviour | `<module>/doctype/<name>/<name>.js` | — |
64
+ | Background job | `tasks.py`, registered in `hooks.py` → `scheduler_events` | APP002 (dotted path must resolve) |
65
+ | Reacting to another app's documents | `events/<doctype>.py`, registered in `hooks.py` → `doc_events` | APP003 (dotted path must resolve) |
66
+ | HTTP endpoint | `api.py`, `@frappe.whitelist()` | PY001 (no unjustified `allow_guest=True`), PY002 (no interpolated SQL) |
67
+ | Portal page | `templates/pages/<route>.{py,html}` | PY002 |
68
+ | Shipped records (workflows, …) | `fixtures/*.json` + the `fixtures` list in `hooks.py` | APP004 (declared ↔ shipped, both directions) |
69
+ | One-off data migration | `patches/<version>/<name>.py` + a line in `patches.txt` | — |
70
+ | A whole new app | `dude app new --name <app>` | APP001 (canonical layout) |
71
+
72
+ Constraints that bite in Frappe specifically:
73
+ - Keep `hooks.py` **declarative** — logic goes in `events/`, `tasks.py`, `api.py`.
74
+ Every dotted path there is resolved at runtime, so a typo fails silently in
75
+ production; APP002/APP003 exist to catch it at lint time.
76
+ - Query through the ORM (`frappe.get_all`, `frappe.get_doc`, `frappe.qb`) so the
77
+ permission model applies. Never build SQL with an f-string (PY002 error).
78
+ - A DocType bundle is `<name>.json` + `<name>.py` + `__init__.py`, and should
79
+ carry `test_<name>.py` (DT001, PY003). Keep them together in one commit.
80
+ - Anything touching a DocType schema, `patches.txt` or `fixtures` needs
81
+ `dude site migrate` before it takes effect.
82
+ - Do not edit auto-generated or exported artefacts by hand — re-export fixtures
83
+ with `dude bench --site all export-fixtures --app <app>` instead.
84
+
85
+ If the issue description is too vague to implement safely, stop and ask the user
86
+ for clarification before making changes.
87
+
88
+ ### Step 4 — Commit
89
+
90
+ ```bash
91
+ git add <file1> <file2> ...
92
+ git commit -m "<type>(<scope>): <description>"
93
+ ```
94
+
95
+ Commit message format (Conventional Commits):
96
+ - Type: `fix`, `feat`, `chore`, `refactor`, `ci`, `docs`, `test`
97
+ - Scope: area of the codebase (e.g. `ticketing`, `doctype`, `hooks`, `api`)
98
+ - Description: lowercase, no trailing period, max 72 chars total
99
+ - Do not add a `Co-Authored-By` trailer
100
+
101
+ ### Step 5 — Run checks
102
+
103
+ Run in order. Stop at the first failure.
104
+
105
+ **Step 5a — Structural lint:**
106
+ ```bash
107
+ dude lint
108
+ ```
109
+
110
+ This is a pure filesystem check over `apps/` — it needs neither Docker nor a
111
+ running bench, so it always runs. On a violation, get the machine-readable form
112
+ and the prose behind the code rather than guessing:
113
+
114
+ ```bash
115
+ dude lint --format json # what broke, where, under which code
116
+ dude explain <CODE> # e.g. dude explain APP002
117
+ ```
118
+
119
+ Fix the cause the rule describes; never work around a diagnostic.
120
+
121
+ **Step 5b — Formatting and static review:**
122
+ ```bash
123
+ dude format # ruff format + autofix over apps/ (needs Docker)
124
+ dude review # one pass: the same lint rules + `ruff check` (no autofix)
125
+ ```
126
+
127
+ `dude review` is the gate — it exits non-zero on any lint **error** or ruff
128
+ finding. Its ruff half needs Docker (it runs the official ruff image against
129
+ `apps/`) and is skipped with a warning when Docker is absent; `dude lint` above
130
+ still ran either way.
131
+
132
+ **Step 5c — Tests:**
133
+ The suite runs `bench run-tests` **inside the bench container**, so the stack
134
+ must be up first. First boot provisions the bench and site and takes several
135
+ minutes.
136
+
137
+ ```bash
138
+ dude up # if the stack is not already running
139
+ dude site migrate # only if the change touched schema/patches/fixtures
140
+ dude test --app <app> # default app is `ticketing`
141
+ dude test --module <dotted.path> # a single module, when iterating
142
+ ```
143
+
144
+ If Docker is unavailable in this environment, `dude lint` still gates the
145
+ change: run it, say explicitly in the report that tests could not be run, and
146
+ do **not** claim they passed.
147
+
148
+ If checks fail:
149
+ - Read the error output carefully
150
+ - Attempt a fix directly related to the failure (do not guess broadly)
151
+ - Re-run the failing step only
152
+ - If still failing after one fix attempt, stop and report — do not loop
153
+
154
+ ### Step 6 — Push the branch
155
+
156
+ ```bash
157
+ git push -u origin <issue-id>
158
+ ```
159
+
160
+ ### Step 7 — Create the PR
161
+
162
+ Use `mcp__atlassian__createPullRequest` with:
163
+ - **workspace**: as provided in the invocation prompt
164
+ - **repo_slug**: as provided in the invocation prompt
165
+ - **title**: `[<ISSUE_ID>] <issue summary>`
166
+ - **description**:
167
+ ```
168
+ ## Summary
169
+ <1-3 bullet points: what was changed and why>
170
+
171
+ ## Issue
172
+ [<ISSUE_ID>] <issue summary>
173
+ <Jira URL>/browse/<ISSUE_ID>
174
+
175
+ ## Test plan
176
+ - [ ] dude lint: ✓
177
+ - [ ] dude test: ✓
178
+ - [ ] dude site migrate needed: yes/no
179
+ ```
180
+ - **sourceBranch**: `<issue-id>`
181
+ - **destinationBranch**: `develop`
182
+ - **close_source_branch**: `true`
183
+
184
+ ### Step 8 — Transition the Jira issue
185
+
186
+ ```
187
+ mcp__atlassian__getTransitionsForJiraIssue(issueKey: <ISSUE_ID>)
188
+ ```
189
+
190
+ Find the transition whose name contains "Review" or "Peer review" (case-insensitive).
191
+ Use its `id`:
192
+
193
+ ```
194
+ mcp__atlassian__transitionJiraIssue(issueKey: <ISSUE_ID>, transitionId: <id>)
195
+ ```
196
+
197
+ If no matching transition is found, skip silently.
198
+
199
+ ### Step 9 — Report + notify
200
+
201
+ ```
202
+ ## Fix complete: <ISSUE_ID>
203
+
204
+ ### Changes (N files)
205
+ - path/to/file — description of change
206
+
207
+ ### Checks
208
+ - dude lint: ✓ / ✗
209
+ - dude test: ✓ / ✗ / skipped (Docker unavailable)
210
+ - dude site migrate required: yes / no
211
+
212
+ ### Pull request
213
+ <PR URL>
214
+ ```
215
+
216
+ Then call `PushNotification` with the same summary.
217
+
218
+ ---
219
+
220
+ ## Parallel mode
221
+
222
+ If the prompt contains **PARALLEL MODE**, this agent is one of several running
223
+ simultaneously via `isolation: "worktree"`. Each agent has its own isolated git
224
+ checkout — git operations never conflict between agents.
225
+
226
+ The following steps differ from the standard workflow:
227
+
228
+ | Step | Standard | Parallel mode |
229
+ |------|----------|---------------|
230
+ | **Step 2** | checkout develop, create branch | worktree already has a clean checkout; just run `git checkout -b <issue-id>` |
231
+ | **Step 5** | run lint + format + tests | run `dude lint` only — it is filesystem-local and safe to run per worktree. **Skip `dude test`**: every worktree would drive the same single bench container and the same site. Tests run once on the consolidated branch by `/fix-issues` |
232
+ | **Step 7** | create PR | **skip** — `/fix-issues` creates one consolidated PR |
233
+ | **Step 8** | transition Jira | **skip** — handled by `/fix-issues` after consolidation |
234
+ | **Step 9** | report + PushNotification | report branch name, files changed, commit hash, and whether the change needs `dude site migrate`; call `PushNotification` immediately |
235
+
236
+ ---
237
+
238
+ ## Rules
239
+
240
+ - Never commit directly to `develop` or `main`
241
+ - Never force-push
242
+ - Never skip hooks (`--no-verify`)
243
+ - Never edit anything under `frappe-bench/` — it is a Docker volume, not source
244
+ - If checks fail after one fix attempt, stop and report — do not keep retrying
245
+ - Do not create the PR if checks are failing
@@ -23,6 +23,17 @@
23
23
  "Edit(*)",
24
24
  "Glob(*)",
25
25
  "Grep(*)",
26
+ "mcp__atlassian__atlassianUserInfo",
27
+ "mcp__atlassian__getAccessibleAtlassianResources",
28
+ "mcp__atlassian__createJiraIssue",
29
+ "mcp__atlassian__searchJiraIssuesUsingJql",
30
+ "mcp__atlassian__getJiraIssue",
31
+ "mcp__atlassian__getTransitionsForJiraIssue",
32
+ "mcp__atlassian__transitionJiraIssue",
33
+ "mcp__atlassian__addCommentToJiraIssue",
34
+ "mcp__atlassian__createPullRequest",
35
+ "mcp__atlassian__getRepository",
36
+ "mcp__atlassian__getPullRequest",
26
37
  "PushNotification"
27
38
  ]
28
39
  },
@@ -0,0 +1,100 @@
1
+ ---
2
+ name: clean-branches
3
+ description: Identify merged and stale branches, list them, ask for confirmation, then delete selected ones
4
+ disable-model-invocation: false
5
+ allowed-tools: "Bash(git *)"
6
+ ---
7
+
8
+ # Clean Branches
9
+
10
+ ## Step 0 — Clean up stale worktrees
11
+
12
+ Before identifying branch candidates, check for stale or abandoned worktrees:
13
+
14
+ ```bash
15
+ git worktree list
16
+ ```
17
+
18
+ Flag any worktree under `.claude/worktrees/` as a **Claude agent worktree** — these are created automatically during agent runs and are safe to remove when no longer active.
19
+
20
+ For each stale worktree:
21
+ 1. Check if the directory exists on disk
22
+ 2. Remove it with `git worktree remove -f -f <path>` (double `-f` required for locked worktrees)
23
+ 3. After removal, include the associated branch in the candidate list for Step 1
24
+
25
+ If any worktree removal fails, warn the user and skip that branch from deletion.
26
+
27
+ ## Current state
28
+
29
+ !`git fetch --prune 2>&1 | tail -5`
30
+ !`git branch --show-current`
31
+
32
+ ## Step 1 — Identify candidates
33
+
34
+ Run the following commands and collect results:
35
+
36
+ ```bash
37
+ # Branches merged into main (local)
38
+ git branch --merged main | grep -v '^\*' | grep -v 'main$' | grep -v 'develop$'
39
+
40
+ # Branches merged into develop (local)
41
+ git branch --merged develop | grep -v '^\*' | grep -v 'main$' | grep -v 'develop$'
42
+
43
+ # Remote branches merged into main
44
+ git branch -r --merged main | grep -v 'origin/main$' | grep -v 'origin/develop$' | grep -v 'origin/HEAD'
45
+
46
+ # Remote branches merged into develop
47
+ git branch -r --merged develop | grep -v 'origin/main$' | grep -v 'origin/develop$' | grep -v 'origin/HEAD'
48
+
49
+ # Stale local branches (no upstream, last commit older than 30 days)
50
+ git for-each-ref --format='%(refname:short) %(upstream:short) %(committerdate:iso)' refs/heads \
51
+ | awk '{if ($2 == "" && $3 != "" && $3 < "'$(date -v-30d +%Y-%m-%d 2>/dev/null || date -d '30 days ago' +%Y-%m-%d)'") print $1}'
52
+ ```
53
+
54
+ ## Step 2 — Present the list
55
+
56
+ After collecting results, deduplicate and present a clear table:
57
+
58
+ | # | Branch | Type | Last Commit | Merged into |
59
+ | --- | ------ | ---- | ----------- | ----------- |
60
+
61
+ **Types:**
62
+
63
+ - `merged-local` — local branch merged into main or develop
64
+ - `merged-remote` — remote tracking branch merged into main or develop
65
+ - `stale-local` — local branch with no upstream and no commits in 30+ days
66
+
67
+ Always **exclude** from the list: `main`, `develop`, `sandbox`, the current branch, and any branch the user is currently on.
68
+
69
+ ## Step 3 — Ask for confirmation
70
+
71
+ Present the list, then ask:
72
+
73
+ > "Which branches should I delete?
74
+ >
75
+ > - Type **all** to delete everything listed
76
+ > - Type **none** to cancel
77
+ > - Type branch numbers or names to keep (exceptions), e.g. `keep 3,5` or `keep feature/old-experiment`"
78
+
79
+ Wait for the user's explicit answer before proceeding.
80
+
81
+ ## Step 4 — Delete confirmed branches
82
+
83
+ Based on the user's response:
84
+
85
+ - For **local** merged/stale branches: `git branch -d <branch>` (use `-D` only if `-d` fails and user confirms)
86
+ - For **remote** branches: `git push origin --delete <branch>` (strip the `origin/` prefix)
87
+
88
+ After deletion, show a summary:
89
+
90
+ ```
91
+ Deleted: <list>
92
+ Skipped: <list>
93
+ ```
94
+
95
+ ## Rules
96
+
97
+ - Never delete `main`, `develop`, `dev`, `test`, `staging`, or the currently checked-out branch
98
+ - Never force-delete (`-D`) without explicit user confirmation per branch
99
+ - Always confirm before any remote deletion — remote deletions are not reversible locally
100
+ - If no candidates are found, report "No stale or merged branches found" and stop
@@ -0,0 +1,88 @@
1
+ ---
2
+ name: create
3
+ description: Guided scaffolding for this stack. Asks whether you want to create a DocType, a hook (scheduled job / document event / fixture) or a whitelisted API method, then runs the matching convention-aware flow that inspects the existing app and enforces the stack's APP/DT/PY rules.
4
+ disable-model-invocation: false
5
+ allowed-tools: "Read Glob Grep Bash(find *) Bash(cat *) Bash(ls *)"
6
+ ---
7
+
8
+ # Create (router)
9
+
10
+ Single entry point for adding something to a custom Frappe app in this project.
11
+ It figures out **what** you want to build, then hands off to the specialised
12
+ skill that knows the exact conventions (see `.claude/rules/{APP,DT,PY}/`) and
13
+ inspects the existing app before writing anything.
14
+
15
+ ## Step 0 — Locate the project
16
+
17
+ ```bash
18
+ find . -maxdepth 3 -name "dude.json" | head -1
19
+ ```
20
+
21
+ If not found, report _"No dude.json found — are you inside a dude project?"_ and stop.
22
+ Set `PROJECT_ROOT` to the directory containing `dude.json`.
23
+
24
+ The apps you can add to are the directories under `apps/` that ship a
25
+ `pyproject.toml` (that is what makes one a real bench app — APP001):
26
+
27
+ ```bash
28
+ ls -d "$PROJECT_ROOT"/apps/*/pyproject.toml
29
+ ```
30
+
31
+ ## Step 1 — Ask what to create
32
+
33
+ If the user has not already made it explicit, ask:
34
+
35
+ > **What do you want to create?**
36
+ > 1. **DocType** — a new model: JSON schema + controller + tests, in a module of a custom app
37
+ > 2. **Hook** — a scheduled background job, a handler for another app's document events, or a shipped fixture
38
+ > 3. **API method** — a `@frappe.whitelist()` endpoint at `/api/method/…`, optionally with a portal page
39
+
40
+ Map free-form answers too:
41
+
42
+ | The user says | Route to |
43
+ |---------------|----------|
44
+ | "model", "table", "doctype", "new record type", "form" | **DocType** |
45
+ | "cron", "scheduled", "background job", "every hour", "task" | **Hook** (scheduled job) |
46
+ | "when a ticket is saved", "on save", "doc_events", "react to", "extend HD Ticket" | **Hook** (document event) |
47
+ | "workflow", "fixture", "ship these records", "seed data" | **Hook** (fixture) |
48
+ | "endpoint", "API", "whitelist", "REST", "call it over HTTP" | **API method** |
49
+ | "portal page", "public page", "web page" | **API method** (its Step 5 covers the page pair) |
50
+
51
+ ## Step 2 — Hand off
52
+
53
+ - **DocType** → read `.claude/skills/create-doctype/SKILL.md` and follow it from Step 1.
54
+ - **Hook** → read `.claude/skills/create-hook/SKILL.md` and follow it from Step 0.
55
+ - **API method** → read `.claude/skills/create-api-method/SKILL.md` and follow it from Step 0.
56
+
57
+ Pass along anything the user already specified (target app, DocType name,
58
+ frequency, endpoint name) so the worker skill can skip questions it already has
59
+ answers for.
60
+
61
+ ## Not a skill: a whole new app
62
+
63
+ If the feature doesn't belong in any existing app, it needs its own — two
64
+ commands, no skill required:
65
+
66
+ ```bash
67
+ dude app new --name my_app # bench new-app, relocated into apps/my_app
68
+ dude app install --name my_app # install it on the site
69
+ dude up # restart so docker/init.sh links everything
70
+ ```
71
+
72
+ The new app lands in `apps/my_app/`, symlinked into the bench in editable mode
73
+ exactly like `ticketing`. From there every skill above applies to it — pass
74
+ `my_app` as the target app. `dude lint` will hold the new app to APP001 (it
75
+ needs `pyproject.toml`, and `my_app/hooks.py`, `modules.txt`, `patches.txt`,
76
+ `__init__.py`).
77
+
78
+ ## Notes
79
+
80
+ - This router never writes files itself — it only routes.
81
+ - All three worker skills are also invocable directly (`/create-doctype`,
82
+ `/create-hook`, `/create-api-method`) when you already know which one you need.
83
+ - Every worker skill ends by running `dude lint` (plus `dude lint --format json`
84
+ and `dude explain <CODE>` when something trips). That is the point: this
85
+ project's conventions are checked mechanically, so the skill verifies its own
86
+ output rather than asserting it.
87
+ - `apps/ticketing/README.md` maps every Frappe building block to a concrete
88
+ file, and `docs/docs/extending.md` is the prose version of these recipes.