Skip to content

Latest commit

Β 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🌍 SDGScript

npm version License: MIT TypeScript SDGs

A TypeScript superset for SDGs-aware programming - Write sustainable code that contributes to the United Nations Sustainable Development Goals.

SDGScript Screenshot

✨ Features

  • πŸ”„ Full TypeScript Compatibility: Use existing TypeScript code seamlessly
  • πŸ“ SDGs Annotations: JSDoc-style syntax for expressing SDGs compliance
  • πŸ” Static Analysis: AST-based carbon footprint and resource usage prediction
  • ⚑ Runtime Monitoring: Optional real-time resource tracking
  • πŸ› οΈ Developer Tools: VSCode extension, ESLint plugin, and report generation
  • πŸ“Š Impact Measurement: Quantify your code's environmental and social impact

πŸš€ Quick Start

Installation

npm install -g sdgscript

1. Initialize a Project

mkdir my-sdg-project
cd my-sdg-project
sdgscript init
npm install

2. Add SDGs Annotations

/**
 * @sdg Goal13 ClimateAction
 * @carbonBudget 1.5kWh
 * @impact environment high
 * @description Efficiently process climate data
 */
async function processClimateData(data: ClimateRecord[]): Promise<ProcessedData> {
  return withSDGContext({
    goal: 'Goal13_ClimateAction',
    carbonBudget: 1.5
  }, async () => {
    // Your efficient implementation here
    trackResource('computation', { energy: 0.8, emissions: 400 });
    return processedData;
  });
}

3. Analyze Your Code

# Generate comprehensive SDGs compliance report
sdgscript analyze src/ --format html -o sdg-report.html

# Check specific metrics
sdgscript analyze src/ --format json | jq '.summary'

4. Integrate with Your Workflow

// .eslintrc.json
{
  "extends": ["@typescript-eslint/recommended"],
  "plugins": ["@sdgscript/eslint-plugin"],
  "rules": {
    "@sdgscript/require-sdg-annotation": "warn",
    "@sdgscript/avoid-inefficient-loops": "error",
    "@sdgscript/limit-network-calls": "warn"
  }
}

πŸ“¦ Architecture

sdgscript/
β”œβ”€β”€ 🧠 packages/core/           # AST transformation & analysis engine
β”œβ”€β”€ πŸ’» packages/cli/            # Command-line tools
β”œβ”€β”€ πŸ”§ packages/eslint-plugin/  # ESLint integration
β”œβ”€β”€ ⚑ packages/runtime/        # Runtime monitoring APIs
└── 🎨 packages/vscode-extension/ # VSCode language support

🎯 SDGs Integration

Supported Goals

Goal Focus Area Programming Context
Goal 7 Clean Energy Energy-efficient algorithms, optimization
Goal 13 Climate Action Carbon footprint reduction, green computing
Goal 4 Quality Education Accessible technology, digital inclusion
Goal 5 Gender Equality Bias detection, inclusive design
Goal 12 Responsible Consumption Resource efficiency, caching strategies

Example: Climate Data Processing

/**
 * @sdg Goal13 ClimateAction
 * @carbonBudget 2.0kWh
 * @impact environment critical
 */
export async function analyzeGlobalTemperatureData(
  sensors: SensorData[]
): Promise<ClimateInsights> {
  return withSDGContext({
    goal: 'Goal13_ClimateAction',
    carbonBudget: 2.0,
    description: 'Global temperature trend analysis for climate action'
  }, async () => {
    // Efficient batch processing to minimize energy consumption
    const insights = await processInBatches(sensors, 100);
    
    trackResource('climate_analysis', {
      energy: 1.8,
      emissions: 900, // gCOβ‚‚
      dataPoints: sensors.length
    });
    
    return insights;
  });
}

πŸ“Š Impact Measurement

SDGScript automatically tracks and reports:

  • πŸ”‹ Energy Consumption: kWh estimates for code execution
  • 🌱 Carbon Emissions: COβ‚‚ equivalent calculations
  • ⚑ Performance Metrics: Algorithm efficiency analysis
  • πŸ“ˆ SDGs Score: 0-100 compliance rating
  • πŸ’‘ Optimization Suggestions: Actionable improvement recommendations

🀝 Contributing

We welcome contributions! Please see CONTRIBUTING.md for guidelines.

Development Setup

git clone https://github.com/yuis-ice/sdgscript.git
cd sdgscript
npm install
npm run build
npm test

πŸ“„ License

MIT License - see LICENSE file for details.

🌟 Acknowledgments


Built with πŸ’š for a sustainable future

About

🌍 TypeScript superset for SDGs-aware programming. Write sustainable code aligned with UN Sustainable Development Goals through static analysis, runtime monitoring, and developer tools.

Topics

Resources

Contributing

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages