anstruct

package module
v0.0.0-...-8916515 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 17, 2025 License: MIT Imports: 14 Imported by: 0

README

Anstruct - AI-Powered Project Structure Manager

Go Version License PRs Welcome

Anstruct is a powerful CLI tool that revolutionizes project structure management using AI. Generate, reverse-engineer, normalize, and sync project structures with simple commands.

# Generate a project from natural language
anstruct aistruct "golang REST API with PostgreSQL" --apply -o ./my-api

# Reverse engineer existing project
anstruct rstruct ./my-project -o project.struct

# Watch and sync in real-time
anstruct watch ./my-app ./my-app.struct --full

Features

  • AI-Powered Generation - Create project structures from natural language
  • Blueprint System - Define structures in simple .struct format
  • Reverse Engineering - Convert existing projects to blueprints
  • Format Normalization - Convert any structure format (tree, ls, markdown) to .struct
  • Real-time Sync - Watch and sync project ↔ blueprint bidirectionally
  • History Management - Undo/redo operations with full tracking
  • Fast & Efficient - Written in Go for maximum performance

Installation

Prerequisites
  • Go 1.21 or higher
  • Git
go install github.com/alberdjuniawan/anstruct/cmd/anstruct@latest

This will automatically:

  • Download and install the latest version
  • Place the binary in your Go bin directory
  • Work on Windows, Linux, and macOS

Verify installation:

anstruct --version

Note: If anstruct command is not recognized, ensure your Go bin directory is in PATH and restart your terminal.

Adding Go bin to PATH

Linux/macOS (bash)

echo 'export PATH=$PATH:$HOME/go/bin' >> ~/.bashrc
source ~/.bashrc

Linux/macOS (zsh)

echo 'export PATH=$PATH:$HOME/go/bin' >> ~/.zshrc
source ~/.zshrc

Windows (PowerShell - Run as Administrator)

[Environment]::SetEnvironmentVariable("Path", $env:Path + ";$env:USERPROFILE\go\bin", "User")

Then restart your terminal.

Option 2: From Source
  1. Clone the repository

    git clone https://github.com/alberdjuniawan/anstruct.git
    cd anstruct
    
  2. Build the binary

    Linux/macOS:

    go build -o anstruct ./cmd/anstruct
    

    Windows (PowerShell):

    go build -o anstruct.exe ./cmd/anstruct
    
  3. Install globally (optional)

    go install ./cmd/anstruct
    

Usage after local build:

# Linux/macOS
./anstruct --version

# Windows (PowerShell)
.\anstruct.exe --version

Quick Start

1. Generate from AI Prompt
# Generate blueprint file
anstruct aistruct "nodejs express api with auth" -o api.struct

# Generate project directly
anstruct aistruct "react dashboard with routing" --apply -o ./dashboard
2. Create from Blueprint
# Create myapp.struct
cat > myapp.struct << 'EOF'
myapp/
	src/
		main.go
		routes/
			api.go
	config/
		app.yaml
	Dockerfile
	README.md
EOF

# Generate project
anstruct mstruct myapp.struct -o ./output
3. Reverse Engineer Project
# Convert project to blueprint
anstruct rstruct ./my-existing-app -o app.struct
4. Watch & Sync
# Two-way sync
anstruct watch ./myapp ./myapp.struct --full

# One-way: blueprint → folder
anstruct watch ./myapp ./myapp.struct --half struct

# One-way: folder → blueprint
anstruct watch ./myapp ./myapp.struct --half folder

Documentation

You can find full guides and references in the Documentation file. It covers everything from basic usage to advanced features — including CLI commands, structure syntax, and AI integration.

Contributing

Contributions are welcome. If you'd like to suggest improvements, fix bugs, or enhance features, please see the Contributing Guide for details.

License

MIT License - see LICENSE file for details.


Acknowledgments


Support


Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type OperationRecreator

type OperationRecreator struct {
	// contains filtered or unexported fields
}

func (*OperationRecreator) RecreateOperation

func (r *OperationRecreator) RecreateOperation(ctx context.Context, op core.Operation) error

type Service

type Service struct {
	Gen       *ai.AIGenerator
	Parser    core.Parser
	Reverser  core.Reverser
	Validator core.Validator
	History   core.History
	Writer    *generator.Generator
}

func NewService

func NewService(endpoint, historyPath string) *Service

func (*Service) AIStruct

func (s *Service) AIStruct(ctx context.Context, prompt, outPath string, opts core.AIOptions) error

func (*Service) MStruct

func (s *Service) MStruct(ctx context.Context, structFile, outputDir string, opts core.GenerateOptions) (core.Receipt, error)

func (*Service) NormalizeStruct

func (s *Service) NormalizeStruct(ctx context.Context, inputContent, outPath string, opts core.AIOptions) error

func (*Service) RStruct

func (s *Service) RStruct(ctx context.Context, inputDir string, outPath string) error

func (*Service) Watch

func (s *Service) Watch(ctx context.Context, projectPath, blueprintPath string, debounce time.Duration, verbose bool) error

Directories

Path Synopsis
cmd
anstruct command
internal
ai

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL