mustflow 2.22.16 → 2.22.46

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.
Files changed (67) hide show
  1. package/dist/cli/commands/dashboard.js +51 -4
  2. package/dist/cli/commands/explain.js +3 -2
  3. package/dist/cli/commands/help.js +0 -1
  4. package/dist/cli/commands/run.js +51 -4
  5. package/dist/cli/commands/verify.js +2 -1
  6. package/dist/cli/i18n/en.js +5 -0
  7. package/dist/cli/i18n/es.js +5 -0
  8. package/dist/cli/i18n/fr.js +5 -0
  9. package/dist/cli/i18n/hi.js +5 -0
  10. package/dist/cli/i18n/ko.js +5 -0
  11. package/dist/cli/i18n/zh.js +5 -0
  12. package/dist/cli/lib/cli-output.js +1 -1
  13. package/dist/cli/lib/dashboard-html/client-script.js +9 -0
  14. package/dist/cli/lib/dashboard-html/styles.js +48 -1
  15. package/dist/cli/lib/doc-review-ledger.js +1 -1
  16. package/dist/cli/lib/git-changes.js +2 -0
  17. package/dist/cli/lib/local-index/index.js +324 -298
  18. package/dist/cli/lib/repo-map.js +19 -5
  19. package/dist/cli/lib/run-plan.js +20 -7
  20. package/dist/cli/lib/run-root-trust.js +33 -2
  21. package/dist/cli/lib/validation/index.js +6 -2
  22. package/dist/cli/lib/validation/test-selection.js +11 -1
  23. package/dist/core/active-run-locks.js +36 -8
  24. package/dist/core/atomic-state-write.js +5 -20
  25. package/dist/core/change-verification.js +18 -2
  26. package/dist/core/command-intent-eligibility.js +7 -0
  27. package/dist/core/contract-lint.js +3 -3
  28. package/dist/core/line-endings.js +2 -0
  29. package/dist/core/repeated-failure.js +1 -1
  30. package/dist/core/run-write-drift.js +42 -26
  31. package/dist/core/safe-filesystem.js +54 -5
  32. package/dist/core/skill-route-explanation.js +2 -1
  33. package/dist/core/source-anchors.js +7 -3
  34. package/dist/core/test-selection.js +13 -2
  35. package/dist/core/test-target-paths.js +17 -0
  36. package/dist/core/validation-ratchet.js +62 -17
  37. package/dist/core/verification-decision-graph.js +8 -1
  38. package/package.json +1 -1
  39. package/templates/default/i18n.toml +141 -3
  40. package/templates/default/locales/en/.mustflow/skills/INDEX.md +24 -1
  41. package/templates/default/locales/en/.mustflow/skills/api-contract-change/SKILL.md +212 -0
  42. package/templates/default/locales/en/.mustflow/skills/astro-code-change/SKILL.md +184 -0
  43. package/templates/default/locales/en/.mustflow/skills/auth-permission-change/SKILL.md +194 -0
  44. package/templates/default/locales/en/.mustflow/skills/config-env-change/SKILL.md +189 -0
  45. package/templates/default/locales/en/.mustflow/skills/css-code-change/SKILL.md +199 -0
  46. package/templates/default/locales/en/.mustflow/skills/dart-code-change/SKILL.md +179 -0
  47. package/templates/default/locales/en/.mustflow/skills/database-migration-change/SKILL.md +178 -0
  48. package/templates/default/locales/en/.mustflow/skills/dependency-upgrade-review/SKILL.md +151 -0
  49. package/templates/default/locales/en/.mustflow/skills/elysia-code-change/SKILL.md +115 -0
  50. package/templates/default/locales/en/.mustflow/skills/file-path-cross-platform-change/SKILL.md +147 -0
  51. package/templates/default/locales/en/.mustflow/skills/flutter-code-change/SKILL.md +116 -0
  52. package/templates/default/locales/en/.mustflow/skills/go-code-change/SKILL.md +156 -0
  53. package/templates/default/locales/en/.mustflow/skills/hono-code-change/SKILL.md +117 -0
  54. package/templates/default/locales/en/.mustflow/skills/html-code-change/SKILL.md +173 -0
  55. package/templates/default/locales/en/.mustflow/skills/javascript-code-change/SKILL.md +149 -0
  56. package/templates/default/locales/en/.mustflow/skills/python-code-change/SKILL.md +154 -0
  57. package/templates/default/locales/en/.mustflow/skills/release-publish-change/SKILL.md +172 -0
  58. package/templates/default/locales/en/.mustflow/skills/routes.toml +138 -0
  59. package/templates/default/locales/en/.mustflow/skills/rust-code-change/SKILL.md +154 -0
  60. package/templates/default/locales/en/.mustflow/skills/security-privacy-review/SKILL.md +22 -7
  61. package/templates/default/locales/en/.mustflow/skills/security-regression-tests/SKILL.md +31 -20
  62. package/templates/default/locales/en/.mustflow/skills/svelte-code-change/SKILL.md +186 -0
  63. package/templates/default/locales/en/.mustflow/skills/tailwind-code-change/SKILL.md +164 -0
  64. package/templates/default/locales/en/.mustflow/skills/tauri-code-change/SKILL.md +185 -0
  65. package/templates/default/locales/en/.mustflow/skills/typescript-code-change/SKILL.md +184 -0
  66. package/templates/default/locales/en/.mustflow/skills/unocss-code-change/SKILL.md +186 -0
  67. package/templates/default/manifest.toml +158 -1
@@ -0,0 +1,173 @@
1
+ ---
2
+ mustflow_doc: skill.html-code-change
3
+ locale: en
4
+ canonical: true
5
+ revision: 2
6
+ lifecycle: mustflow-owned
7
+ authority: procedure
8
+ name: html-code-change
9
+ description: Apply this skill when HTML, templates, JSX or component markup, forms, controls, dialogs, navigation, tables, media, metadata, SEO head content, or structured data are created or changed.
10
+ metadata:
11
+ mustflow_schema: "1"
12
+ mustflow_kind: procedure
13
+ pack_id: mustflow.core
14
+ skill_id: mustflow.core.html-code-change
15
+ command_intents:
16
+ - changes_status
17
+ - changes_diff_summary
18
+ - lint
19
+ - build
20
+ - test_related
21
+ - test
22
+ - docs_validate_fast
23
+ - mustflow_check
24
+ ---
25
+
26
+ # HTML Code Change
27
+
28
+ <!-- mustflow-section: purpose -->
29
+ ## Purpose
30
+
31
+ Preserve semantic structure, native controls, keyboard access, focus behavior, form labeling, metadata, and browser-valid markup. Treat non-native interactive markup as suspicious by default; HTML already gives browsers, keyboards, forms, password managers, mobile input, and assistive technology a working contract.
32
+
33
+ <!-- mustflow-section: use-when -->
34
+ ## Use When
35
+
36
+ - `.html`, JSX, TSX, Vue, Svelte, Astro, or template markup changes.
37
+ - The task touches layout landmarks, headings, forms, buttons, links, dialogs, menus, tabs, accordions, custom selects, composite widgets, tables, media, metadata, canonical links, Open Graph, robots, hreflang, viewport, or JSON-LD.
38
+
39
+ <!-- mustflow-section: do-not-use-when -->
40
+ ## Do Not Use When
41
+
42
+ - Only CSS changes and markup semantics are unchanged; use `css-code-change`.
43
+ - The markup is generated and should be changed through a source component or template.
44
+
45
+ <!-- mustflow-section: required-inputs -->
46
+ ## Required Inputs
47
+
48
+ - Existing page layout, document shell, head/SEO helpers, metadata builders, canonical URL helpers, sitemap or robots config, form components, interactive control components, and tests.
49
+ - Target framework conventions for rendering, routing, hydration, and metadata.
50
+ - Visible page content, H1 or primary title, main entity, locale, indexing intent, and data sources for title, description, image, author, date, price, rating, availability, and FAQ content when metadata changes.
51
+ - Accessibility and validation tooling declared in the command contract.
52
+
53
+ <!-- mustflow-section: preconditions -->
54
+ ## Preconditions
55
+
56
+ - Identify the document structure, interactive controls, form ownership, focus path, metadata source, and verification surface.
57
+ - Prefer native HTML elements before adding ARIA or JavaScript behavior.
58
+ - Classify every interactive element by user intent before changing markup.
59
+ - Do not edit metadata, canonical, Open Graph, robots, hreflang, or JSON-LD from a single file in isolation.
60
+
61
+ <!-- mustflow-section: allowed-edits -->
62
+ ## Allowed Edits
63
+
64
+ - Use semantic landmarks, headings, native links, native buttons, and native form controls where possible.
65
+ - Connect labels, help text, error text, required state, autocomplete, and input type explicitly.
66
+ - Keep metadata and structured data consistent with visible page content.
67
+ - Add ARIA only when native semantics cannot express the control and the required role, state, keyboard, and focus behavior are implemented.
68
+
69
+ <!-- mustflow-section: procedure -->
70
+ ## Procedure
71
+
72
+ 1. Read the page shell, route layout, metadata helpers, component patterns, and tests before editing.
73
+ 2. Check document outline, landmarks, source order, and heading levels.
74
+ 3. Classify each interactive element by intent. Navigation to a URL uses an anchor with `href`. Commands, toggles, submit actions, open/close actions, destructive actions, copy actions, disclosure triggers, and modal triggers use buttons.
75
+ 4. Use native form controls for text entry, selection, checkbox, radio, and file input. Use grouped native radio or checkbox controls with fieldset and legend when the group label matters.
76
+ 5. Treat composite widgets such as tabs, action menus, comboboxes, listboxes, trees, grids, and custom selects as high-risk. Prefer native HTML or an existing audited component; otherwise implement the complete role, state, focus, and keyboard pattern.
77
+ 6. Reject clickable `div` or `span` controls, clickable icons without buttons, anchors without `href`, links used as buttons, nested interactive controls, positive `tabindex`, focusable `aria-hidden` content, and focus outline removal without a replacement focus style.
78
+ 7. Use ARIA only when native HTML cannot express the needed semantics. Validate the role is legal for the element, the accessible name exists, required states are present, visual and ARIA states stay synchronized, keyboard behavior matches the widget pattern, and focus behavior is explicit.
79
+ 8. For custom legacy button-like elements that cannot be replaced, require `role`, focusability, Enter activation, Space activation, Space scroll prevention, pointer activation, duplicate-event prevention, and visible focus. Use native buttons instead whenever possible.
80
+ 9. For dialogs, prefer native dialog when the project can support it. Otherwise implement focus entry, Tab and Shift+Tab containment, Escape behavior, inert or unreachable background content, visible close or cancel control, focus return, and an accessible name.
81
+ 10. For tabs, use tablist, tab, and tabpanel semantics only for a real tabbed interface. Require one active tab, panel linkage, roving tabindex, arrow key movement, Home and End where expected, and Enter or Space activation when activation is manual.
82
+ 11. For menus, do not use ARIA menu roles for ordinary site navigation. Site navigation is a nav landmark with links. Use ARIA menu patterns only for application-style action menus with a button trigger, expanded state, focus strategy, Escape close behavior, and focus return.
83
+ 12. For forms, verify visible label association, help association, error association, required text, native required state, autocomplete, validation timing, invalid state, error summary behavior, and submission behavior.
84
+ 13. Use placeholder, title, aria-label, color, icon, or toast-only feedback only as supplementary affordances, not as the only label, required indicator, or error explanation.
85
+ 14. For metadata, read visible content and the metadata generation path first. Keep title, description, canonical, Open Graph, Twitter or X card data, robots, hreflang, and JSON-LD aligned with visible content, locale, URL, and indexing intent.
86
+ 15. Structured data must describe content visible on the same page. Do not invent ratings, reviews, FAQ items, authors, prices, availability, dates, organizations, product properties, or claims not backed by the page data source.
87
+ 16. Ensure every HTML page has a valid non-empty language and responsive viewport that does not disable zoom. Mixed-language passages should identify their language when needed.
88
+ 17. Keep inline script and style minimal; move behavior and styling to the existing project layers unless the framework requires an inline boundary.
89
+ 18. Choose configured verification intents that cover markup validity, lint, build, accessibility, route rendering, metadata, and docs when available.
90
+
91
+ <!-- mustflow-section: form-accessibility -->
92
+ ## Form Accessibility Rules
93
+
94
+ - Every user-editable native form control needs a persistent visible label, preferably an explicit label whose `for` value exactly matches the control `id`.
95
+ - Placeholder text, title text, aria-label, icon-only labels, and visual proximity are not substitutes for visible labels unless a strong design constraint is reported and the accessible name remains clear.
96
+ - Help text and error text must be real DOM text with stable IDs and connected through `aria-describedby` when relevant.
97
+ - Required native controls should use native `required`; the required state must also be visible in text or an explained marker. Do not rely on color alone.
98
+ - Use `aria-required` mainly for custom ARIA controls or deliberate compatibility needs; it does not enforce browser validation.
99
+ - Do not set `aria-invalid` before the user has interacted with the field or attempted submission. Set it when validation has determined the field is invalid.
100
+ - Error messages must identify what is wrong and how to fix it when the fix is known. Avoid generic text such as "Invalid" with no recovery instruction.
101
+ - Multiple submit errors should use an error summary near the top of the form or page when the project pattern supports it. Summary items should link to invalid fields, and inline errors should remain next to fields.
102
+ - Use alert or live regions only for dynamic validation or submit feedback that should be announced. Do not spam alerts on every keystroke or place interactive controls inside alerts.
103
+ - Inputs collecting information about the current user should use appropriate autocomplete tokens. Do not blindly disable autocomplete on login, checkout, contact, signup, or account forms.
104
+
105
+ <!-- mustflow-section: metadata-policy -->
106
+ ## Metadata And Structured Data Rules
107
+
108
+ Before editing page metadata, identify the rendered route, canonical production URL, visible H1 or main title, visible primary entity, locale, indexing intent, and source of page facts.
109
+
110
+ - Titles must match the visible primary topic, avoid repeated keyword stuffing, avoid stale boilerplate, and use the page's visible language.
111
+ - Descriptions must summarize the actual visible page and must not fabricate claims, guarantees, prices, ratings, dates, or features.
112
+ - Canonical URLs must be absolute production URLs for the preferred version of the same or near-duplicate content. Do not point canonical to staging, localhost, unrelated pages, wrong locale pages, redirects, 404s, noindex pages, or parameter URLs unless explicitly intended.
113
+ - Canonical, sitemap, hreflang, internal links, and social URL metadata should not contradict each other.
114
+ - Open Graph and Twitter or X title, description, URL, and image should come from the same source of truth as page metadata unless a campaign override is documented. Social images must be absolute, crawlable, and representative of the visible page.
115
+ - Prefer JSON-LD for structured data. Validate JSON syntax and ensure required properties for the chosen rich result type are present when rich-result eligibility matters.
116
+ - Robots directives such as noindex, nofollow, nosnippet, or restrictive crawl hints need explicit intent. Before removing one, check whether the page is intentionally private, duplicated, thin, internal, staged, or blocked.
117
+
118
+ <!-- mustflow-section: rejection-criteria -->
119
+ ## Review Rejection Criteria
120
+
121
+ Reject or revise the patch when any of these appear without strong justification and verification:
122
+
123
+ - New `div` or `span` interaction where a native link, button, or form control would work.
124
+ - Anchors without `href`, buttons implemented as links, links implemented as buttons, nested interactive controls, clickable icons without native controls, or site navigation using ARIA menu roles.
125
+ - Custom controls without complete accessible name, role, state, keyboard, focus, and hidden-content behavior.
126
+ - Positive `tabindex`, hidden content that remains tabbable, focusable `aria-hidden` content, or invisible focus.
127
+ - Form controls without visible labels, placeholder-only labels, disconnected help or error text, color-only required or error state, premature `aria-invalid`, or autocomplete removed without reason.
128
+ - Metadata or JSON-LD that contradicts visible content, fabricates facts, points canonical or social URL at the wrong page, disables zoom, omits page language, or accidentally noindexes a public page.
129
+
130
+ <!-- mustflow-section: postconditions -->
131
+ ## Postconditions
132
+
133
+ - Markup communicates the intended structure without relying on visual styling alone.
134
+ - Keyboard and focus behavior are preserved.
135
+ - Forms have labels and errors connected.
136
+ - Metadata and structured data reflect visible content.
137
+ - Hidden content is not reachable by keyboard when it should be inactive.
138
+ - Native controls are used unless a complete custom interaction pattern is justified.
139
+
140
+ <!-- mustflow-section: verification -->
141
+ ## Verification
142
+
143
+ Use configured oneshot command intents when available:
144
+
145
+ - `lint`
146
+ - `build`
147
+ - `test_related`
148
+ - `test`
149
+ - `docs_validate_fast`
150
+ - `mustflow_check`
151
+
152
+ Report missing accessibility, browser, or HTML validation intents when relevant.
153
+
154
+ When configured or manual verification is available, cover keyboard-only navigation with Tab, Shift+Tab, Enter, Space, Escape, Arrow keys, Home, and End where applicable. Confirm visible focus, accessible name, role, value, state, hidden-content behavior, form errors, metadata consistency, and structured data truthfulness.
155
+
156
+ <!-- mustflow-section: failure-handling -->
157
+ ## Failure Handling
158
+
159
+ - If a custom control cannot meet keyboard and focus requirements, replace it with a native element or report the blocker.
160
+ - If metadata source of truth is unclear, inspect the framework route and SEO helpers before editing.
161
+ - If form validation timing or error ownership is unclear, keep native validation behavior and report the unresolved custom validation boundary.
162
+ - If structured data facts cannot be traced to visible content or a trusted page data source, do not add them.
163
+ - If accessibility verification is unavailable, report the manual keyboard and focus checks that remain.
164
+
165
+ <!-- mustflow-section: output-format -->
166
+ ## Output Format
167
+
168
+ - Boundary checked
169
+ - Semantic, form, focus, and metadata notes
170
+ - Files changed
171
+ - Command intents run
172
+ - Skipped checks and reasons
173
+ - Remaining HTML risk
@@ -0,0 +1,149 @@
1
+ ---
2
+ mustflow_doc: skill.javascript-code-change
3
+ locale: en
4
+ canonical: true
5
+ revision: 2
6
+ lifecycle: mustflow-owned
7
+ authority: procedure
8
+ name: javascript-code-change
9
+ description: Apply this skill when JavaScript source, package module format, runtime boundary, dependency usage, async Promise handling, browser or Node behavior, bundler config, or tests are created or changed.
10
+ metadata:
11
+ mustflow_schema: "1"
12
+ mustflow_kind: procedure
13
+ pack_id: mustflow.core
14
+ skill_id: mustflow.core.javascript-code-change
15
+ command_intents:
16
+ - changes_status
17
+ - changes_diff_summary
18
+ - lint
19
+ - build
20
+ - test_related
21
+ - test
22
+ - docs_validate_fast
23
+ - mustflow_check
24
+ ---
25
+
26
+ # JavaScript Code Change
27
+
28
+ <!-- mustflow-section: purpose -->
29
+ ## Purpose
30
+
31
+ Preserve JavaScript module, runtime, package entry, Promise, cleanup, dependency, and test boundaries.
32
+
33
+ <!-- mustflow-section: use-when -->
34
+ ## Use When
35
+
36
+ - `.js`, `.mjs`, `.cjs`, package scripts, package exports, bundler config, browser code, Node code, edge code, dependency usage, or JavaScript tests change.
37
+ - The task touches `import`, `require`, `module.exports`, `exports`, `fetch`, `process`, `window`, `document`, `Buffer`, `fs`, `async`, Promise chains, or package entry metadata.
38
+
39
+ <!-- mustflow-section: do-not-use-when -->
40
+ ## Do Not Use When
41
+
42
+ - TypeScript surfaces are changed; use `typescript-code-change`.
43
+ - JavaScript files are generated artifacts that should be regenerated by a declared command.
44
+
45
+ <!-- mustflow-section: required-inputs -->
46
+ ## Required Inputs
47
+
48
+ - `package.json`, lockfile, engines, module `type`, package `exports`, bundler config, lint config, test config, and relevant entrypoints.
49
+ - Target runtime: browser, Node, worker, edge, Bun, or multi-runtime boundary.
50
+ - Runtime adapter files, source entrypoints, package docs examples, and build output layout when package entry or runtime support changes.
51
+ - Async ownership and cleanup surface when Promises, retries, timers, event listeners, streams, abort signals, background tasks, startup, shutdown, or external I/O change.
52
+ - Configured verification intents.
53
+
54
+ <!-- mustflow-section: preconditions -->
55
+ ## Preconditions
56
+
57
+ - Determine module system and runtime before editing imports or globals.
58
+ - Treat Promise and dependency changes as behavior changes unless proven otherwise.
59
+
60
+ <!-- mustflow-section: allowed-edits -->
61
+ ## Allowed Edits
62
+
63
+ - Keep ESM and CommonJS boundaries explicit and localized.
64
+ - Use browser APIs only in browser-safe files and Node APIs only in Node-safe files.
65
+ - Await, return, catch, or intentionally handle every Promise.
66
+ - Prefer existing dependencies and platform APIs over adding a new dependency.
67
+ - Keep runtime-specific APIs behind platform adapters or runtime-specific entrypoints.
68
+ - Keep package entry changes synchronized with declarations, docs examples, build output, and consumer smoke coverage when available.
69
+
70
+ <!-- mustflow-section: procedure -->
71
+ ## Procedure
72
+
73
+ 1. Read package metadata, module type, exports, bundler config, lint config, entrypoints, docs examples, and tests.
74
+ 2. Declare the touched boundary: module system, runtime, package entry, browser/Node/edge/Bun split, async flow, dependency, or test-only.
75
+ 3. Classify each changed JavaScript file as shared, Node, browser, edge, Bun, or test-only before adding imports or globals.
76
+ 4. Keep shared files portable:
77
+ - do not import or reference `node:*`, `fs`, `process`, `Buffer`, `window`, `document`, `localStorage`, DOM-only APIs, or Node streams directly;
78
+ - prefer `URL`, `URLSearchParams`, `Uint8Array`, `ArrayBuffer`, `TextEncoder`, `TextDecoder`, Web `Request`/`Response`, Web Streams, and injected dependencies when those fit the existing code.
79
+ 5. Keep runtime-specific APIs isolated:
80
+ - Node files may use Node process, filesystem, Buffer, Node crypto, and Node streams;
81
+ - browser files may use DOM, window, document, local storage, browser events, and browser fetch;
82
+ - edge files should be treated as Web API based, not as browser DOM code and not as full Node code;
83
+ - Bun-specific APIs do not prove Node, browser, or edge compatibility.
84
+ 6. Do not use runtime detection as a broad escape hatch in shared code. Prefer explicit runtime entrypoints, adapters, conditional exports, or dependency injection over a file that mixes every runtime branch.
85
+ 7. Keep environment access behind existing server/client env helpers. Do not read raw server secrets from client, shared, browser, or edge code, and do not assume `process.env` exists outside Node-oriented code.
86
+ 8. Do not mix `import`/`export` with `require`/`module.exports` outside an established interop boundary.
87
+ 9. Treat package entry metadata as public contract:
88
+ - `type`, file extensions, `main`, `module`, `browser`, `exports`, `types`, `typesVersions`, `files`, `bin`, `sideEffects`, and `engines` affect consumers;
89
+ - adding `exports` can block deep imports and should be classified as public API sensitive;
90
+ - conditional exports must keep specific conditions before generic fallbacks;
91
+ - ESM and CJS branches should expose compatible documented shapes when both are supported;
92
+ - TypeScript declaration output and docs examples must keep pointing at existing package entry files.
93
+ 10. For package entry changes, check source entrypoints, build output layout, docs import examples, TypeScript or declaration settings, bundler config, and consumer-style tests. Report missing Node ESM, Node CJS, browser bundle, edge, Bun, or TypeScript consumer verification when those targets are claimed but no configured intent exists.
94
+ 11. Treat build targets as syntax/output compatibility, not as permission to use a runtime API. A browser or edge build target does not make Node filesystem, process, Buffer, or native APIs safe.
95
+ 12. Treat implicit globals as failures.
96
+ 13. Do not discard Promises. Every Promise-producing call must be awaited, returned, joined, or intentionally supervised by the project's detached-task pattern.
97
+ 14. Do not leave `.map(async ...)` unjoined. Join with the established Promise aggregation or bounded-concurrency helper when parallel work is intended.
98
+ 15. Do not use unbounded parallelism for large external I/O fan-out. Use the local concurrency limit pattern when the workload touches HTTP, database, filesystem, queue, AI, or other external services.
99
+ 16. Propagate cancellation when the operation can outlive a request, job, stream, retry loop, timeout, or user action. Accept and forward `AbortSignal` or the repository's established cancellation token when available.
100
+ 17. Do not implement timeout as a caller-only race that leaves the real work running. Timeout behavior must cancel or abort the underlying operation when the API supports it.
101
+ 18. Put cleanup in a deterministic path. Timers, event listeners, stream readers, Node streams, temp files, locks, transactions, subscriptions, and shutdown drains need success, failure, timeout, and cancellation cleanup coverage when touched.
102
+ 19. Do not build package exports or dependency changes without checking consumers, tests, and docs examples.
103
+ 20. Choose configured verification intents that cover lint, build, tests, package entry, runtime behavior, async rejection handling, cancellation, and cleanup when available.
104
+
105
+ <!-- mustflow-section: postconditions -->
106
+ ## Postconditions
107
+
108
+ - Runtime and module boundaries are explicit.
109
+ - Promise failures are not hidden.
110
+ - Runtime-specific APIs do not leak into shared, browser, edge, or package entry code.
111
+ - Package entry changes are synchronized with tests or reported as unverified.
112
+ - Async cancellation and cleanup behavior is covered or reported as a remaining risk.
113
+ - No unnecessary dependency was added.
114
+
115
+ <!-- mustflow-section: verification -->
116
+ ## Verification
117
+
118
+ Use configured oneshot command intents when available:
119
+
120
+ - `lint`
121
+ - `build`
122
+ - `test_related`
123
+ - `test`
124
+ - `docs_validate_fast`
125
+ - `mustflow_check`
126
+
127
+ Report missing browser, Node, edge, Bun, TypeScript-consumer, package-entry, async-cancellation, or cleanup verification intents when they are relevant.
128
+
129
+ <!-- mustflow-section: failure-handling -->
130
+ ## Failure Handling
131
+
132
+ - If the module system is unclear, inspect package metadata and entrypoints before editing.
133
+ - If runtime globals are needed in shared code, isolate them behind an adapter or report the boundary conflict.
134
+ - If a shared file imports runtime-only APIs, split the runtime entry or adapter before adding more branches.
135
+ - If a package entry change breaks a documented import path, restore compatibility or report the breaking-change requirement.
136
+ - If a Promise is intentionally detached but has no rejection sink, shutdown/drain policy, or tracing context, do not detach it.
137
+ - If cancellation or cleanup cannot be proven, add or reuse the local lifecycle pattern before weakening tests.
138
+ - If dependency compatibility is unclear, classify the change as research or defer it.
139
+
140
+ <!-- mustflow-section: output-format -->
141
+ ## Output Format
142
+
143
+ - Boundary checked
144
+ - Runtime and module notes
145
+ - Async and dependency notes
146
+ - Files changed
147
+ - Command intents run
148
+ - Skipped checks and reasons
149
+ - Remaining JavaScript risk
@@ -0,0 +1,154 @@
1
+ ---
2
+ mustflow_doc: skill.python-code-change
3
+ locale: en
4
+ canonical: true
5
+ revision: 2
6
+ lifecycle: mustflow-owned
7
+ authority: procedure
8
+ name: python-code-change
9
+ description: Apply this skill when Python source, packaging, runtime version, import layout, type checking, linting, tests, or CLI entry points are created or changed.
10
+ metadata:
11
+ mustflow_schema: "1"
12
+ mustflow_kind: procedure
13
+ pack_id: mustflow.core
14
+ skill_id: mustflow.core.python-code-change
15
+ command_intents:
16
+ - changes_status
17
+ - changes_diff_summary
18
+ - lint
19
+ - build
20
+ - test_related
21
+ - test
22
+ - docs_validate_fast
23
+ - mustflow_check
24
+ ---
25
+
26
+ # Python Code Change
27
+
28
+ <!-- mustflow-section: purpose -->
29
+ ## Purpose
30
+
31
+ Preserve Python runtime, packaging, import, async resource, public API, typing, lint, and test boundaries while making a focused change.
32
+
33
+ <!-- mustflow-section: use-when -->
34
+ ## Use When
35
+
36
+ - `.py`, `pyproject.toml`, `setup.py`, `setup.cfg`, requirements files, lockfiles, tox, nox, pytest, mypy, pyright, Ruff, or Python CI config changes.
37
+ - The task touches package layout, CLI entry points, imports, type hints, dependency declarations, virtual environment assumptions, or tests.
38
+
39
+ <!-- mustflow-section: do-not-use-when -->
40
+ ## Do Not Use When
41
+
42
+ - The task only edits generated Python output that should not be maintained manually.
43
+ - The repository does not contain Python behavior and the file is only documentation.
44
+
45
+ <!-- mustflow-section: required-inputs -->
46
+ ## Required Inputs
47
+
48
+ - Python version source: `requires-python`, `.python-version`, tool version files, CI matrix, or container base image.
49
+ - Packaging and dependency files, test config, lint config, and type checker config.
50
+ - Package layout: `src` layout, flat layout, namespace package, distribution name, import package name, package discovery settings, CLI entry points, plugin entry points, and nearby tests.
51
+ - Async ownership and resource cleanup surface when coroutines, tasks, context managers, sessions, clients, pools, files, async generators, subprocesses, or logging change.
52
+ - Public contract surface when imports, signatures, exceptions, return shapes, CLI behavior, config, environment variables, extras, Python version support, or typing stubs change.
53
+ - Configured verification intents.
54
+
55
+ <!-- mustflow-section: preconditions -->
56
+ ## Preconditions
57
+
58
+ - Determine the lowest supported Python version before choosing syntax or typing features.
59
+ - Read package layout and import style before editing imports.
60
+ - Treat global machine Python state as irrelevant unless the project explicitly declares it.
61
+
62
+ <!-- mustflow-section: allowed-edits -->
63
+ ## Allowed Edits
64
+
65
+ - Keep existing packaging tools and layout unless the user explicitly asks for a packaging migration.
66
+ - Add or adjust type hints at public boundaries, complex return values, and external input boundaries.
67
+ - Follow existing test style, fixtures, parametrization, and lint/type strictness.
68
+ - Do not lower Ruff, mypy, pyright, pytest, or packaging strictness to hide a failure.
69
+ - Keep import fixes in package metadata, package discovery, entry points, or test invocation contracts instead of path hacks.
70
+ - Make resource ownership explicit: code closes only the resources it creates.
71
+
72
+ <!-- mustflow-section: procedure -->
73
+ ## Procedure
74
+
75
+ 1. Read project metadata, Python version constraints, dependency files, and test/lint/type configs.
76
+ 2. Identify the boundary touched: runtime version, package API, import root, packaging metadata, CLI entry, test fixture, async resource ownership, external input, or dependency contract.
77
+ 3. For packaging and import changes, separate the distribution name from the import package name. Check package directory mapping, package discovery settings, namespace package behavior, package data, entry points, optional dependencies, and `requires-python` before touching imports.
78
+ 4. Treat `src` layout as an installation contract. Importable code under `src/` should be tested through the supported installed-package path, not by making repository files accidentally importable from the working directory.
79
+ 5. Match existing package layout and import conventions. Do not add `sys.path`, `site.addsitedir`, `PYTHONPATH`, pytest `pythonpath`, ad hoc import loading, or test `conftest.py` import hacks to make package imports pass.
80
+ 6. Do not add `__init__.py` to tests as a blind fix. Add it only when tests are intentionally a package and the import-mode behavior remains explicit.
81
+ 7. For packaging changes, distinguish development and release contracts:
82
+ - editable installs prove the local development path;
83
+ - wheel installs or equivalent built artifacts prove the release path;
84
+ - entry point, dependency, optional dependency, metadata, and package data changes require reinstall-oriented verification when a configured intent exists;
85
+ - installed console scripts or plugin entry points should be smoke-tested through the installed entry point contract, not by directly running a source file.
86
+ 8. Verify import origin when packaging risk is present. The public package should resolve from the installed environment intended by the project, not from accidental repository-root files.
87
+ 9. Validate unknown external data before treating it as typed domain data.
88
+ 10. Preserve async and resource ownership:
89
+ - every coroutine is awaited, returned by contract, or scheduled as an owned and tracked task;
90
+ - raw background task creation is allowed only through the project's owner or spawn helper, a task group, or an equivalent lifecycle mechanism;
91
+ - background tasks keep a strong reference, have a shutdown path, and retrieve failures instead of leaving never-retrieved exceptions;
92
+ - cancellation is control flow, so cleanup uses `finally` and cancellation is re-raised after cleanup unless suppression is the documented behavior;
93
+ - async functions do not call blocking I/O, blocking sleeps, long CPU work, or blocking subprocess waits directly unless the project has an explicit executor or isolation pattern;
94
+ - context managers and async context managers do not suppress exceptions unless suppression is the feature;
95
+ - context-manager helpers that catch exceptions for logging re-raise after logging;
96
+ - early-exit async generators have an explicit close path.
97
+ 11. Preserve traceback evidence. Logging inside exception handlers should retain exception information instead of logging only the exception message.
98
+ 12. Preserve public contracts:
99
+ - treat public imports, public signatures, exceptions, return shapes, CLI behavior, entry points, config keys, environment variables, dependency metadata, extras, Python version support, and typing stubs as compatibility-sensitive;
100
+ - do not change sync functions into async functions, accepted input shapes, nullable behavior, documented exception types, tuple/dict/dataclass return shapes, config precedence, or environment variable semantics without a compatibility review;
101
+ - typed packages should keep runtime and typing surfaces aligned, including `py.typed` and stubs when present.
102
+ 13. Avoid mutable default arguments, broad `except Exception: pass`, broad `BaseException` catches outside process boundaries, global state hidden behind module imports, and path handling that ignores existing `pathlib` or OS conventions.
103
+ 14. Use `# type: ignore[...]` only when tightly scoped, justified, and consistent with local policy.
104
+ 15. If packaging, public API, CLI, config, or typing contracts change, synchronize README examples, entry point tests, build metadata, docs, fixtures, and downstream-style examples that describe installation or usage.
105
+ 16. Choose configured verification intents that cover formatting, lint, type checking, tests, package build, installed-package smoke checks, and CLI smoke risk when available.
106
+
107
+ <!-- mustflow-section: postconditions -->
108
+ ## Postconditions
109
+
110
+ - The code respects the declared Python version and packaging layout.
111
+ - Imports work from the project-supported execution path.
112
+ - Packaging changes distinguish development imports from release artifact imports.
113
+ - Async tasks, context managers, files, clients, pools, subprocesses, and generators have visible ownership and cleanup.
114
+ - Public API, CLI, config, environment, dependency metadata, and typing contract changes are called out.
115
+ - Type and lint strictness are not weakened.
116
+ - Tests or skipped verification are tied to the changed behavior.
117
+
118
+ <!-- mustflow-section: verification -->
119
+ ## Verification
120
+
121
+ Use configured oneshot command intents when available:
122
+
123
+ - `lint`
124
+ - `build`
125
+ - `test_related`
126
+ - `test`
127
+ - `docs_validate_fast`
128
+ - `mustflow_check`
129
+
130
+ Report missing package, type, or test intents rather than inventing raw tool commands.
131
+
132
+ <!-- mustflow-section: failure-handling -->
133
+ ## Failure Handling
134
+
135
+ - If import resolution fails, inspect package metadata and test invocation before adding path hacks.
136
+ - If a test only passes because repository root, `src`, or `tests` is injected into import paths, reject the fix and repair packaging or test layout instead.
137
+ - If packaging correctness matters but only repository-root tests can run, report that wheel or installed-artifact verification is missing.
138
+ - If the supported Python version blocks a syntax choice, rewrite to the supported form.
139
+ - If third-party stubs or package metadata are wrong, document the local workaround and keep it narrow.
140
+ - If a background task lacks owner, shutdown, strong reference, or exception retrieval, do not add it.
141
+ - If cancellation or context-manager behavior is swallowed accidentally, restore propagation or document the intentional suppression contract.
142
+ - If resource cleanup cannot be proven, use the project's context manager, exit stack, fixture, or lifecycle pattern before broadening tests.
143
+ - If public contracts change without compatibility evidence, stop and report the breaking-change or deprecation requirement.
144
+
145
+ <!-- mustflow-section: output-format -->
146
+ ## Output Format
147
+
148
+ - Boundary checked
149
+ - Runtime and packaging assumptions
150
+ - Files changed
151
+ - Type, lint, and import notes
152
+ - Command intents run
153
+ - Skipped checks and reasons
154
+ - Remaining Python risk