constitution

package
v0.3.5 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ConstitutionCmd = &cobra.Command{
	Use:   "constitution [amendment text]",
	Short: "Create the constitution, or append a dated amendment",
	Long: `Create the project's constitutional principles in .canary/memory/constitution.md.

With no arguments and no existing file, writes the default constitution.
With no arguments and an existing file, reports that it already exists.
With arguments and an existing file, appends the argument text as a dated
amendment inside a managed <!-- CANARY:amendments:START/END --> section.`,
	RunE: func(cmd *cobra.Command, args []string) error {
		constitutionPath := ".canary/memory/constitution.md"

		if _, err := os.Stat(constitutionPath); os.IsNotExist(err) {

			content, err := utils.ReadEmbeddedFile("base/memory/constitution.md")
			if err != nil {
				return fmt.Errorf("read constitution template: %w", err)
			}

			if err := os.MkdirAll(filepath.Dir(constitutionPath), 0750); err != nil {
				return fmt.Errorf("create memory directory: %w", err)
			}

			if err := os.WriteFile(constitutionPath, content, 0640); err != nil {
				return fmt.Errorf("write constitution: %w", err)
			}

			fmt.Printf("✅ Created constitution at: %s\n", constitutionPath)
			fmt.Println("\nConstitutional Principles:")
			fmt.Println("  I. Requirement-First Development")
			fmt.Println("  II. Specification Discipline")
			fmt.Println("  III. Token-Driven Planning")
			fmt.Println("  IV. Test-First Imperative")
			fmt.Println("  V. Simplicity and Anti-Abstraction")
			fmt.Println("  VI. Integration-First Testing")
			fmt.Println("  VII. Documentation Currency")
			fmt.Println("  VIII. Continuous Improvement")
			fmt.Println("  IX. Amendment Process")
		} else {
			if len(args) == 0 {
				fmt.Printf("✅ Constitution already exists at: %s\n", constitutionPath)
				return nil
			}
			if err := appendAmendment(constitutionPath, strings.TrimSpace(strings.Join(args, " "))); err != nil {
				return err
			}
			fmt.Printf("✅ Appended amendment to: %s\n", constitutionPath)
		}

		return nil
	},
}

CANARY: REQ=ENG-4303; FEATURE="ConstitutionCmd"; ASPECT=CLI; STATUS=IMPL; OWNER=canary; UPDATED=2026-08-30

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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