module-systems
Expert skill for designing module systems including resolution algorithms, import/export mechanisms, visibility control, namespace management, and cyclic dependency handling.
What this skill does
# Module Systems Skill
Design and implement module systems for programming languages with support for resolution, loading, visibility, and dependency management.
## Capabilities
- Design module/import/export syntax
- Implement module resolution algorithms
- Handle cyclic module dependencies
- Implement visibility/access control
- Design namespace management systems
- Support module aliases and re-exports
- Implement lazy/on-demand module loading
- Design package/crate system integration
## Usage
Invoke this skill when you need to:
- Design a module system for a new language
- Implement module resolution algorithms
- Handle complex dependency graphs
- Build visibility and access control systems
- Integrate with package managers
## Inputs
| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| moduleStyle | string | Yes | Style (es6, commonjs, rust, ml) |
| resolutionStrategy | string | Yes | Resolution (node, rust, python, custom) |
| features | array | No | Features to implement |
| cyclicHandling | string | No | How to handle cycles (error, lazy, tarjan) |
| visibility | object | No | Visibility model configuration |
### Feature Options
```json
{
"features": [
"import-export",
"re-exports",
"namespace-aliasing",
"selective-imports",
"default-exports",
"lazy-loading",
"cyclic-detection",
"visibility-control",
"inline-modules",
"package-integration"
]
}
```
## Output Structure
```
module-system/
├── syntax/
│ ├── import.grammar # Import statement syntax
│ ├── export.grammar # Export statement syntax
│ └── module-decl.grammar # Module declaration syntax
├── resolution/
│ ├── resolver.ts # Main resolution algorithm
│ ├── module-graph.ts # Dependency graph
│ ├── path-resolver.ts # Path resolution
│ └── cache.ts # Module cache
├── loading/
│ ├── loader.ts # Module loader
│ ├── lazy-loader.ts # Lazy loading support
│ └── parallel-loader.ts # Parallel loading
├── visibility/
│ ├── access-control.ts # Visibility checking
│ └── namespace.ts # Namespace management
├── analysis/
│ ├── cycle-detector.ts # Cyclic dependency detection
│ └── dependency-analyzer.ts # Dependency analysis
└── tests/
├── resolution.test.ts
├── cycles.test.ts
└── visibility.test.ts
```
## Module System Types
### ES6-Style Modules
```typescript
// Import syntax
import defaultExport from 'module';
import { named, another as alias } from 'module';
import * as namespace from 'module';
// Export syntax
export const value = 42;
export function func() {}
export default class MyClass {}
export { name, other as renamed };
export * from 'other-module';
// Implementation
interface ESModule {
defaultExport?: any;
namedExports: Map<string, any>;
reExports: ReExport[];
}
interface ImportSpecifier {
type: 'default' | 'named' | 'namespace';
imported: string;
local: string;
}
```
### Rust-Style Modules
```rust
// Module declaration
mod my_module; // Load from file
mod inline { ... } // Inline module
// Use statements
use crate::module::Item;
use super::parent::*;
use self::child::Thing;
use external_crate::Something;
// Visibility
pub struct Public;
pub(crate) struct CrateVisible;
pub(super) struct ParentVisible;
struct Private; // default
// Implementation
interface RustModule {
name: string;
path: ModulePath;
visibility: Visibility;
items: Map<string, ModuleItem>;
submodules: Map<string, RustModule>;
}
type Visibility =
| { type: 'private' }
| { type: 'public' }
| { type: 'restricted'; path: ModulePath };
```
### ML-Style Modules
```ocaml
(* Module signature *)
module type STACK = sig
type 'a t
val empty : 'a t
val push : 'a -> 'a t -> 'a t
val pop : 'a t -> ('a * 'a t) option
end
(* Module implementation *)
module ListStack : STACK = struct
type 'a t = 'a list
let empty = []
let push x s = x :: s
let pop = function
| [] -> None
| x :: xs -> Some (x, xs)
end
(* Functor *)
module MakeSet (Ord: ORD) : SET = struct
(* ... implementation using Ord.compare *)
end
```
## Resolution Algorithms
### Node.js-Style Resolution
```typescript
interface NodeResolver {
resolveModule(specifier: string, from: string): string | null;
}
function nodeResolve(specifier: string, fromDir: string): string | null {
// 1. If specifier is a core module, return it
if (isCoreModule(specifier)) return specifier;
// 2. If starts with '/' or './', resolve relative
if (specifier.startsWith('/') || specifier.startsWith('./') ||
specifier.startsWith('../')) {
return resolveRelative(specifier, fromDir);
}
// 3. Otherwise, walk up node_modules
let dir = fromDir;
while (dir !== '/') {
const candidate = path.join(dir, 'node_modules', specifier);
const resolved = resolvePackage(candidate);
if (resolved) return resolved;
dir = path.dirname(dir);
}
return null;
}
function resolvePackage(pkgPath: string): string | null {
// Check package.json exports/main
const pkgJson = readPackageJson(pkgPath);
if (pkgJson?.exports) {
return resolveExports(pkgPath, pkgJson.exports);
}
if (pkgJson?.main) {
return path.join(pkgPath, pkgJson.main);
}
// Default to index.js
return path.join(pkgPath, 'index.js');
}
```
### Rust-Style Resolution
```typescript
interface RustResolver {
resolveUse(usePath: UsePath, currentModule: ModulePath): ResolvedItem;
}
function rustResolve(usePath: UsePath, current: ModulePath): ResolvedItem {
const [first, ...rest] = usePath.segments;
// Determine starting point
let startModule: RustModule;
if (first === 'crate') {
startModule = getCrateRoot();
} else if (first === 'super') {
startModule = getParentModule(current);
} else if (first === 'self') {
startModule = getCurrentModule(current);
} else if (isExternCrate(first)) {
startModule = getExternCrate(first);
} else {
// Start from current module scope
startModule = getCurrentModule(current);
rest.unshift(first);
}
// Resolve path segments
let currentItem: ModuleItem = startModule;
for (const segment of rest) {
currentItem = resolveSegment(currentItem, segment);
checkVisibility(currentItem, current);
}
return currentItem;
}
```
## Cyclic Dependency Handling
```typescript
// Tarjan's algorithm for SCC detection
function findCycles(graph: ModuleGraph): ModuleCycle[] {
const index = new Map<Module, number>();
const lowlink = new Map<Module, number>();
const onStack = new Set<Module>();
const stack: Module[] = [];
const sccs: Module[][] = [];
let currentIndex = 0;
function strongconnect(module: Module): void {
index.set(module, currentIndex);
lowlink.set(module, currentIndex);
currentIndex++;
stack.push(module);
onStack.add(module);
for (const dep of module.dependencies) {
if (!index.has(dep)) {
strongconnect(dep);
lowlink.set(module, Math.min(lowlink.get(module)!, lowlink.get(dep)!));
} else if (onStack.has(dep)) {
lowlink.set(module, Math.min(lowlink.get(module)!, index.get(dep)!));
}
}
if (lowlink.get(module) === index.get(module)) {
const scc: Module[] = [];
let w: Module;
do {
w = stack.pop()!;
onStack.delete(w);
scc.push(w);
} while (w !== module);
if (scc.length > 1) {
sccs.push(scc);
}
}
}
for (const module of graph.modules) {
if (!index.has(module)) {
strongconnect(module);
}
}
return sccs.map(modules => ({ modules, edges: findCycleEdges(modules) }));
}
```
## Visibility Control
```typescript
interface VisibilityChecker {
canAccess(item: ModuleItem, fromModule: ModulePath): boolean;
}
function checkVisibility(
item: ModuleItem,
fromModule: ModulRelated in General
modeling-omnistudio-epc-catalog
IncludedSalesforce Industries CME EPC product-modeling skill for Product2-based catalog creation. Use when creating EPC products, configuring product attributes, building offer bundles with Product Child Items, or reviewing EPC DataPack JSON metadata for product catalog changes. TRIGGER when: user creates or updates Product2 EPC records, AttributeAssignment payloads, AttributeMetadata/AttributeDefaultValues, Offer bundles, or ProductChildItem relationships. DO NOT TRIGGER when: designing OmniScripts/FlexCards/Integration Procedures (use building-omnistudio-omniscript, building-omnistudio-flexcard, or building-omnistudio-integration-procedure), implementing Apex business logic (use generating-apex), or troubleshooting deployment pipelines (use deploying-metadata).
relationship-science-coach
IncludedUse this skill for direct, practical adult relationship coaching: couples conflict, repair, trust, marriage, dating, flirting, attachment patterns, emotional connection, sex, desire differences, eroticism, kink negotiation, affection, love languages, breakups, and long-term passion. Draw on Gottman, EFT and Hold Me Tight, attachment science, modern sex research, Perel, Nagoski, Kerner, Schnarch, Love and Stosny, and flexible love-language tools. Be concrete and low-hedge. Redirect only for imminent danger, abuse, coercive control, minors, non-consent, self-harm, stalking, or medical/legal/psychiatric decisions.
building-sf-integrations
IncludedSalesforce integration architecture and runtime plumbing with 120-point scoring. Use this skill to set up Named Credentials, External Credentials, External Services, REST/SOAP callout patterns, Platform Events, and Change Data Capture. TRIGGER when: user sets up Named Credentials, External Services, REST/SOAP callouts, Platform Events, CDC, or touches .namedCredential-meta.xml files. DO NOT TRIGGER when: Connected App/OAuth config (use configuring-connected-apps), Apex-only logic (use generating-apex), or data import/export (use handling-sf-data).
venue-templates
IncludedAccess comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.
let-fate-decide
IncludedDraws the 12 Houses of the Zodiac Tarot spread to inject entropy into planning when prompts are vague, ambiguous, or casually delegated. Interprets the spread to guide next steps. Use when the user says 'let fate decide', 'YOLO', 'whatever', 'idk', or other nonchalant phrases, makes Yu-Gi-Oh references, or when you are about to arbitrarily pick between multiple reasonable approaches. Prefer over ask-questions-if-underspecified when the user's tone is casual or playful rather than precision-seeking.
net-ops
IncludedCross-platform network troubleshooting (Windows, macOS, Linux) via local or remote shell. Use for: DNS broken, can't resolve hostnames, nslookup/dig works but apps fail, NRPT, WFP, scutil, /etc/resolver, systemd-resolved, /etc/resolv.conf, NetworkManager, VPN DNS leak residue (ProtonVPN/Mullvad/WireGuard/AnyConnect), AV/firewall blocking DNS or DoH, Tailscale DNS interaction, intermittent connectivity, remote diagnostics over SSH.