language-operator 0.1.30 → 0.1.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +35 -0
  3. data/Gemfile.lock +1 -1
  4. data/Makefile +7 -2
  5. data/Rakefile +29 -0
  6. data/docs/dsl/SCHEMA_VERSION.md +250 -0
  7. data/docs/dsl/agent-reference.md +13 -0
  8. data/lib/language_operator/agent/safety/safe_executor.rb +12 -0
  9. data/lib/language_operator/cli/commands/agent.rb +54 -101
  10. data/lib/language_operator/cli/commands/cluster.rb +37 -1
  11. data/lib/language_operator/cli/commands/persona.rb +2 -5
  12. data/lib/language_operator/cli/commands/status.rb +5 -18
  13. data/lib/language_operator/cli/commands/system.rb +772 -0
  14. data/lib/language_operator/cli/formatters/code_formatter.rb +3 -7
  15. data/lib/language_operator/cli/formatters/log_formatter.rb +3 -5
  16. data/lib/language_operator/cli/formatters/progress_formatter.rb +3 -7
  17. data/lib/language_operator/cli/formatters/status_formatter.rb +37 -0
  18. data/lib/language_operator/cli/formatters/table_formatter.rb +10 -26
  19. data/lib/language_operator/cli/helpers/pastel_helper.rb +24 -0
  20. data/lib/language_operator/cli/main.rb +4 -0
  21. data/lib/language_operator/dsl/schema.rb +1102 -0
  22. data/lib/language_operator/dsl.rb +1 -0
  23. data/lib/language_operator/logger.rb +4 -4
  24. data/lib/language_operator/templates/README.md +23 -0
  25. data/lib/language_operator/templates/examples/agent_synthesis.tmpl +115 -0
  26. data/lib/language_operator/templates/examples/persona_distillation.tmpl +19 -0
  27. data/lib/language_operator/templates/schema/.gitkeep +0 -0
  28. data/lib/language_operator/templates/schema/CHANGELOG.md +93 -0
  29. data/lib/language_operator/templates/schema/agent_dsl_openapi.yaml +306 -0
  30. data/lib/language_operator/templates/schema/agent_dsl_schema.json +452 -0
  31. data/lib/language_operator/version.rb +1 -1
  32. data/requirements/tasks/iterate.md +2 -2
  33. metadata +13 -9
  34. data/examples/README.md +0 -569
  35. data/examples/agent_example.rb +0 -86
  36. data/examples/chat_endpoint_agent.rb +0 -118
  37. data/examples/github_webhook_agent.rb +0 -171
  38. data/examples/mcp_agent.rb +0 -158
  39. data/examples/oauth_callback_agent.rb +0 -296
  40. data/examples/stripe_webhook_agent.rb +0 -219
  41. data/examples/webhook_agent.rb +0 -80
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c31089cce835003d727a915a79d0ddf4a3fe1300dee6027ec842e6ef8dc5361b
4
- data.tar.gz: e6450b3f1a2c898247b1dc01d543086881371939549889fbfcb7d6d8c8c992a0
3
+ metadata.gz: eb53d7e9ca7cceedb04334c17bcfde8c976f94916c2da54c35de1dee3884444e
4
+ data.tar.gz: 0b71cd8e346ae4a058806e5db91165a1a5cd24c63bd9b68fd361b430cd333131
5
5
  SHA512:
6
- metadata.gz: 61f3a17c1e9b7369e18a686a9fcd02af26f0e66a7f7a9e24540e6695532390c931cfc426a3f8e67e6cbf2ad5a71a98dfaa0c2564cd4819a3d8c85af99bd70040
7
- data.tar.gz: ecb13cc62fba6fe0e2a7f05e383727680c9c8d34fefc6522fdafea07947373117cacda56b8c36c88bfb460b0d1a627d3ca45b561893026ac652e517bbf12af73
6
+ metadata.gz: 85349b922729847281abeadcf0bc27a0abff89034c97ffe01d0c8b1adfd97db104622c9f9bb4a9f16e65b90e9ad22dd6c6ede84c61714e210b2da72b3c7050e0
7
+ data.tar.gz: d2daaeb57d6ce2fbe50e231980d306e5b5bd4b592cade3bbf3a92df15b3733db53b6f12c693c68af5ee82d27f5f6902aab724c80ef589d0ed7733719018469df
data/CHANGELOG.md CHANGED
@@ -7,6 +7,41 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ### Added
11
+ - **Schema Version Method**: Added `LanguageOperator::Dsl::Schema.version` method that returns the current schema version (linked to gem version)
12
+ - **Schema Versioning Documentation**: Added comprehensive `docs/dsl/SCHEMA_VERSION.md` documenting versioning policy, semantic version semantics for schema changes, compatibility rules, and deprecation policy
13
+ - **Schema Export CLI Commands**: New `aictl system schema` command for exporting DSL schema
14
+ - Export as JSON Schema v7 (default): `aictl system schema`
15
+ - Export as YAML: `aictl system schema --format yaml`
16
+ - Export as OpenAPI 3.0.3 spec: `aictl system schema --format openapi`
17
+ - Show version only: `aictl system schema --version`
18
+ - **Synthesis Template Management**: New `aictl system synthesis-template` command for managing code generation templates
19
+ - Export agent synthesis template: `aictl system synthesis-template`
20
+ - Export persona distillation template: `aictl system synthesis-template --type persona`
21
+ - Export with JSON/YAML metadata: `aictl system synthesis-template --format json --with-schema`
22
+ - Validate template syntax: `aictl system synthesis-template --validate`
23
+ - **Template Validation**: New `aictl system validate-template` command for validating synthesis templates
24
+ - Validate custom templates: `aictl system validate-template --template /path/to/template.tmpl`
25
+ - Validate bundled templates: `aictl system validate-template --type agent`
26
+ - AST-based validation against DSL schema
27
+ - Detailed violation reporting with line numbers
28
+ - **Synthesis Testing**: New `aictl system test-synthesis` command for testing agent code generation
29
+ - Test synthesis from natural language: `aictl system test-synthesis --instructions "Monitor GitHub issues"`
30
+ - Dry-run mode to preview prompts: `--dry-run`
31
+ - Automatic temporal intent detection (scheduled vs autonomous)
32
+ - LLM-powered code generation with validation
33
+ - **Schema Artifacts**: Auto-generated schema artifacts stored in `lib/language_operator/templates/schema/`
34
+ - `agent_dsl_schema.json` - Complete JSON Schema v7 specification
35
+ - `agent_dsl_openapi.yaml` - OpenAPI 3.0.3 API documentation
36
+ - `CHANGELOG.md` - Schema version history
37
+ - **Safe Methods API**: New public methods on `LanguageOperator::Dsl::Schema`
38
+ - `Schema.safe_agent_methods` - Returns array of safe agent DSL methods
39
+ - `Schema.safe_tool_methods` - Returns array of safe tool DSL methods
40
+ - `Schema.safe_helper_methods` - Returns array of safe helper methods
41
+ - Schema version method includes YARD documentation with examples
42
+ - Tests added for schema version access and validation
43
+ - Integration tests for all new CLI commands
44
+
10
45
  ### Changed
11
46
  - **GitHub Migration**: Migrated project from self-hosted Forgejo to GitHub
12
47
  - Repository now hosted at: https://github.com/language-operator/language-operator-gem
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- language-operator (0.1.30)
4
+ language-operator (0.1.31)
5
5
  k8s-ruby (~> 0.17)
6
6
  mcp (~> 0.4)
7
7
  opentelemetry-exporter-otlp (~> 0.27)
data/Makefile CHANGED
@@ -1,4 +1,4 @@
1
- .PHONY: help build test install console docs clean version-bump lint
1
+ .PHONY: help build test install console docs clean version-bump lint schema
2
2
 
3
3
  .DEFAULT_GOAL := help
4
4
 
@@ -8,7 +8,12 @@ help: ## Show this help message
8
8
  @echo 'Available targets:'
9
9
  @awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf " %-20s %s\n", $$1, $$2}' $(MAKEFILE_LIST)
10
10
 
11
- build: ## Build the gem
11
+ schema: ## Generate schema artifacts (JSON Schema and OpenAPI)
12
+ @echo "Generating schema artifacts..."
13
+ @bundle exec rake schema:generate
14
+ @echo "✅ Schema artifacts generated"
15
+
16
+ build: schema ## Build the gem
12
17
  @echo "Building language-operator gem..."
13
18
  @gem build language-operator.gemspec
14
19
  @echo "✅ Gem built successfully"
data/Rakefile CHANGED
@@ -32,3 +32,32 @@ task :console do
32
32
  ARGV.clear
33
33
  IRB.start
34
34
  end
35
+
36
+ namespace :schema do
37
+ desc 'Generate schema artifacts (JSON Schema and OpenAPI)'
38
+ task :generate do
39
+ require 'json'
40
+ require 'yaml'
41
+ require_relative 'lib/language_operator/dsl/schema'
42
+
43
+ schema_dir = File.join(__dir__, 'lib', 'language_operator', 'templates', 'schema')
44
+ FileUtils.mkdir_p(schema_dir)
45
+
46
+ # Generate JSON Schema
47
+ json_schema_path = File.join(schema_dir, 'agent_dsl_schema.json')
48
+ puts "Generating JSON Schema: #{json_schema_path}"
49
+ schema = LanguageOperator::Dsl::Schema.to_json_schema
50
+ File.write(json_schema_path, JSON.pretty_generate(schema))
51
+ puts "✅ Generated #{json_schema_path}"
52
+
53
+ # Generate OpenAPI spec
54
+ openapi_path = File.join(schema_dir, 'agent_dsl_openapi.yaml')
55
+ puts "Generating OpenAPI spec: #{openapi_path}"
56
+ openapi = LanguageOperator::Dsl::Schema.to_openapi
57
+ File.write(openapi_path, YAML.dump(openapi))
58
+ puts "✅ Generated #{openapi_path}"
59
+
60
+ puts "\nSchema artifacts generated successfully!"
61
+ puts "Version: #{LanguageOperator::Dsl::Schema.version}"
62
+ end
63
+ end
@@ -0,0 +1,250 @@
1
+ # Schema Versioning Policy
2
+
3
+ Language Operator DSL Schema uses semantic versioning linked directly to the gem version.
4
+
5
+ ## Version Format
6
+
7
+ Schema versions follow [Semantic Versioning 2.0.0](https://semver.org/):
8
+
9
+ ```
10
+ MAJOR.MINOR.PATCH
11
+ ```
12
+
13
+ ## Accessing Schema Version
14
+
15
+ ### Programmatic Access
16
+
17
+ ```ruby
18
+ require 'language_operator'
19
+
20
+ # Get schema version
21
+ LanguageOperator::Dsl::Schema.version
22
+ # => "0.1.30"
23
+
24
+ # Version is also included in JSON Schema output
25
+ schema = LanguageOperator::Dsl::Schema.to_json_schema
26
+ schema[:version]
27
+ # => "0.1.30"
28
+ ```
29
+
30
+ ### JSON Schema Output
31
+
32
+ When generating JSON Schema, the version is automatically included:
33
+
34
+ ```json
35
+ {
36
+ "$schema": "http://json-schema.org/draft-07/schema#",
37
+ "$id": "https://github.com/language-operator/language-operator-gem/schema/agent-dsl.json",
38
+ "title": "Language Operator Agent DSL",
39
+ "version": "0.1.30",
40
+ ...
41
+ }
42
+ ```
43
+
44
+ ## Version Semantics
45
+
46
+ The schema version is **identical** to the gem version (`LanguageOperator::VERSION`). Changes to the schema follow these rules:
47
+
48
+ ### MAJOR Version (X.0.0)
49
+
50
+ Breaking changes that require updates to existing agent definitions:
51
+
52
+ **Examples:**
53
+ - Removing DSL methods (e.g., removing `schedule` method)
54
+ - Renaming required fields (e.g., `description` → `summary`)
55
+ - Changing parameter types incompatibly (e.g., `mode` from Symbol to String)
56
+ - Removing supported execution modes
57
+ - Changing workflow dependency resolution behavior
58
+ - Altering constraint validation rules in breaking ways
59
+
60
+ **Migration Required:** Users must update their agent definitions to match new schema.
61
+
62
+ **Breaking Change Indicators:**
63
+ - Methods removed from `SAFE_AGENT_METHODS`, `SAFE_TOOL_METHODS`, or `SAFE_HELPER_METHODS`
64
+ - Required fields added or changed
65
+ - Enum values removed
66
+ - Pattern validation tightened (existing valid values become invalid)
67
+
68
+ ### MINOR Version (0.X.0)
69
+
70
+ Backward-compatible additions and enhancements:
71
+
72
+ **Examples:**
73
+ - Adding new DSL methods (e.g., new output destinations)
74
+ - Adding new optional fields (e.g., new constraint types)
75
+ - Adding new execution modes
76
+ - Expanding enums (e.g., adding authentication types)
77
+ - Adding new workflow features that don't affect existing workflows
78
+ - Relaxing validation patterns (more values become valid)
79
+ - Adding new helper methods
80
+
81
+ **Migration Required:** None. Existing agent definitions continue to work.
82
+
83
+ **Addition Indicators:**
84
+ - New methods added to safe method lists
85
+ - New optional properties in schema definitions
86
+ - New enum values
87
+ - New JSON Schema definitions
88
+ - Pattern validation relaxed
89
+
90
+ ### PATCH Version (0.0.X)
91
+
92
+ Bug fixes and non-breaking improvements:
93
+
94
+ **Examples:**
95
+ - Fixing validation regex patterns that were too strict
96
+ - Correcting schema descriptions or documentation
97
+ - Fixing default values
98
+ - Improving error messages
99
+ - Performance optimizations in schema generation
100
+ - Documentation improvements
101
+
102
+ **Migration Required:** None. Fully backward compatible.
103
+
104
+ **Fix Indicators:**
105
+ - Pattern fixes (making existing valid definitions work correctly)
106
+ - Description clarifications
107
+ - Default value corrections
108
+ - Schema metadata updates
109
+
110
+ ## Schema Evolution Examples
111
+
112
+ ### Example: MAJOR Version Change (Breaking)
113
+
114
+ **Before (v0.1.x):**
115
+ ```ruby
116
+ agent "my-agent" do
117
+ mode :autonomous # Symbol
118
+ schedule "0 12 * * *"
119
+ end
120
+ ```
121
+
122
+ **After (v1.0.0) - Hypothetical Breaking Change:**
123
+ ```ruby
124
+ agent "my-agent" do
125
+ mode "autonomous" # Now requires String
126
+ cron_schedule "0 12 * * *" # Renamed method
127
+ end
128
+ ```
129
+
130
+ **Impact:** Existing agent definitions fail validation. Users must update code.
131
+
132
+ ### Example: MINOR Version Change (Addition)
133
+
134
+ **Before (v0.1.x):**
135
+ ```ruby
136
+ agent "my-agent" do
137
+ constraints do
138
+ daily_budget 10.00
139
+ end
140
+ end
141
+ ```
142
+
143
+ **After (v0.2.0) - New Feature:**
144
+ ```ruby
145
+ agent "my-agent" do
146
+ constraints do
147
+ daily_budget 10.00
148
+ monthly_budget 250.00 # NEW: Added in 0.2.0
149
+ end
150
+ end
151
+ ```
152
+
153
+ **Impact:** None. Old definitions still valid. New feature available optionally.
154
+
155
+ ### Example: PATCH Version Change (Fix)
156
+
157
+ **Before (v0.1.29):**
158
+ ```ruby
159
+ # Bug: timeout pattern too strict, rejects "120s"
160
+ constraints do
161
+ timeout "2m" # Works
162
+ # timeout "120s" # Would fail validation
163
+ end
164
+ ```
165
+
166
+ **After (v0.1.30) - Bug Fix:**
167
+ ```ruby
168
+ # Fixed: timeout pattern now accepts both formats
169
+ constraints do
170
+ timeout "2m" # Still works
171
+ timeout "120s" # Now works too
172
+ end
173
+ ```
174
+
175
+ **Impact:** None. Existing valid definitions unchanged. Previously invalid definitions may now work.
176
+
177
+ ## Version Compatibility
178
+
179
+ ### Agent Definition Compatibility
180
+
181
+ Agent definitions are compatible across:
182
+ - ✅ Same MAJOR version (e.g., 0.1.0 agent works with 0.1.30 gem)
183
+ - ✅ MINOR upgrades (e.g., 0.1.x agent works with 0.2.x gem)
184
+ - ❌ MAJOR upgrades (e.g., 0.x.x agent may not work with 1.x.x gem)
185
+
186
+ ### JSON Schema Compatibility
187
+
188
+ Generated JSON Schemas are versioned. Consumers should:
189
+
190
+ 1. **Check schema version** before validation:
191
+ ```ruby
192
+ schema = LanguageOperator::Dsl::Schema.to_json_schema
193
+ if Gem::Version.new(schema[:version]) >= Gem::Version.new("0.2.0")
194
+ # Use features from 0.2.0+
195
+ end
196
+ ```
197
+
198
+ 2. **Pin gem versions** in production:
199
+ ```ruby
200
+ # Gemfile
201
+ gem 'language-operator', '~> 0.1.0' # Allow patch updates only
202
+ ```
203
+
204
+ ## Deprecation Policy
205
+
206
+ When planning MAJOR version changes:
207
+
208
+ 1. **Deprecation warnings** added in MINOR version before removal
209
+ 2. **Migration guides** provided in documentation
210
+ 3. **Minimum deprecation period** of one MAJOR version cycle
211
+
212
+ Example timeline:
213
+ - v0.1.0: Feature X introduced
214
+ - v0.2.0: Feature X deprecated (warnings added, docs updated)
215
+ - v0.3.0: Still supported with warnings
216
+ - v1.0.0: Feature X removed (breaking change)
217
+
218
+ ## Validation and Testing
219
+
220
+ ### Schema Version Testing
221
+
222
+ The gem includes comprehensive tests ensuring:
223
+ - Schema version matches gem version
224
+ - Version is included in JSON Schema output
225
+ - Safe method lists are validated against ASTValidator constants
226
+
227
+ See: `spec/language_operator/dsl/schema_spec.rb`
228
+
229
+ ### Breaking Change Detection
230
+
231
+ When submitting changes:
232
+
233
+ 1. **Check if change is breaking** using checklist above
234
+ 2. **Update version accordingly** in `lib/language_operator/version.rb`
235
+ 3. **Document in CHANGELOG.md** under appropriate section
236
+ 4. **Add migration guide** if MAJOR version bump
237
+ 5. **Update this document** if versioning policy changes
238
+
239
+ ## Related Documentation
240
+
241
+ - [Semantic Versioning Specification](https://semver.org/)
242
+ - [Agent DSL Reference](./agent-reference.md)
243
+ - [Best Practices](./best-practices.md)
244
+ - [CHANGELOG.md](../../CHANGELOG.md)
245
+
246
+ ## Questions?
247
+
248
+ For questions about schema versioning:
249
+ - Open an issue: https://github.com/language-operator/language-operator-gem/issues
250
+ - Check existing discussions about schema changes
@@ -4,6 +4,7 @@ Complete reference guide for the Language Operator agent DSL.
4
4
 
5
5
  ## Table of Contents
6
6
 
7
+ - [Schema Version](#schema-version)
7
8
  - [Agent Definition](#agent-definition)
8
9
  - [Execution Modes](#execution-modes)
9
10
  - [Schedule Configuration](#schedule-configuration)
@@ -14,6 +15,18 @@ Complete reference guide for the Language Operator agent DSL.
14
15
  - [Output Configuration](#output-configuration)
15
16
  - [Complete Examples](#complete-examples)
16
17
 
18
+ ## Schema Version
19
+
20
+ The Language Operator DSL schema is versioned using semantic versioning. The schema version is identical to the gem version.
21
+
22
+ **Access schema version:**
23
+
24
+ ```ruby
25
+ LanguageOperator::Dsl::Schema.version # => "0.1.30"
26
+ ```
27
+
28
+ For detailed information about schema versioning policy, version semantics, and compatibility, see [Schema Versioning Policy](./SCHEMA_VERSION.md).
29
+
17
30
  ## Agent Definition
18
31
 
19
32
  The basic structure of an agent definition:
@@ -69,6 +69,18 @@ module LanguageOperator
69
69
  # Log the call
70
70
  @__executor__.log_call(@__context__, method_name, args)
71
71
 
72
+ # Special handling for require - allow only 'language_operator'
73
+ if %i[require require_relative].include?(method_name)
74
+ required_gem = args.first.to_s
75
+ return ::Kernel.require(required_gem) if required_gem == 'language_operator'
76
+
77
+ # Allow require 'language_operator'
78
+
79
+ ::Kernel.raise ::LanguageOperator::Agent::Safety::SafeExecutor::SecurityError,
80
+ "Require '#{required_gem}' is not allowed. Only 'require \"language_operator\"' is permitted."
81
+
82
+ end
83
+
72
84
  # Check if method is safe
73
85
  unless safe_method?(method_name)
74
86
  ::Kernel.raise ::LanguageOperator::Agent::Safety::SafeExecutor::SecurityError,