Skip to content

Commit 9dab396

Browse files
committed
Respond to review and add SIL library skill
1 parent f5fed92 commit 9dab396

3 files changed

Lines changed: 515 additions & 56 deletions

File tree

Lines changed: 349 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,349 @@
1+
---
2+
name: sil-library-reuse
3+
description: >
4+
Reuse lower-level SIL libraries before writing custom helpers in FieldWorks.
5+
Use this whenever a task touches file or directory I/O, locked-file retries,
6+
paths or URIs, writing systems, keyboards, LCM caches/project IDs/service
7+
locators, linked files/media/config paths, localization, LIFT/import/export,
8+
FLExBridge or Chorus sync/merge flows, analytics/telemetry, morphology or
9+
NLP, scripture/Paratext integration, or SIL test helpers. Even for small
10+
fixes, check the package families and repo patterns here first. If any
11+
guidance here proves inaccurate or stale, revalidate against current
12+
FieldWorks package references, local package metadata, and upstream repos,
13+
then update this skill so it stays current.
14+
---
15+
16+
# SIL Library Reuse
17+
18+
FieldWorks already depends on SIL packages that solve many of the "small
19+
helper" problems agents are tempted to rebuild. Start here before adding new
20+
filesystem wrappers, cache bootstraps, writing-system plumbing, localization
21+
hooks, bridge calls, or parser code.
22+
23+
## Staying Current
24+
25+
If you find this to be inaccurate, treat that as a maintenance signal, not a
26+
reason to ignore the skill. SIL package versions, upstream repo layouts, and
27+
public API names change over time. Revalidate the claim against the current
28+
FieldWorks package references, installed package metadata, local usage, and
29+
upstream repos, then update this skill in the same change when practical. If
30+
you cannot update it, call out the stale item clearly in your final response.
31+
32+
## Workflow
33+
34+
1. Identify the package family from the touched namespace or project file. If
35+
the package or version is unclear, check
36+
[Directory.Packages.props](../../../Directory.Packages.props) and
37+
[Build/SilVersions.props](../../../Build/SilVersions.props).
38+
2. Search FieldWorks first for the concrete helper or namespace and copy the
39+
existing local pattern.
40+
3. If local usage is thin or the name is unfamiliar, open the upstream repo
41+
links below. Do not assume Context7 covers these packages well.
42+
4. Prefer the library helper over custom code when it already handles retries,
43+
path normalization, cache setup, localization metadata, sync boundaries, or
44+
corpus parsing.
45+
5. Keep FieldWorks constraints intact: .NET Framework 4.8, C# 7.3, `.resx` for
46+
user-facing strings, registration-free COM, and repo build/test scripts.
47+
48+
## Good First Searches
49+
50+
- `RobustIO|RobustFile|RetryUtility|Keyboard.Controller|FileLocationUtilities`
51+
- `LcmCache|TestProjectId|SimpleProjectId|ServiceLocator.GetInstance|LcmFileHelper|WritingSystemManager|FileUtils`
52+
- `LocalizationManagerWinforms|L10NExtender`
53+
- `Analytics.Track|Analytics.ReportException|FLExBridgeHelper`
54+
- `Paratext|IParatextHelper|Usfm|Usx|Morpher|SIL.Machine`
55+
56+
## Package Family Map
57+
58+
### `libpalaso`
59+
60+
Packages:
61+
`SIL.Core`, `SIL.Core.Desktop`, `SIL.Archiving`, `SIL.Lexicon`, `SIL.Lift`,
62+
`SIL.Media`, `SIL.Scripture`, `SIL.TestUtilities`, `SIL.Windows.Forms*`,
63+
`SIL.WritingSystems`
64+
65+
Use for:
66+
filesystem resilience, path helpers, retry loops, desktop file helpers,
67+
writing systems, keyboards, LIFT processing, archiving, and test temp-file
68+
helpers.
69+
70+
FieldWorks usage anchors:
71+
72+
- [Src/Common/RootSite/RootSiteTests/RealDataTestsBase.cs](../../../Src/Common/RootSite/RootSiteTests/RealDataTestsBase.cs)
73+
- [Src/xWorks/FwXWindow.cs](../../../Src/xWorks/FwXWindow.cs)
74+
- [Src/Common/SimpleRootSite/EditingHelper.cs](../../../Src/Common/SimpleRootSite/EditingHelper.cs)
75+
76+
Main APIs to look for first:
77+
78+
- `RobustIO.DeleteDirectoryAndContents`
79+
- `RobustIO.MoveDirectory`
80+
- `RobustIO.RequireThatDirectoryExists`
81+
- `RobustFile.Copy`
82+
- `RobustFile.WriteAllBytes`
83+
- `RobustFile.ReplaceByCopyDelete`
84+
- `RetryUtility.Retry`
85+
- `PathHelper.NormalizePath`
86+
- `PathHelper.AreOnSameVolume`
87+
- `PathHelper.StripFilePrefix`
88+
- `FileLocationUtilities.LocateExecutable`
89+
- `FileLocationUtilities.LocateInProgramFiles`
90+
- `PathUtilities.SelectFileInExplorer`
91+
- `PathUtilities.OpenDirectoryInExplorer`
92+
- `WritingSystemDefinition`
93+
- `IWritingSystemRepository`
94+
- `Keyboard.Controller`
95+
- `KeyboardController`
96+
- `LiftSorter.SortLiftFile`
97+
- `LiftPreparer.MigrateLiftFile`
98+
- `WritingSystemsInLiftFileHelper`
99+
- `ArchivingFileSystem`
100+
101+
Upstream repo:
102+
103+
- [libpalaso](https://github.com/sillsdev/libpalaso)
104+
- [SIL.Core/IO](https://github.com/sillsdev/libpalaso/tree/master/SIL.Core/IO)
105+
- [SIL.Core.Desktop/IO](https://github.com/sillsdev/libpalaso/tree/master/SIL.Core.Desktop/IO)
106+
- [SIL.WritingSystems](https://github.com/sillsdev/libpalaso/tree/master/SIL.WritingSystems)
107+
- [SIL.Windows.Forms.Keyboarding](https://github.com/sillsdev/libpalaso/tree/master/SIL.Windows.Forms.Keyboarding)
108+
- [SIL.Windows.Forms.WritingSystems](https://github.com/sillsdev/libpalaso/tree/master/SIL.Windows.Forms.WritingSystems)
109+
- [SIL.Lift](https://github.com/sillsdev/libpalaso/tree/master/SIL.Lift)
110+
- [SIL.Archiving](https://github.com/sillsdev/libpalaso/tree/master/SIL.Archiving)
111+
- [SIL.TestUtilities](https://github.com/sillsdev/libpalaso/tree/master/SIL.TestUtilities)
112+
113+
### `liblcm`
114+
115+
Packages:
116+
`SIL.LCModel`, `SIL.LCModel.Core`, `SIL.LCModel.Utils`,
117+
`SIL.LCModel.FixData`, `SIL.LCModel.Tests`
118+
119+
Use for:
120+
LCM cache creation, project IDs, service location, writing-system managers,
121+
linked/media/config paths, imports, migrations, and repository/factory access.
122+
123+
FieldWorks usage anchors:
124+
125+
- [Src/Common/RootSite/RootSiteTests/RealDataTestsBase.cs](../../../Src/Common/RootSite/RootSiteTests/RealDataTestsBase.cs)
126+
- [Src/xWorks/FwXWindow.cs](../../../Src/xWorks/FwXWindow.cs)
127+
- [Src/xWorks/xWorksTests/ExportDialogTests.cs](../../../Src/xWorks/xWorksTests/ExportDialogTests.cs)
128+
129+
Main APIs to look for first:
130+
131+
- `LcmCache.CreateCacheFromExistingData`
132+
- `LcmCache.CreateCacheWithNewBlankLangProj`
133+
- `ILcmServiceLocator`
134+
- `ServiceLocator.GetInstance<T>()`
135+
- `IProjectIdentifier`
136+
- `SimpleProjectId`
137+
- `TestProjectId`
138+
- `LcmFileHelper.GetConfigSettingsDir`
139+
- `LcmFileHelper.GetDefaultLinkedFilesDir`
140+
- `LcmFileHelper.GetDefaultMediaDir`
141+
- `LcmFileHelper.GetWritingSystemDir`
142+
- `LinkedFilesRelativePathHelper`
143+
- `FileUtils.FileExists`
144+
- `FileUtils.DirectoryExists`
145+
- `FileUtils.EnsureDirectoryExists`
146+
- `FileUtils.StripFilePrefix`
147+
- `FileUtils.ChangePathToPlatform`
148+
- `WritingSystemManager`
149+
- `UnitOfWorkService`
150+
151+
Upstream repo:
152+
153+
- [liblcm](https://github.com/sillsdev/liblcm)
154+
- [src/SIL.LCModel](https://github.com/sillsdev/liblcm/tree/master/src/SIL.LCModel)
155+
- [Infrastructure](https://github.com/sillsdev/liblcm/tree/master/src/SIL.LCModel/Infrastructure)
156+
- [DomainServices](https://github.com/sillsdev/liblcm/tree/master/src/SIL.LCModel/DomainServices)
157+
- [src/SIL.LCModel.Core](https://github.com/sillsdev/liblcm/tree/master/src/SIL.LCModel.Core)
158+
- [src/SIL.LCModel.Utils](https://github.com/sillsdev/liblcm/tree/master/src/SIL.LCModel.Utils)
159+
160+
### `l10nsharp`
161+
162+
Packages:
163+
`L10NSharp`, `L10NSharp.Windows.Forms`
164+
165+
Use for:
166+
runtime WinForms localization, XLIFF-backed string management, control
167+
metadata, and language switching.
168+
169+
FieldWorks usage anchors:
170+
171+
- [Src/Common/FieldWorks/FieldWorks.cs](../../../Src/Common/FieldWorks/FieldWorks.cs)
172+
173+
Main APIs to look for first:
174+
175+
- `LocalizationManagerWinforms.Create`
176+
- `LocalizationManagerWinforms.SetUILanguage`
177+
- `LocalizationManagerWinforms.ReapplyLocalizationsToAllObjects`
178+
- `L10NExtender`
179+
- `ILocalizableComponent`
180+
- `LocalizingInfoWinforms`
181+
- `LocalizationCategory`
182+
- `XliffLocalizationManagerWinforms`
183+
184+
Upstream repo:
185+
186+
- [l10nsharp](https://github.com/sillsdev/l10nsharp)
187+
- [src/L10NSharp](https://github.com/sillsdev/l10nsharp/tree/master/src/L10NSharp)
188+
- [src/L10NSharp.Windows.Forms](https://github.com/sillsdev/l10nsharp/tree/master/src/L10NSharp.Windows.Forms)
189+
- [UIComponents](https://github.com/sillsdev/l10nsharp/tree/master/src/L10NSharp.Windows.Forms/UIComponents)
190+
- [SampleApp](https://github.com/sillsdev/l10nsharp/tree/master/src/SampleApp)
191+
192+
### `desktopanalytics.net`
193+
194+
Packages:
195+
`SIL.DesktopAnalytics`
196+
197+
Use for:
198+
telemetry, consent-aware tracking, exception reporting, and application-level
199+
analytics properties.
200+
201+
FieldWorks usage anchors:
202+
203+
- [Src/Common/FieldWorks/FieldWorks.cs](../../../Src/Common/FieldWorks/FieldWorks.cs)
204+
- [Src/Common/FwUtils/TrackingHelper.cs](../../../Src/Common/FwUtils/TrackingHelper.cs)
205+
- [Src/LexText/LexTextDll/AreaListener.cs](../../../Src/LexText/LexTextDll/AreaListener.cs)
206+
207+
Main APIs to look for first:
208+
209+
- `Analytics.Track`
210+
- `Analytics.ReportException`
211+
- `Analytics.AllowTracking`
212+
- `Analytics.IdentifyUpdate`
213+
- `Analytics.SetApplicationProperty`
214+
- `Analytics.FlushClient`
215+
- `UserInfo.CreateSanitized`
216+
217+
Upstream repo:
218+
219+
- [DesktopAnalytics.net](https://github.com/sillsdev/DesktopAnalytics.net)
220+
- [Analytics.cs](https://github.com/sillsdev/DesktopAnalytics.net/blob/master/src/DesktopAnalytics/Analytics.cs)
221+
- [UserInfo.cs](https://github.com/sillsdev/DesktopAnalytics.net/blob/master/src/DesktopAnalytics/UserInfo.cs)
222+
223+
### `ipcframework` and `chorus`
224+
225+
Packages:
226+
`SIL.FLExBridge.IPCFramework`, `SIL.Chorus.App`, `SIL.Chorus.LibChorus`,
227+
`SIL.Chorus.L10ns`
228+
229+
Use for:
230+
FLExBridge launch/obtain/send-receive flows, IPC contracts, sync/merge
231+
orchestration, file-type handlers, and merge/conflict notes.
232+
233+
FieldWorks usage anchors:
234+
235+
- [Src/Common/FwUtils/FLExBridgeHelper.cs](../../../Src/Common/FwUtils/FLExBridgeHelper.cs)
236+
- [Src/LexText/Lexicon/FLExBridgeListener.cs](../../../Src/LexText/Lexicon/FLExBridgeListener.cs)
237+
- [Src/Common/Controls/FwControls/ObtainProjectMethod.cs](../../../Src/Common/Controls/FwControls/ObtainProjectMethod.cs)
238+
239+
Start with the local wrapper first:
240+
241+
- `FLExBridgeHelper.LaunchFieldworksBridge`
242+
- `FLExBridgeHelper.DoesProjectHaveFlexRepo`
243+
- `FLExBridgeHelper.DoesProjectHaveLiftRepo`
244+
- `FLExBridgeHelper.IsFlexBridgeInstalled`
245+
- `FLExBridgeHelper.FullFieldWorksBridgePath`
246+
247+
Then inspect upstream helpers if the change crosses the boundary:
248+
249+
- `IPCClientFactory.Create`
250+
- `IPCHostFactory.Create`
251+
- `IIPCClient.RemoteCall`
252+
- `IIPCHost.Initialize`
253+
- `Synchronizer`
254+
- `XmlMergeService.Do3WayMerge`
255+
- `MergeOrder`
256+
- `ElementStrategy`
257+
- `IChorusFileTypeHandler`
258+
- `ChorusNotesMergeEventListener`
259+
260+
Upstream repos:
261+
262+
- [ipcframework](https://github.com/sillsdev/ipcframework)
263+
- [IPCFramework/IPCInterfaces.cs](https://github.com/sillsdev/ipcframework/tree/master/IPCFramework/IPCInterfaces.cs)
264+
- [IPCClientFactory.cs](https://github.com/sillsdev/ipcframework/tree/master/IPCFramework/IPCClientFactory.cs)
265+
- [IPCHostFactory.cs](https://github.com/sillsdev/ipcframework/tree/master/IPCFramework/IPCHostFactory.cs)
266+
- [ServerProgram/FLExBridgeHelper.cs](https://github.com/sillsdev/ipcframework/tree/master/ServerProgram/FLExBridgeHelper.cs)
267+
- [ClientProgram/FLExConnectionHelper.cs](https://github.com/sillsdev/ipcframework/tree/master/ClientProgram/FLExConnectionHelper.cs)
268+
- [chorus](https://github.com/sillsdev/chorus)
269+
- [src/LibChorus/sync](https://github.com/sillsdev/chorus/tree/master/src/LibChorus/sync)
270+
- [src/LibChorus/merge/xml/generic](https://github.com/sillsdev/chorus/tree/master/src/LibChorus/merge/xml/generic)
271+
- [src/LibChorus/FileTypeHandlers](https://github.com/sillsdev/chorus/tree/master/src/LibChorus/FileTypeHandlers)
272+
- [src/LibChorus/VcsDrivers/Mercurial](https://github.com/sillsdev/chorus/tree/master/src/LibChorus/VcsDrivers/Mercurial)
273+
- [src/LibChorus/notes](https://github.com/sillsdev/chorus/tree/master/src/LibChorus/notes)
274+
275+
### `machine`
276+
277+
Packages:
278+
`SIL.Machine`, `SIL.Machine.Morphology.HermitCrab`
279+
280+
Use for:
281+
morphology, feature-structure-based NLP, text corpora, USFM/USX parsing, and
282+
alignment. Direct FieldWorks usage is light today; consult this before
283+
inventing parser or analysis code.
284+
285+
Main APIs to look for first:
286+
287+
- `Morpher.ParseWord`
288+
- `Morpher.GenerateWords`
289+
- `XmlLanguageLoader`
290+
- `TraceManager`
291+
- `FeatureStruct`
292+
- `ParatextTextCorpus`
293+
- `UsxFileTextCorpus`
294+
- `UsfmParser`
295+
- `CorporaUtils`
296+
297+
Upstream repo:
298+
299+
- [machine](https://github.com/sillsdev/machine)
300+
- [src/SIL.Machine](https://github.com/sillsdev/machine/tree/master/src/SIL.Machine)
301+
- [src/SIL.Machine.Morphology.HermitCrab](https://github.com/sillsdev/machine/tree/master/src/SIL.Machine.Morphology.HermitCrab)
302+
- [src/SIL.Machine.Translation.Thot](https://github.com/sillsdev/machine/tree/master/src/SIL.Machine.Translation.Thot)
303+
304+
### `Paratext`
305+
306+
Packages:
307+
`SIL.ParatextShared`, `ParatextData`
308+
309+
Use for:
310+
Scripture project access, verse references, plugin integration, USFM tokens,
311+
and Paratext interoperability.
312+
313+
FieldWorks usage anchors:
314+
315+
- [Src/Common/ScriptureUtils/ScriptureUtilsTests/ParatextHelperTests.cs](../../../Src/Common/ScriptureUtils/ScriptureUtilsTests/ParatextHelperTests.cs)
316+
- `Paratext8Plugin` projects and helpers
317+
318+
Important caveat:
319+
`SIL.ParatextShared` source for the legacy package used by FieldWorks is not
320+
publicly available. Use the public docs and demo plugins instead of hunting
321+
for a missing source tree.
322+
323+
Public docs and references:
324+
325+
- [Paratext demo plugins](https://github.com/ubsicap/paratext_demo_plugins)
326+
- [Full API documentation wiki](https://github.com/ubsicap/paratext_demo_plugins/wiki/Full-API-Documentation)
327+
- [SIL.ParatextShared 7.4.0.1](https://www.nuget.org/packages/SIL.ParatextShared/7.4.0.1)
328+
329+
Useful API names in the public docs:
330+
331+
- `IProject`
332+
- `IReadOnlyProject`
333+
- `IVerseRef`
334+
- `IUSFMToken`
335+
- `IUSFMMarkerToken`
336+
- `IScriptureTextSelection`
337+
- `IBiblicalTerm`
338+
- `IProjectNote`
339+
340+
## Biases To Keep
341+
342+
- Prefer `RobustIO` or `RobustFile` over ad hoc delete/retry loops.
343+
- Prefer `LcmCache`, `TestProjectId`, `ServiceLocator.GetInstance<T>()`, and
344+
`LcmFileHelper` over custom LCM bootstrapping or path math.
345+
- Prefer `LocalizationManagerWinforms` over ad hoc runtime localization state.
346+
- Prefer `FLExBridgeHelper` over direct IPC calls from new UI code.
347+
- Prefer existing analytics calls or wrappers over one-off telemetry clients.
348+
- When a repo search comes up empty, switch from keyword search to
349+
symbol/reference navigation before deciding the helper does not exist.

0 commit comments

Comments
 (0)