@morsa/guidance-bank 0.2.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/LICENSE +21 -0
- package/README.md +135 -0
- package/bin/gbank.js +3 -0
- package/dist/cli/commands/init.js +27 -0
- package/dist/cli/commands/mcpServe.js +8 -0
- package/dist/cli/commands/stats.js +92 -0
- package/dist/cli/index.js +67 -0
- package/dist/cli/postinstall.js +24 -0
- package/dist/cli/prompts/initPrompts.js +89 -0
- package/dist/cli/prompts/providerAvailability.js +31 -0
- package/dist/core/audit/summarizeEntryContent.js +43 -0
- package/dist/core/audit/types.js +1 -0
- package/dist/core/bank/canonicalEntry.js +106 -0
- package/dist/core/bank/integration.js +16 -0
- package/dist/core/bank/layout.js +159 -0
- package/dist/core/bank/lifecycle.js +24 -0
- package/dist/core/bank/manifest.js +37 -0
- package/dist/core/bank/project.js +105 -0
- package/dist/core/bank/types.js +6 -0
- package/dist/core/context/contextEntryResolver.js +140 -0
- package/dist/core/context/contextTextRenderer.js +116 -0
- package/dist/core/context/detectProjectContext.js +118 -0
- package/dist/core/context/resolveContextService.js +138 -0
- package/dist/core/context/types.js +1 -0
- package/dist/core/init/initService.js +112 -0
- package/dist/core/init/initTypes.js +1 -0
- package/dist/core/projects/createBankDeriveGuidance/index.js +47 -0
- package/dist/core/projects/createBankDeriveGuidance/shared/general.js +49 -0
- package/dist/core/projects/createBankDeriveGuidance/shared/typescript.js +18 -0
- package/dist/core/projects/createBankDeriveGuidance/stacks/angular.js +252 -0
- package/dist/core/projects/createBankDeriveGuidance/stacks/ios.js +254 -0
- package/dist/core/projects/createBankDeriveGuidance/stacks/nextjs.js +220 -0
- package/dist/core/projects/createBankDeriveGuidance/stacks/nodejs.js +221 -0
- package/dist/core/projects/createBankDeriveGuidance/stacks/other.js +34 -0
- package/dist/core/projects/createBankDeriveGuidance/stacks/react.js +214 -0
- package/dist/core/projects/createBankFlow.js +252 -0
- package/dist/core/projects/createBankIterationPrompt.js +294 -0
- package/dist/core/projects/createBankPrompt.js +95 -0
- package/dist/core/projects/createFlowPhases.js +28 -0
- package/dist/core/projects/discoverCurrentProjectBank.js +43 -0
- package/dist/core/projects/discoverExistingGuidance.js +99 -0
- package/dist/core/projects/discoverProjectEvidence.js +87 -0
- package/dist/core/projects/discoverRecentCommits.js +28 -0
- package/dist/core/projects/findReferenceProjects.js +42 -0
- package/dist/core/projects/guidanceStrategies.js +29 -0
- package/dist/core/projects/identity.js +16 -0
- package/dist/core/projects/providerProjectGuidance.js +82 -0
- package/dist/core/providers/providerRegistry.js +51 -0
- package/dist/core/providers/types.js +1 -0
- package/dist/core/stats/statsService.js +117 -0
- package/dist/core/sync/syncService.js +145 -0
- package/dist/core/sync/syncTypes.js +1 -0
- package/dist/core/upgrade/upgradeService.js +134 -0
- package/dist/integrations/claudeCode/install.js +78 -0
- package/dist/integrations/codex/install.js +80 -0
- package/dist/integrations/commandRunner.js +32 -0
- package/dist/integrations/cursor/install.js +118 -0
- package/dist/integrations/shared.js +20 -0
- package/dist/mcp/config.js +19 -0
- package/dist/mcp/createMcpServer.js +31 -0
- package/dist/mcp/launcher.js +49 -0
- package/dist/mcp/registerTools.js +33 -0
- package/dist/mcp/serverMetadata.js +7 -0
- package/dist/mcp/tools/auditUtils.js +49 -0
- package/dist/mcp/tools/createBankApply.js +106 -0
- package/dist/mcp/tools/createBankToolRuntime.js +115 -0
- package/dist/mcp/tools/createBankToolSchemas.js +234 -0
- package/dist/mcp/tools/entryMutationHelpers.js +44 -0
- package/dist/mcp/tools/registerBankManifestTool.js +47 -0
- package/dist/mcp/tools/registerClearProjectBankTool.js +73 -0
- package/dist/mcp/tools/registerCreateBankTool.js +240 -0
- package/dist/mcp/tools/registerDeleteEntryTool.js +98 -0
- package/dist/mcp/tools/registerDeleteGuidanceSourceTool.js +120 -0
- package/dist/mcp/tools/registerListEntriesTool.js +94 -0
- package/dist/mcp/tools/registerReadEntryTool.js +99 -0
- package/dist/mcp/tools/registerResolveContextTool.js +128 -0
- package/dist/mcp/tools/registerSetProjectStateTool.js +121 -0
- package/dist/mcp/tools/registerSyncBankTool.js +113 -0
- package/dist/mcp/tools/registerUpgradeBankTool.js +89 -0
- package/dist/mcp/tools/registerUpsertRuleTool.js +100 -0
- package/dist/mcp/tools/registerUpsertSkillTool.js +102 -0
- package/dist/mcp/tools/sharedSchemas.js +13 -0
- package/dist/shared/errors.js +18 -0
- package/dist/shared/paths.js +11 -0
- package/dist/storage/atomicWrite.js +15 -0
- package/dist/storage/auditLogger.js +20 -0
- package/dist/storage/auditStore.js +22 -0
- package/dist/storage/bankRepository.js +168 -0
- package/dist/storage/entryStore.js +142 -0
- package/dist/storage/manifestStore.js +30 -0
- package/dist/storage/projectBankStore.js +55 -0
- package/dist/storage/providerIntegrationStore.js +22 -0
- package/dist/storage/safeFs.js +202 -0
- package/package.json +64 -0
- package/scripts/postinstall.js +20 -0
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
export const ANGULAR_DERIVE_GUIDANCE = `## Angular Guidance
|
|
2
|
+
|
|
3
|
+
Focus on Angular patterns: components, templates, routing, DI, RxJS/signals, forms, testing, and architecture boundaries.
|
|
4
|
+
|
|
5
|
+
## Codebase Exploration Before Generating
|
|
6
|
+
|
|
7
|
+
### Structure Discovery
|
|
8
|
+
|
|
9
|
+
1. List root folders.
|
|
10
|
+
2. Identify where Angular source code lives (for example: src/, apps/, libs/, projects/).
|
|
11
|
+
3. Map feature/module hierarchy 2-3 levels deep.
|
|
12
|
+
4. Record the exact folder names and paths you found.
|
|
13
|
+
|
|
14
|
+
### Pattern Extraction (Read Real Files)
|
|
15
|
+
|
|
16
|
+
For each category, read 2-3 representative files and extract reusable decisions:
|
|
17
|
+
|
|
18
|
+
| Category | What to Find | What to Extract |
|
|
19
|
+
|----------|--------------|-----------------|
|
|
20
|
+
| Feature structure | Feature folders and boundaries | Placement rules for components/services/models/routes |
|
|
21
|
+
| Components | Component model and container/presentational split | Selector naming, inputs/outputs, host bindings |
|
|
22
|
+
| Templates | Control flow and binding patterns | @if/@for usage, track strategy, async pipe strategy, event handling |
|
|
23
|
+
| Routing | Route configs and lazy loading | loadChildren/loadComponent conventions, guards/resolvers |
|
|
24
|
+
| State layer | Signals/RxJS/store/effects | State ownership, side-effect boundaries, update patterns, interop boundaries |
|
|
25
|
+
| Services/API | HttpClient and data services | DI conventions, mapping, error handling, retries |
|
|
26
|
+
| Forms | Reactive forms and validators | Form initialization, validation style, submit flow |
|
|
27
|
+
| Styling | SCSS/CSS organization | Token usage, naming convention, layout patterns |
|
|
28
|
+
| Performance | Change detection and template costs | OnPush/default usage, template computation boundaries |
|
|
29
|
+
| Testing | Spec structure and helpers | Test location, mocking style, critical test expectations |
|
|
30
|
+
|
|
31
|
+
### Config and Tooling Analysis (Angular-Specific)
|
|
32
|
+
|
|
33
|
+
Read these files if present:
|
|
34
|
+
- package.json and lockfile
|
|
35
|
+
- angular.json / workspace.json / project.json
|
|
36
|
+
- eslint config and formatting config
|
|
37
|
+
- src/main.ts, app config, bootstrap files
|
|
38
|
+
- app.routes.ts and route setup files
|
|
39
|
+
- nx.json / turbo.json (if monorepo)
|
|
40
|
+
- workspace lint rules for boundaries (for example \`@nx/enforce-module-boundaries\`)
|
|
41
|
+
- tailwind config (if present) and shared style token files
|
|
42
|
+
|
|
43
|
+
### Version and Feature Gate (Angular)
|
|
44
|
+
|
|
45
|
+
Before turning patterns into rules, verify what is actually used in this codebase:
|
|
46
|
+
- Angular version from dependencies and workspace config.
|
|
47
|
+
- Component style in real files: standalone, NgModule, or mixed.
|
|
48
|
+
- State style in real files: signals, RxJS streams, store/effects, or mixed.
|
|
49
|
+
- Use standalone APIs only when version and code evidence support them (Angular 14+ and real standalone usage).
|
|
50
|
+
- Use template control flow (\`@if/@for/@switch\`) only when version and code evidence support it (Angular 17+ with real usage/migration evidence).
|
|
51
|
+
- Use signals only when version and code evidence support them (Angular 16+ with real imports/usages like \`signal\`, \`computed\`, \`effect\`).
|
|
52
|
+
- Use \`takeUntilDestroyed\` for subscription cleanup only when version and code evidence support it (Angular 16+ with \`DestroyRef\`/interop usage); otherwise keep the existing local cleanup pattern.
|
|
53
|
+
- If a feature is not supported by version and code evidence, do not generate rules that require it.
|
|
54
|
+
|
|
55
|
+
### Red Flag Detection (Angular-Specific)
|
|
56
|
+
|
|
57
|
+
Search for recurring issues that should become explicit rules:
|
|
58
|
+
- TODO/FIXME/HACK patterns
|
|
59
|
+
- mixed state patterns without clear ownership
|
|
60
|
+
- mixed usage of \`inject()\` and constructor DI without a clear project convention
|
|
61
|
+
- business logic in templates instead of component/service layer
|
|
62
|
+
- \`@for\` loops without stable tracking strategy when control flow syntax is used
|
|
63
|
+
- ad-hoc dependency creation instead of DI
|
|
64
|
+
- manual subscriptions without the project-approved cleanup strategy (\`takeUntilDestroyed\` when supported, otherwise local equivalent)
|
|
65
|
+
- nested subscriptions instead of flattened stream composition (\`switchMap\`/\`concatMap\`/\`exhaustMap\` or local effect/store patterns)
|
|
66
|
+
- duplicated state sources across signals and observables without explicit ownership boundaries
|
|
67
|
+
- duplicated API mapping logic
|
|
68
|
+
- direct HttpClient usage in templates/components when a service abstraction exists
|
|
69
|
+
- browser-only APIs (\`window\`, \`document\`, \`localStorage\`) used without platform guards in SSR-capable projects
|
|
70
|
+
- DOM side effects inside constructors instead of lifecycle/hooks with platform checks
|
|
71
|
+
- large shared modules with unclear responsibility
|
|
72
|
+
- cross-feature imports that violate established boundaries
|
|
73
|
+
- hardcoded design values where project tokens/variables are the standard
|
|
74
|
+
- expensive template-bound computations or repeated function calls in hot render paths
|
|
75
|
+
- inconsistent API error contract across handlers/services/interceptors/UI layer
|
|
76
|
+
- error handling and notification behavior duplicated across features
|
|
77
|
+
- side effects in \`computed\`/\`effect\` without clear boundaries and intent
|
|
78
|
+
|
|
79
|
+
### Analysis Checklist (Angular Project)
|
|
80
|
+
|
|
81
|
+
Document these with file path evidence:
|
|
82
|
+
|
|
83
|
+
- Architecture and boundary model.
|
|
84
|
+
- Component and template model.
|
|
85
|
+
- Routing and lazy-loading strategy.
|
|
86
|
+
- State and async model (ownership, subscriptions, interop).
|
|
87
|
+
- Service/API model and error-contract boundaries.
|
|
88
|
+
- SSR/hydration and browser-only API handling strategy (if SSR-capable).
|
|
89
|
+
- Change detection and template performance patterns.
|
|
90
|
+
- Styling mode and design-token strategy.
|
|
91
|
+
- Testing strategy and depth by module type.
|
|
92
|
+
- Main recurring anti-patterns and where they appear.
|
|
93
|
+
|
|
94
|
+
Before final output, gather concrete evidence for each applicable item.
|
|
95
|
+
If evidence remains partial, continue conservatively and mark uncertainty with \`[VERIFY: ...]\` instead of blocking output.
|
|
96
|
+
|
|
97
|
+
### Generation Locks (Prevent Architecture Drift)
|
|
98
|
+
|
|
99
|
+
Apply these constraints when generating rules and skills:
|
|
100
|
+
- Preserve detected architecture and import/workspace boundaries.
|
|
101
|
+
- Preserve component/template interaction model (including stable loop tracking when \`@for\` is used).
|
|
102
|
+
- Preserve state ownership and async boundaries (subscriptions, interop, side effects).
|
|
103
|
+
- Preserve routing loading strategy.
|
|
104
|
+
- Preserve SSR/browser safety boundaries in SSR-capable projects.
|
|
105
|
+
- Preserve styling system and token conventions.
|
|
106
|
+
- Avoid high-impact workflow changes unless strongly supported by project evidence.
|
|
107
|
+
|
|
108
|
+
## Skill Candidates (Angular)
|
|
109
|
+
|
|
110
|
+
Generate these skills with actual project paths and Angular-specific workflow steps:
|
|
111
|
+
Generate only skills that have clear project evidence and practical value.
|
|
112
|
+
For small/low-confidence projects, 2-4 core skills are usually enough.
|
|
113
|
+
|
|
114
|
+
### adding-feature
|
|
115
|
+
- Include actual feature folder structure used in this project.
|
|
116
|
+
- Show how to add component/service/route wiring using existing local patterns.
|
|
117
|
+
- Include integration with state layer and tests where applicable.
|
|
118
|
+
|
|
119
|
+
### adding-service
|
|
120
|
+
- Include service and API client structure used in this project.
|
|
121
|
+
- Show DI pattern, request/response mapping, and error handling.
|
|
122
|
+
- Include mocking/test strategy for service behavior.
|
|
123
|
+
|
|
124
|
+
### code-review
|
|
125
|
+
- Include Angular-specific review checklist based on project patterns.
|
|
126
|
+
- Cover template complexity, state ownership, subscription safety, and route boundaries.
|
|
127
|
+
|
|
128
|
+
### common-anti-patterns
|
|
129
|
+
- Include recurring Angular anti-patterns from this project.
|
|
130
|
+
- Pair each anti-pattern with preferred local alternative.
|
|
131
|
+
|
|
132
|
+
### troubleshooting
|
|
133
|
+
- Include common Angular build/runtime/test issues for this codebase.
|
|
134
|
+
- Include where to inspect first when these issues happen.
|
|
135
|
+
|
|
136
|
+
### [framework-specific]
|
|
137
|
+
Generate 1-3 extra skills based on actual stack usage:
|
|
138
|
+
- signals-patterns (if signals are primary)
|
|
139
|
+
- rxjs-patterns (if RxJS orchestration is primary)
|
|
140
|
+
- ngrx-patterns (if NgRx is present)
|
|
141
|
+
- forms-patterns (if complex forms are central)
|
|
142
|
+
- monorepo-workflows (if apps/libs pattern exists)
|
|
143
|
+
|
|
144
|
+
### enrichment-tasks (optional)
|
|
145
|
+
- Generate this only when the user explicitly asks for enrichment, or when analysis shows a clear gap in the existing rule/skill bank.
|
|
146
|
+
|
|
147
|
+
## Rule Generation Requirements
|
|
148
|
+
|
|
149
|
+
### What NOT to Include
|
|
150
|
+
|
|
151
|
+
- Do not invent generic philosophy ("clean code", "think about user").
|
|
152
|
+
- Do not duplicate what linters/formatters fully enforce.
|
|
153
|
+
- Do not add rules without evidence from codebase patterns.
|
|
154
|
+
- Do not repeat the same rule across multiple rule topics.
|
|
155
|
+
- Do not propose Angular APIs that are incompatible with detected project version and architecture mode.
|
|
156
|
+
- Do not force Angular workflow-changing migrations unless they are already reflected in project direction and evidence.
|
|
157
|
+
|
|
158
|
+
### Rule Content Requirements
|
|
159
|
+
|
|
160
|
+
Keep this section Angular-specific:
|
|
161
|
+
- Capture decisions tied to Angular architecture, templates, routing, state, and DI boundaries.
|
|
162
|
+
- Prefer Angular-native patterns and terminology over generic cross-stack wording.
|
|
163
|
+
- Highlight recurring Angular anti-patterns and safer local alternatives.
|
|
164
|
+
- Include interaction, lifecycle, subscription, and performance constraints only when supported by project evidence.
|
|
165
|
+
- Keep rules compatible with current Angular workflow unless stronger project evidence justifies change.
|
|
166
|
+
|
|
167
|
+
## Algorithm: Analysis -> Rules (Angular)
|
|
168
|
+
|
|
169
|
+
Follow this systematic approach for Angular projects:
|
|
170
|
+
|
|
171
|
+
**Structure -> Architecture Rules:**
|
|
172
|
+
1. Identify repeated folder/module structures across features.
|
|
173
|
+
2. Define placement rules for components, services, models, and routes.
|
|
174
|
+
3. Document cross-feature boundaries and allowed dependencies.
|
|
175
|
+
|
|
176
|
+
**Components/Templates -> UI Rules:**
|
|
177
|
+
1. Scan representative component and template files.
|
|
178
|
+
2. Extract repeated patterns for bindings, control flow, and composition.
|
|
179
|
+
3. Convert repeated high-quality patterns into concise rules.
|
|
180
|
+
|
|
181
|
+
**State/Async -> Data Flow Rules:**
|
|
182
|
+
1. Identify how state is owned and updated (signals/RxJS/store).
|
|
183
|
+
2. Identify where side effects live and how async errors are handled.
|
|
184
|
+
3. Identify subscription orchestration and signals/observables interop boundaries.
|
|
185
|
+
4. Generate rules that keep ownership, side effects, and interop boundaries explicit.
|
|
186
|
+
|
|
187
|
+
**Configs -> Architectural Constraints:**
|
|
188
|
+
1. Inspect Angular/workspace/eslint settings.
|
|
189
|
+
2. Promote only meaningful architectural constraints (aliases, boundaries, layering).
|
|
190
|
+
3. Avoid restating trivial formatter/linter-only behavior.
|
|
191
|
+
|
|
192
|
+
**Performance -> Change Detection and Template Rules:**
|
|
193
|
+
1. Identify dominant change detection strategy (OnPush/default) by module type.
|
|
194
|
+
2. Detect repeated template performance issues (heavy bindings, repeated function calls, unstable loops).
|
|
195
|
+
3. Generate concise rules that improve performance without forcing architectural rewrites.
|
|
196
|
+
|
|
197
|
+
**Red Flags -> Safety Rules:**
|
|
198
|
+
1. If the same anti-pattern appears repeatedly, define "Avoid X, do Y instead".
|
|
199
|
+
2. Tie alternatives to existing utilities/patterns used in this codebase.
|
|
200
|
+
|
|
201
|
+
**Tests -> Testing Rules:**
|
|
202
|
+
1. Identify where tests live and which module types are covered.
|
|
203
|
+
2. Extract common spec patterns, helper usage, and minimal expected coverage.
|
|
204
|
+
3. Require tests for module types that are consistently tested in this project.
|
|
205
|
+
|
|
206
|
+
## Recommended Rule Topics (Angular Project)
|
|
207
|
+
|
|
208
|
+
Split by topic:
|
|
209
|
+
Generate only topics that are supported by concrete project evidence.
|
|
210
|
+
|
|
211
|
+
| Topic | Covers (Angular-Specific) |
|
|
212
|
+
|------|----------------------------|
|
|
213
|
+
| \`architecture\` | feature boundaries, module placement, dependency direction |
|
|
214
|
+
| \`components\` | standalone patterns, selector/file naming, composition |
|
|
215
|
+
| \`templates\` | binding rules, control flow style, template complexity limits |
|
|
216
|
+
| \`routing\` | lazy loading, guards/resolvers, route organization |
|
|
217
|
+
| \`state-management\` | signals/RxJS/store ownership and side-effect boundaries |
|
|
218
|
+
| \`state-interop\` | signals/observables bridge boundaries and ownership consistency |
|
|
219
|
+
| \`services-data\` | API services, mapping, interceptors, error handling |
|
|
220
|
+
| \`performance\` | change detection usage, template performance boundaries |
|
|
221
|
+
| \`forms\` | reactive forms architecture, validation and submit flow |
|
|
222
|
+
| \`styling\` | SCSS/CSS structure, token usage, naming convention |
|
|
223
|
+
| \`testing\` | spec placement, test helpers, minimum critical checks |
|
|
224
|
+
| \`error-handling\` | error mapping, user messages, retry/logging boundaries |
|
|
225
|
+
| \`ssr-browser-boundaries\` | browser-only API guards and platform-safe behavior in SSR-capable projects |
|
|
226
|
+
| \`i18n\` | localization key usage and string handling (if applicable) |
|
|
227
|
+
|
|
228
|
+
## Context-to-Rule/Skill Mapping (Angular)
|
|
229
|
+
|
|
230
|
+
Use this mapping to decide what files to generate:
|
|
231
|
+
Generate only skills that are supported by concrete project evidence.
|
|
232
|
+
|
|
233
|
+
| Found in Angular Codebase | Generate Rule Topic | Generate Skill |
|
|
234
|
+
|--------------------------|---------------------|----------------|
|
|
235
|
+
| Standalone component pattern | \`components\`, \`templates\` | \`adding-feature\` |
|
|
236
|
+
| NgModule-heavy feature setup | \`architecture\`, \`components\` | \`adding-feature\` |
|
|
237
|
+
| Nx workspace with boundary rules | \`architecture\` | \`monorepo-workflows\` |
|
|
238
|
+
| Signals-based state | \`state-management\` | \`signals-patterns\` |
|
|
239
|
+
| RxJS stream orchestration | \`state-management\` | \`rxjs-patterns\` |
|
|
240
|
+
| NgRx store/effects | \`state-management\` | \`ngrx-patterns\` |
|
|
241
|
+
| Signals/RxJS interop boundaries | \`state-interop\`, \`state-management\` | \`code-review\` |
|
|
242
|
+
| Structured API services | \`services-data\` | \`adding-service\` |
|
|
243
|
+
| Complex reactive forms | \`forms\` | \`forms-patterns\` |
|
|
244
|
+
| OnPush-dominant components | \`components\`, \`templates\` | \`code-review\` |
|
|
245
|
+
| Repeated template performance issues | \`performance\`, \`templates\` | \`troubleshooting\` |
|
|
246
|
+
| Tailwind utility-first styling | \`styling\` | \`code-review\` |
|
|
247
|
+
| BEM-dominant styling conventions | \`styling\` | \`code-review\` |
|
|
248
|
+
| Route guards/resolvers usage | \`routing\` | \`code-review\` |
|
|
249
|
+
| SSR/browser platform guards | \`ssr-browser-boundaries\` | \`troubleshooting\` |
|
|
250
|
+
| Repeated runtime/build issues | \`error-handling\` | \`troubleshooting\` |
|
|
251
|
+
| Repeated unsafe patterns | \`error-handling\` | \`common-anti-patterns\` |
|
|
252
|
+
`;
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
export const IOS_DERIVE_GUIDANCE = `## iOS Guidance
|
|
2
|
+
|
|
3
|
+
Focus on iOS/Swift patterns: SwiftUI, UIKit, architecture boundaries, state and async flow, navigation, services, testing, and UI boundaries.
|
|
4
|
+
Treat SwiftUI, UIKit, TCA, MVVM, coordinators, and KMM as possible branches, not defaults. Promote only patterns that are supported by file-path evidence in this codebase.
|
|
5
|
+
|
|
6
|
+
## Codebase Exploration Before Generating
|
|
7
|
+
|
|
8
|
+
### Structure Discovery
|
|
9
|
+
|
|
10
|
+
1. List contents of the root directory.
|
|
11
|
+
2. Identify main source folders (for example: \`Sources/\`, \`Features/\`, \`App/\`, \`Modules/\`).
|
|
12
|
+
3. Map the folder hierarchy 2-3 levels deep.
|
|
13
|
+
4. Record the exact folder names and paths you found.
|
|
14
|
+
|
|
15
|
+
### Pattern Extraction (Read Actual Files)
|
|
16
|
+
|
|
17
|
+
For each category, read 2-3 representative Swift files and extract patterns:
|
|
18
|
+
|
|
19
|
+
| Category | What to Find | What to Extract |
|
|
20
|
+
|----------|--------------|-----------------|
|
|
21
|
+
| Features/Screens | Feature folders (\`*View.swift\`, \`*ViewModel.swift\`, \`*Reducer.swift\`, \`*Coordinator.swift\`) | Screen/module structure and the actual local architecture pattern |
|
|
22
|
+
| Services | Service files (\`*Service.swift\`, \`*Actor.swift\`) | Protocol abstraction, actor usage, async/await |
|
|
23
|
+
| Views | SwiftUI views (\`*View.swift\`) | View composition, modifiers, environment usage |
|
|
24
|
+
| Models/Entities | Entity files (\`*Entity.swift\`, \`*Model.swift\`) | Codable, Equatable, Identifiable conformances |
|
|
25
|
+
| Tests | Test files (\`*Tests.swift\`) | XCTest structure, mocking, and any framework-specific helpers actually in use |
|
|
26
|
+
| Navigation | Coordinator/Router files | NavigationStack, NavigationPath, coordinator, tab flow, or custom navigation ownership |
|
|
27
|
+
| Dependencies | DI files (\`*Dependency.swift\`, \`*Client.swift\`, container or factory files) | TCA Dependencies, factories, constructor injection, or custom DI container |
|
|
28
|
+
| Shared Modules | Shared components or modules folders | Reusable SwiftUI/UIKit components, styling tokens, app-wide primitives |
|
|
29
|
+
| Platform Integration | App lifecycle, notifications, widgets, extensions, deep links | Runtime boundaries and platform-specific integration points |
|
|
30
|
+
| KMM Integration | KMM wrapper files | ResultWrapper handling, entity mapping, only if present |
|
|
31
|
+
|
|
32
|
+
### Config and Dependency Analysis (iOS-Specific)
|
|
33
|
+
|
|
34
|
+
Read these iOS project files if they exist:
|
|
35
|
+
- \`Package.swift\` (SPM dependencies and targets)
|
|
36
|
+
- \`Podfile\` (CocoaPods dependencies)
|
|
37
|
+
- \`*.xcodeproj\` / \`*.xcworkspace\` / \`project.pbxproj\`
|
|
38
|
+
- \`Cartfile\` (Carthage, if used)
|
|
39
|
+
- app entry point: \`@main App.swift\`, \`AppDelegate.swift\`, \`SceneDelegate.swift\`
|
|
40
|
+
- architecture entry points only when present: \`AppReducer.swift\`, \`AppView.swift\`, root coordinator, root router
|
|
41
|
+
- build configs: \`*.xcconfig\`, \`Info.plist\`, build phases
|
|
42
|
+
- linter configs: \`.swiftlint.yml\`, \`.swiftformat\`
|
|
43
|
+
- platform integration configs: widget/extension targets, deep-link registration, notification setup
|
|
44
|
+
- KMM: \`shared/\` folder, \`KMMWrapper.swift\`, framework imports
|
|
45
|
+
|
|
46
|
+
### Version and Feature Gate (iOS)
|
|
47
|
+
|
|
48
|
+
Before turning patterns into rules, verify what is actually used in this codebase:
|
|
49
|
+
- UI framework mode: SwiftUI, UIKit, or mixed.
|
|
50
|
+
- Architecture style: TCA, MVVM, MVC, VIPER, Clean, coordinator-driven, lightweight screen logic, or mixed.
|
|
51
|
+
- Async style: async/await, Combine, callbacks, or mixed.
|
|
52
|
+
- Dependency pattern: TCA Dependencies, Resolver/Factory, constructor injection, manual injection, or mixed.
|
|
53
|
+
- Navigation ownership: NavigationStack, coordinator/router, UIKit navigation controller, or mixed.
|
|
54
|
+
- Platform surface: app-only, app + widgets/extensions, deep links, notifications, or mixed.
|
|
55
|
+
- Do not force TCA, MVVM, coordinators, KMM, or any other architecture pattern unless project evidence supports them.
|
|
56
|
+
- If the project is simple SwiftUI/UIKit without a heavyweight architecture, preserve that simplicity instead of inventing extra layers.
|
|
57
|
+
|
|
58
|
+
### Red Flag Detection (Swift-Specific)
|
|
59
|
+
|
|
60
|
+
Search for recurring iOS/Swift problems that should become explicit rules:
|
|
61
|
+
- \`// TODO:\`, \`// FIXME:\`, \`// HACK:\` comments
|
|
62
|
+
- \`// swiftlint:disable\` usage
|
|
63
|
+
- \`@MainActor\` missing where needed, or overused
|
|
64
|
+
- force unwraps \`!\` outside of tests or IBOutlets
|
|
65
|
+
- \`print()\` statements in production code
|
|
66
|
+
- hardcoded strings that should be localized
|
|
67
|
+
- hardcoded colors/spacing where shared tokens/components exist
|
|
68
|
+
- direct service instantiation instead of dependency injection
|
|
69
|
+
- side effects in SwiftUI view body or reducer body
|
|
70
|
+
- \`Task { }\` without proper cancellation handling
|
|
71
|
+
- missing \`Equatable\`/\`Sendable\` conformances where needed
|
|
72
|
+
- inconsistent async/await vs Combine usage
|
|
73
|
+
- navigation logic leaking into unrelated view/service layers
|
|
74
|
+
- UIKit/SwiftUI bridging patterns that are repeated but undocumented
|
|
75
|
+
- extension/widget/deep-link boundaries handled inconsistently
|
|
76
|
+
|
|
77
|
+
### Code Style Extraction (Swift)
|
|
78
|
+
|
|
79
|
+
From representative Swift files, identify:
|
|
80
|
+
- import order: \`Foundation\` -> \`SwiftUI/UIKit\` -> third-party -> local modules
|
|
81
|
+
- access control patterns: \`private\`, \`internal\`, \`public\` usage
|
|
82
|
+
- type naming: \`PascalCase\` for types, \`camelCase\` for properties/methods
|
|
83
|
+
- file naming: \`FeatureNameView.swift\`, \`FeatureNameReducer.swift\`, \`FeatureNameViewModel.swift\`, etc.
|
|
84
|
+
- extension organization: separate extensions for protocol conformances
|
|
85
|
+
- MARK comments: \`// MARK: -\` usage for code organization
|
|
86
|
+
- documentation: \`///\` doc comments on public APIs
|
|
87
|
+
- property wrappers: \`@State\`, \`@Binding\`, \`@Environment\`, \`@Dependency\`, \`@Observable\` patterns
|
|
88
|
+
- closure syntax: trailing closure conventions
|
|
89
|
+
- guard vs if-let patterns
|
|
90
|
+
|
|
91
|
+
### Analysis Checklist (iOS Project)
|
|
92
|
+
|
|
93
|
+
Document these with file path evidence:
|
|
94
|
+
|
|
95
|
+
- Architecture and feature module organization.
|
|
96
|
+
- UI framework mode and screen composition patterns.
|
|
97
|
+
- State management and async model.
|
|
98
|
+
- Dependency injection and service/client pattern.
|
|
99
|
+
- Navigation strategy and ownership.
|
|
100
|
+
- Platform integration boundaries (widgets, extensions, notifications, deep links) if present.
|
|
101
|
+
- Networking/persistence/KMM integration, if present.
|
|
102
|
+
- Testing approach and helper usage.
|
|
103
|
+
- Code style conventions that are not already enforced by formatters.
|
|
104
|
+
- Main recurring anti-patterns and where they appear.
|
|
105
|
+
|
|
106
|
+
Before final output, gather concrete evidence for each applicable item.
|
|
107
|
+
If evidence remains partial, continue conservatively and mark uncertainty with \`[VERIFY: ...]\` instead of blocking output.
|
|
108
|
+
|
|
109
|
+
### Generation Locks (Prevent Architecture Drift)
|
|
110
|
+
|
|
111
|
+
Apply these constraints when generating rules and skills:
|
|
112
|
+
- Preserve detected architecture (TCA/MVVM/coordinator/simple SwiftUI/UIKit/etc.) and do not migrate implicitly.
|
|
113
|
+
- Preserve detected UI framework mode (SwiftUI/UIKit/mixed).
|
|
114
|
+
- Preserve dependency injection and service ownership model.
|
|
115
|
+
- Preserve navigation ownership model.
|
|
116
|
+
- Preserve concurrency model unless strong project evidence suggests convergence.
|
|
117
|
+
- Preserve the observed complexity level: if the project uses lightweight patterns, do not generate enterprise-style layers.
|
|
118
|
+
- Preserve build/runtime and module-boundary assumptions.
|
|
119
|
+
|
|
120
|
+
## Skill Candidates (iOS)
|
|
121
|
+
|
|
122
|
+
Generate these skills with actual project paths and Swift-specific workflow steps:
|
|
123
|
+
Generate only skills that have clear project evidence and practical value.
|
|
124
|
+
For small/low-confidence projects, 2-4 core skills are usually enough.
|
|
125
|
+
|
|
126
|
+
### adding-feature
|
|
127
|
+
- Include actual feature folder structure used in this project.
|
|
128
|
+
- Reference real View/ViewModel/Reducer/Coordinator files as templates based on the detected local architecture.
|
|
129
|
+
- Show step-by-step for the detected architecture pattern only.
|
|
130
|
+
- Include navigation and parent integration when relevant.
|
|
131
|
+
|
|
132
|
+
### adding-service
|
|
133
|
+
- Include actual service/client file paths and dependency registration style.
|
|
134
|
+
- Show protocol definition, implementation, registration, and async/error handling.
|
|
135
|
+
- Include mocking/test strategy for service behavior.
|
|
136
|
+
|
|
137
|
+
### code-review
|
|
138
|
+
- Include iOS/Swift-specific review checklist based on project patterns.
|
|
139
|
+
- Cover architecture compliance, UI composition, async handling, dependency use, and testing.
|
|
140
|
+
|
|
141
|
+
### common-anti-patterns
|
|
142
|
+
- Include recurring Swift/iOS anti-patterns from this project.
|
|
143
|
+
- Pair each anti-pattern with the preferred local alternative.
|
|
144
|
+
|
|
145
|
+
### troubleshooting
|
|
146
|
+
- Include common build/runtime/test issues for this codebase.
|
|
147
|
+
- Include where to inspect first when these issues happen.
|
|
148
|
+
|
|
149
|
+
### [framework-specific]
|
|
150
|
+
Generate 1-3 additional skills based on actual stack usage:
|
|
151
|
+
- tca-patterns (if TCA is primary)
|
|
152
|
+
- mvvm-patterns (if MVVM or view-model-heavy flow is primary)
|
|
153
|
+
- coordinator-patterns (if coordinator/router ownership is central)
|
|
154
|
+
- kmm-integration (if shared/KMM is present)
|
|
155
|
+
- adding-widget (if reusable widget/component system is central)
|
|
156
|
+
- extension-workflows (if widgets/extensions/deep links are central)
|
|
157
|
+
- [domain]-workflows (if a domain workflow is clearly repeated)
|
|
158
|
+
|
|
159
|
+
### enrichment-tasks (optional)
|
|
160
|
+
- Generate this only when the user explicitly asks for enrichment, or when analysis shows a clear gap in the existing rule/skill bank.
|
|
161
|
+
|
|
162
|
+
## Rule Generation Requirements
|
|
163
|
+
|
|
164
|
+
### What NOT to Include
|
|
165
|
+
|
|
166
|
+
- Do not invent generic philosophy ("clean code", "think about user").
|
|
167
|
+
- Do not duplicate what linters/formatters enforce.
|
|
168
|
+
- Do not add rules without evidence from codebase patterns.
|
|
169
|
+
- Do not repeat rules across multiple files.
|
|
170
|
+
|
|
171
|
+
### Rule Content Requirements
|
|
172
|
+
|
|
173
|
+
Keep this section iOS-specific:
|
|
174
|
+
- Capture decisions tied to Swift architecture and app structure (TCA/MVVM, navigation, DI, async model).
|
|
175
|
+
- Prefer Swift-native patterns and terminology over generic cross-stack wording.
|
|
176
|
+
- Highlight iOS-specific risks and anti-patterns that recur in this codebase.
|
|
177
|
+
- Match the actual architecture level of the project; do not upscale a lightweight codebase into a layered architecture just because the stack allows it.
|
|
178
|
+
|
|
179
|
+
## Algorithm: Analysis -> Rules (iOS)
|
|
180
|
+
|
|
181
|
+
Follow this systematic approach for iOS projects:
|
|
182
|
+
|
|
183
|
+
**Structure -> Architecture Rules:**
|
|
184
|
+
1. Detect patterns in feature folders and module layout.
|
|
185
|
+
2. Generate placement rules for the artifacts that actually exist here: views, view models, reducers, coordinators, services, models, modules.
|
|
186
|
+
3. Document module boundaries and what can import what.
|
|
187
|
+
|
|
188
|
+
**Swift Files -> Code Style Rules:**
|
|
189
|
+
1. For views, reducers/view models, and services, scan 2-3 representative files each.
|
|
190
|
+
2. Identify import grouping, access control, MARK usage, and extension organization.
|
|
191
|
+
3. Promote only repeated high-signal conventions.
|
|
192
|
+
|
|
193
|
+
**Configs -> Architectural Rules:**
|
|
194
|
+
1. Inspect Package.swift, Podfile, swiftlint, xcconfig, and project metadata.
|
|
195
|
+
2. Create rules for module imports, dependency access, runtime boundaries, and platform integrations.
|
|
196
|
+
3. Do not restate what SwiftLint/SwiftFormat already enforce.
|
|
197
|
+
|
|
198
|
+
**Red Flags -> Safety Rules:**
|
|
199
|
+
1. If the same Swift anti-pattern appears repeatedly, define "Avoid X, do Y instead".
|
|
200
|
+
2. Reference the actual correct pattern from this repo.
|
|
201
|
+
|
|
202
|
+
**Tests -> Testing Rules:**
|
|
203
|
+
1. Identify test location pattern and XCTest/TestStore usage.
|
|
204
|
+
2. Extract mocking and assertion conventions.
|
|
205
|
+
3. Require tests only for module types that are consistently tested in this project.
|
|
206
|
+
|
|
207
|
+
## Recommended Rule Topics (iOS Project)
|
|
208
|
+
|
|
209
|
+
Split by topic:
|
|
210
|
+
Generate only topics that are supported by concrete project evidence.
|
|
211
|
+
|
|
212
|
+
| Topic | Covers (iOS-Specific) |
|
|
213
|
+
|------|------------------------|
|
|
214
|
+
| \`architecture\` | TCA/MVVM structure, layers, feature module organization |
|
|
215
|
+
| \`code-style\` | Swift naming, imports, access control, MARK comments |
|
|
216
|
+
| \`dependencies\` | DI pattern, service protocols, actors, dependency registration |
|
|
217
|
+
| \`navigation\` | NavigationStack, Coordinator, or reducer-driven navigation |
|
|
218
|
+
| \`swiftui-patterns\` | View composition, modifiers, environment, previews |
|
|
219
|
+
| \`uikit-patterns\` | UIViewController patterns, lifecycle, layout (if UIKit) |
|
|
220
|
+
| \`tca-patterns\` | Reducer structure, State/Action, effects, testing (if TCA) |
|
|
221
|
+
| \`mvvm-patterns\` | ViewModel ownership, bindings, async flow (if MVVM) |
|
|
222
|
+
| \`services\` | API clients, persistence, mapping, boundary normalization |
|
|
223
|
+
| \`widget-system\` | Reusable UI components and styling tokens |
|
|
224
|
+
| \`kmm-integration\` | Shared/KMM wrappers and entity bridging |
|
|
225
|
+
| \`platform-integration\` | widgets, extensions, notifications, deep links, app lifecycle boundaries |
|
|
226
|
+
| \`testing\` | XCTest patterns, TestStore, mocking, snapshots |
|
|
227
|
+
| \`error-handling\` | Error types, logging, user-facing failures |
|
|
228
|
+
| \`localization\` | String localization and formatting (if applicable) |
|
|
229
|
+
|
|
230
|
+
## Context-to-Rule/Skill Mapping (iOS)
|
|
231
|
+
|
|
232
|
+
Use this mapping to decide what files to generate:
|
|
233
|
+
Generate only skills that are supported by concrete project evidence.
|
|
234
|
+
|
|
235
|
+
| Found in iOS Codebase | Generate Rule Topic | Generate Skill |
|
|
236
|
+
|----------------------|---------------------|----------------|
|
|
237
|
+
| TCA architecture (\`@Reducer\`, \`Store\`) | \`architecture\`, \`tca-patterns\` | \`adding-feature\` |
|
|
238
|
+
| MVVM architecture (\`ObservableObject\`, \`@Observable\`) | \`architecture\`, \`mvvm-patterns\` | \`adding-feature\`, \`mvvm-patterns\` |
|
|
239
|
+
| Swift code conventions | \`code-style\` | \`code-review\` |
|
|
240
|
+
| TCA Dependencies (\`@Dependency\`) | \`dependencies\` | \`adding-service\` |
|
|
241
|
+
| Custom DI (Resolver, Factory) | \`dependencies\` | \`adding-service\` |
|
|
242
|
+
| NavigationStack / Coordinator | \`navigation\` | - |
|
|
243
|
+
| SwiftUI views | \`swiftui-patterns\` | - |
|
|
244
|
+
| UIKit views | \`uikit-patterns\` | - |
|
|
245
|
+
| API/Network layer | \`services\` | - |
|
|
246
|
+
| Reusable UI components | \`widget-system\` | \`adding-widget\` |
|
|
247
|
+
| KMM shared module | \`kmm-integration\` | \`kmm-integration\` |
|
|
248
|
+
| Widgets/extensions/deep links | \`platform-integration\` | \`extension-workflows\` |
|
|
249
|
+
| XCTest / TCA TestStore | \`testing\` | - |
|
|
250
|
+
| Error types, logging | \`error-handling\` | - |
|
|
251
|
+
| Localized strings | \`localization\` | - |
|
|
252
|
+
| SwiftLint violations | - | \`common-anti-patterns\` |
|
|
253
|
+
| Build/runtime issues | - | \`troubleshooting\` |
|
|
254
|
+
`;
|