agentic-lang 0.2.0

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 (146) hide show
  1. package/COMMUNITY.md +220 -0
  2. package/CONTRIBUTING.md +194 -0
  3. package/FINAL_REPORT.md +398 -0
  4. package/FOR_OTHER_LLMS.md +286 -0
  5. package/IMPROVEMENTS.md +319 -0
  6. package/LAUNCH_GUIDE.md +388 -0
  7. package/LICENSE +21 -0
  8. package/NPM_PUBLISH.md +257 -0
  9. package/PROJECT_COMPLETE.md +414 -0
  10. package/PROJECT_OVERVIEW.md +265 -0
  11. package/PROJECT_TREE.txt +228 -0
  12. package/PUBLISHING_GUIDE.md +426 -0
  13. package/PUBLISH_NOW.md +337 -0
  14. package/QUICKSTART.md +207 -0
  15. package/README.md +195 -0
  16. package/README_ENHANCED.md +329 -0
  17. package/READY_TO_LAUNCH.txt +56 -0
  18. package/REFACTOR_PLAN.md +179 -0
  19. package/ROADMAP.md +201 -0
  20. package/SUMMARY.md +315 -0
  21. package/bin/agentic.js +3 -0
  22. package/blog/001-introducing-agentic.md +382 -0
  23. package/blog/002-confidence-driven-development.md +490 -0
  24. package/blog/003-formal-verification.md +427 -0
  25. package/blog/004-multi-agent-production.md +436 -0
  26. package/dist/cli.d.ts +7 -0
  27. package/dist/cli.d.ts.map +1 -0
  28. package/dist/cli.js +151 -0
  29. package/dist/cli.js.map +1 -0
  30. package/dist/diagnostics/diagnostic.d.ts +115 -0
  31. package/dist/diagnostics/diagnostic.d.ts.map +1 -0
  32. package/dist/diagnostics/diagnostic.js +101 -0
  33. package/dist/diagnostics/diagnostic.js.map +1 -0
  34. package/dist/diagnostics/formatter.d.ts +36 -0
  35. package/dist/diagnostics/formatter.d.ts.map +1 -0
  36. package/dist/diagnostics/formatter.js +263 -0
  37. package/dist/diagnostics/formatter.js.map +1 -0
  38. package/dist/effects/effect-system.d.ts +64 -0
  39. package/dist/effects/effect-system.d.ts.map +1 -0
  40. package/dist/effects/effect-system.js +197 -0
  41. package/dist/effects/effect-system.js.map +1 -0
  42. package/dist/generator/typescript-generator.d.ts +31 -0
  43. package/dist/generator/typescript-generator.d.ts.map +1 -0
  44. package/dist/generator/typescript-generator.js +308 -0
  45. package/dist/generator/typescript-generator.js.map +1 -0
  46. package/dist/index.d.ts +19 -0
  47. package/dist/index.d.ts.map +1 -0
  48. package/dist/index.js +60 -0
  49. package/dist/index.js.map +1 -0
  50. package/dist/lean4/exporter.d.ts +24 -0
  51. package/dist/lean4/exporter.d.ts.map +1 -0
  52. package/dist/lean4/exporter.js +142 -0
  53. package/dist/lean4/exporter.js.map +1 -0
  54. package/dist/lsp/server.d.ts +6 -0
  55. package/dist/lsp/server.d.ts.map +1 -0
  56. package/dist/lsp/server.js +131 -0
  57. package/dist/lsp/server.js.map +1 -0
  58. package/dist/parser/lexer.d.ts +79 -0
  59. package/dist/parser/lexer.d.ts.map +1 -0
  60. package/dist/parser/lexer.js +296 -0
  61. package/dist/parser/lexer.js.map +1 -0
  62. package/dist/parser/parser-enhanced.d.ts +12 -0
  63. package/dist/parser/parser-enhanced.d.ts.map +1 -0
  64. package/dist/parser/parser-enhanced.js +206 -0
  65. package/dist/parser/parser-enhanced.js.map +1 -0
  66. package/dist/parser/parser.d.ts +34 -0
  67. package/dist/parser/parser.d.ts.map +1 -0
  68. package/dist/parser/parser.js +507 -0
  69. package/dist/parser/parser.js.map +1 -0
  70. package/dist/property-tests/generator-enhanced.d.ts +27 -0
  71. package/dist/property-tests/generator-enhanced.d.ts.map +1 -0
  72. package/dist/property-tests/generator-enhanced.js +209 -0
  73. package/dist/property-tests/generator-enhanced.js.map +1 -0
  74. package/dist/property-tests/generator-fixed.d.ts +2 -0
  75. package/dist/property-tests/generator-fixed.d.ts.map +1 -0
  76. package/dist/property-tests/generator-fixed.js +7 -0
  77. package/dist/property-tests/generator-fixed.js.map +1 -0
  78. package/dist/property-tests/generator.d.ts +28 -0
  79. package/dist/property-tests/generator.d.ts.map +1 -0
  80. package/dist/property-tests/generator.js +284 -0
  81. package/dist/property-tests/generator.js.map +1 -0
  82. package/dist/refinements/refinement-types.d.ts +96 -0
  83. package/dist/refinements/refinement-types.d.ts.map +1 -0
  84. package/dist/refinements/refinement-types.js +234 -0
  85. package/dist/refinements/refinement-types.js.map +1 -0
  86. package/dist/repl.d.ts +21 -0
  87. package/dist/repl.d.ts.map +1 -0
  88. package/dist/repl.js +317 -0
  89. package/dist/repl.js.map +1 -0
  90. package/dist/runtime/agents.d.ts +97 -0
  91. package/dist/runtime/agents.d.ts.map +1 -0
  92. package/dist/runtime/agents.js +258 -0
  93. package/dist/runtime/agents.js.map +1 -0
  94. package/dist/runtime/index.d.ts +98 -0
  95. package/dist/runtime/index.d.ts.map +1 -0
  96. package/dist/runtime/index.js +253 -0
  97. package/dist/runtime/index.js.map +1 -0
  98. package/dist/types-extended.d.ts +197 -0
  99. package/dist/types-extended.d.ts.map +1 -0
  100. package/dist/types-extended.js +7 -0
  101. package/dist/types-extended.js.map +1 -0
  102. package/dist/types.d.ts +129 -0
  103. package/dist/types.d.ts.map +1 -0
  104. package/dist/types.js +6 -0
  105. package/dist/types.js.map +1 -0
  106. package/dist/verification/z3-engine.d.ts +75 -0
  107. package/dist/verification/z3-engine.d.ts.map +1 -0
  108. package/dist/verification/z3-engine.js +234 -0
  109. package/dist/verification/z3-engine.js.map +1 -0
  110. package/examples/advanced-features.agentic +98 -0
  111. package/examples/annotations.agentic +37 -0
  112. package/examples/auth.agentic +53 -0
  113. package/examples/enterprise-example.agentic +360 -0
  114. package/examples/minimal.agentic +3 -0
  115. package/examples/minimal.ts +7 -0
  116. package/examples/ml-pipeline.agentic +350 -0
  117. package/examples/multi-agent-example.agentic +212 -0
  118. package/examples/onboarding-tutorial.agentic +263 -0
  119. package/examples/production-api.agentic +304 -0
  120. package/examples/real-world-chatbot.agentic +351 -0
  121. package/examples/result-handling.agentic +34 -0
  122. package/examples/runtime.ts +24 -0
  123. package/examples/showcase.agentic +22 -0
  124. package/examples/showcase.ts +28 -0
  125. package/examples/simple-test.agentic +4 -0
  126. package/examples/simple-test.ts +7 -0
  127. package/examples/simple.agentic +20 -0
  128. package/examples/test2.agentic +4 -0
  129. package/examples/test2.ts +9 -0
  130. package/examples/test3.agentic +4 -0
  131. package/examples/test3.ts +9 -0
  132. package/package.json +70 -0
  133. package/playground/index.html +221 -0
  134. package/playground/playground.js +291 -0
  135. package/registry/package-registry.ts +319 -0
  136. package/scripts/build.js +50 -0
  137. package/scripts/validate-confidence-mutation.ts +112 -0
  138. package/stdlib/async/promise.agentic +216 -0
  139. package/stdlib/database/pool.agentic +235 -0
  140. package/stdlib/file/io.agentic +194 -0
  141. package/stdlib/http/client.agentic +168 -0
  142. package/video-scripts/001-agentic-in-100-seconds.md +175 -0
  143. package/vscode-extension/README.md +67 -0
  144. package/vscode-extension/language-configuration.json +31 -0
  145. package/vscode-extension/package.json +46 -0
  146. package/vscode-extension/syntaxes/agentic.tmLanguage.json +134 -0
@@ -0,0 +1,436 @@
1
+ # Building Production Multi-Agent Systems with Agentic
2
+
3
+ **Part 4 of the Agentic Blog Series**
4
+
5
+ ---
6
+
7
+ ## The Multi-Agent Challenge
8
+
9
+ You've built one AI agent. Now you need five agents working together:
10
+ - **Coordinator** - Routes tasks
11
+ - **Analyst** - Analyzes data
12
+ - **Researcher** - Finds information
13
+ - **Writer** - Generates content
14
+ - **Reviewer** - Quality control
15
+
16
+ **How do they communicate? How do they coordinate? How do you prevent chaos?**
17
+
18
+ In frameworks like LangGraph or AutoGen, you write orchestration code. Lots of it.
19
+
20
+ **In Agentic, multi-agent coordination is built into the language.**
21
+
22
+ ---
23
+
24
+ ## Agent Types: A New Primitive
25
+
26
+ ```agentic
27
+ @agent(role: "coordinator", capabilities: ["routing", "delegation"])
28
+ agent CoordinatorAgent {
29
+ inbox: Channel<Task>
30
+ outbox: Channel<Assignment>
31
+
32
+ @handler("task_received")
33
+ @confidence(0.88)
34
+ func route(task: Task) -> Assignment {
35
+ // Type-safe message handling
36
+ // Automatic serialization
37
+ // Built-in error handling
38
+ }
39
+ }
40
+ ```
41
+
42
+ **This is not a class. It's a language primitive.**
43
+
44
+ The compiler:
45
+ - ✅ Generates message serialization
46
+ - ✅ Creates inbox/outbox channels
47
+ - ✅ Validates message types
48
+ - ✅ Ensures handlers match message types
49
+ - ✅ Tracks agent lifecycle
50
+
51
+ ---
52
+
53
+ ## Session Types: Verified Protocols
54
+
55
+ Here's the killer feature: **session types**.
56
+
57
+ ```agentic
58
+ @protocol(A2A) // Agent-to-Agent
59
+ type TaskProcessingProtocol {
60
+ // Protocol definition
61
+ Coordinator -> Worker: TaskAssignment
62
+ Worker -> Coordinator: Acknowledgment
63
+ Worker -> Coordinator: Progress (0..n times)
64
+ Worker -> Coordinator: Result
65
+ close
66
+ }
67
+
68
+ @implements(TaskProcessingProtocol)
69
+ agent WorkerAgent {
70
+ // Compiler verifies protocol compliance!
71
+ }
72
+ ```
73
+
74
+ **If an agent violates the protocol, compilation fails.**
75
+
76
+ This is cutting-edge research (PLDI 2025) in production code.
77
+
78
+ ---
79
+
80
+ ## Real Example: Content Generation Pipeline
81
+
82
+ ```agentic
83
+ @workflow(persistent: true, resumable: true)
84
+ @confidence(0.86)
85
+ func contentPipeline(topic: string) -> Result<Article, Error> {
86
+ // Spawn specialized agents
87
+ researcher = spawn ResearcherAgent()
88
+ outliner = spawn OutlinerAgent()
89
+ writer = spawn WriterAgent()
90
+ reviewer = spawn ReviewerAgent()
91
+
92
+ // Step 1: Research
93
+ @checkpoint("research")
94
+ @budget_limit(feature_max: 2.00)
95
+ researcher.inbox.send(ResearchRequest {
96
+ topic: topic,
97
+ depth: "comprehensive"
98
+ })
99
+
100
+ @timeout(5m)
101
+ research = researcher.outbox.receive() match {
102
+ Some(r) -> r,
103
+ None -> {
104
+ @handoff {
105
+ to: "human_researcher",
106
+ reason: "Automated research timed out",
107
+ context: { topic, elapsed: 5m }
108
+ }
109
+ return Err(Error.RESEARCH_TIMEOUT)
110
+ }
111
+ }
112
+
113
+ // Step 2: Create outline
114
+ @checkpoint("outline")
115
+ outliner.inbox.send(OutlineRequest {
116
+ topic: topic,
117
+ research: research.findings
118
+ })
119
+
120
+ outline = outliner.outbox.receive()
121
+
122
+ // Step 3: Write content
123
+ @checkpoint("writing")
124
+ @budget_limit(feature_max: 5.00)
125
+ writer.inbox.send(WriteRequest {
126
+ outline: outline,
127
+ research: research.findings,
128
+ tone: "professional",
129
+ length: 2000
130
+ })
131
+
132
+ draft = writer.outbox.receive()
133
+
134
+ // Step 4: Review and revise
135
+ @checkpoint("review")
136
+ reviewer.inbox.send(ReviewRequest {
137
+ content: draft.text,
138
+ criteria: ["accuracy", "clarity", "completeness"]
139
+ })
140
+
141
+ review = reviewer.outbox.receive()
142
+
143
+ // Step 5: Revise if needed
144
+ if review.score < 0.85 {
145
+ @checkpoint("revision")
146
+ writer.inbox.send(ReviseRequest {
147
+ draft: draft.text,
148
+ feedback: review.comments
149
+ })
150
+
151
+ final = writer.outbox.receive()
152
+ } else {
153
+ final = draft
154
+ }
155
+
156
+ @checkpoint("complete")
157
+
158
+ return Ok(Article {
159
+ title: final.title,
160
+ content: final.text,
161
+ metadata: {
162
+ topic: topic,
163
+ researchSources: research.sources.length,
164
+ revisions: review.score < 0.85 ? 1 : 0,
165
+ totalCost: getTotalCost(),
166
+ confidence: final.confidence
167
+ }
168
+ })
169
+ }
170
+ ```
171
+
172
+ **This handles:**
173
+ - Multi-agent coordination
174
+ - Checkpoints (can resume if interrupted)
175
+ - Timeouts and fallbacks
176
+ - Cost tracking per agent
177
+ - Quality control with revision loop
178
+ - Full observability
179
+
180
+ **In LangGraph, this is 300+ lines. In Agentic, it's 60 lines.**
181
+
182
+ ---
183
+
184
+ ## Consensus and Voting
185
+
186
+ Multiple agents reach agreement:
187
+
188
+ ```agentic
189
+ @confidence(0.88)
190
+ func decideByConsensus(
191
+ question: Decision,
192
+ agents: Agent[],
193
+ quorum: number = 0.67
194
+ ) -> Result<Answer, ConsensusError> {
195
+ // Each agent votes
196
+ @parallel
197
+ votes = agents.map(agent => agent.vote(question))
198
+
199
+ // Tally results
200
+ tally = countVotes(votes)
201
+
202
+ // Require quorum (67% agreement)
203
+ winner = tally.max()
204
+
205
+ if winner.percentage < quorum {
206
+ // No consensus - escalate
207
+ @escalate_to_human({
208
+ question: question,
209
+ votes: tally,
210
+ message: "Agents cannot reach consensus"
211
+ })
212
+
213
+ return Err(ConsensusError.NO_CONSENSUS)
214
+ }
215
+
216
+ @trace_decision("consensus_reached", {
217
+ decision: winner.answer,
218
+ agreementPercentage: winner.percentage,
219
+ dissenting: agents.length - winner.count
220
+ })
221
+
222
+ return Ok(winner.answer)
223
+ }
224
+ ```
225
+
226
+ **Use for:**
227
+ - Critical decisions
228
+ - Reducing single-agent bias
229
+ - Redundancy for reliability
230
+
231
+ ---
232
+
233
+ ## Auction-Based Task Allocation
234
+
235
+ Agents bid on tasks based on their confidence:
236
+
237
+ ```agentic
238
+ @confidence(0.86)
239
+ func auctionTask(task: Task, agents: Agent[]) -> Result<Agent, Error> {
240
+ // Request bids from all agents
241
+ @parallel(timeout: 5s)
242
+ bids = agents.map(agent =>
243
+ agent.bidOnTask(task) // Each agent returns confidence + cost
244
+ )
245
+
246
+ // Filter low-confidence bids
247
+ qualified = bids.filter(bid => bid.confidence >= 0.75)
248
+
249
+ if qualified.length == 0 {
250
+ @escalate_to_human("No agent confident enough")
251
+ return Err(Error.NO_QUALIFIED_AGENT)
252
+ }
253
+
254
+ // Select best bid (highest confidence / cost ratio)
255
+ winner = qualified.maxBy(bid =>
256
+ bid.confidence / (bid.estimatedCost + 0.01)
257
+ )
258
+
259
+ @trace_decision("task_auctioned", {
260
+ winner: winner.agent.id,
261
+ winningBid: winner.confidence,
262
+ totalBidders: bids.length
263
+ })
264
+
265
+ return Ok(winner.agent)
266
+ }
267
+ ```
268
+
269
+ ---
270
+
271
+ ## Supervision and Fault Tolerance
272
+
273
+ Supervisor restarts failed workers:
274
+
275
+ ```agentic
276
+ @agent(role: "supervisor")
277
+ agent SupervisorAgent {
278
+ workers: Agent[]
279
+ restartPolicy: "always" | "on_failure" | "never"
280
+
281
+ @confidence(0.87)
282
+ func supervise() -> void {
283
+ loop {
284
+ // Monitor worker health
285
+ for worker in self.workers {
286
+ if worker.isFailed() {
287
+ @trace_event("worker_failed", {
288
+ workerId: worker.id,
289
+ reason: worker.getFailureReason()
290
+ })
291
+
292
+ self.restartPolicy match {
293
+ "always" -> self.restartWorker(worker),
294
+ "on_failure" -> {
295
+ if worker.isRestartable() {
296
+ self.restartWorker(worker)
297
+ }
298
+ },
299
+ "never" -> {
300
+ @alert("critical", "Worker ${worker.id} failed and won't restart")
301
+ }
302
+ }
303
+ }
304
+ }
305
+
306
+ sleep(10s)
307
+ }
308
+ }
309
+
310
+ @confidence(0.85)
311
+ func restartWorker(worker: Agent) -> Result<Agent, Error> {
312
+ logger.info("🔄 Restarting worker: ${worker.id}")
313
+
314
+ // Preserve state if possible
315
+ state = worker.getState()
316
+
317
+ // Stop old worker
318
+ worker.stop()
319
+
320
+ // Spawn new worker with same config
321
+ newWorker = spawn WorkerAgent(config: worker.config)
322
+
323
+ // Restore state
324
+ if state {
325
+ newWorker.setState(state)
326
+ }
327
+
328
+ // Replace in worker list
329
+ self.workers = self.workers.map(w =>
330
+ w.id == worker.id ? newWorker : w
331
+ )
332
+
333
+ logger.info("✓ Worker restarted: ${newWorker.id}")
334
+
335
+ return Ok(newWorker)
336
+ }
337
+ }
338
+ ```
339
+
340
+ ---
341
+
342
+ ## Production Lessons
343
+
344
+ ### Lesson 1: Always Use Timeouts
345
+
346
+ ```agentic
347
+ // ✓ Good
348
+ @timeout(30s)
349
+ result = agent.outbox.receive()
350
+
351
+ // ✗ Bad
352
+ result = agent.outbox.receive() // Could wait forever!
353
+ ```
354
+
355
+ ### Lesson 2: Buffer Your Channels
356
+
357
+ ```agentic
358
+ // Unbuffered (synchronous)
359
+ inbox: Channel<Message>(capacity: 0) // Send blocks until receive
360
+
361
+ // Buffered (async, better for production)
362
+ inbox: Channel<Message>(capacity: 100) // Send doesn't block
363
+ ```
364
+
365
+ ### Lesson 3: Implement Backpressure
366
+
367
+ ```agentic
368
+ @backpressure(maxQueueSize: 1000)
369
+ func handleMessage(msg: Message) -> Response {
370
+ if inbox.size() > 1000 {
371
+ return Response.RATE_LIMITED
372
+ }
373
+
374
+ // Process message
375
+ }
376
+ ```
377
+
378
+ ### Lesson 4: Monitor Everything
379
+
380
+ ```agentic
381
+ @trace_agent_metrics({
382
+ messageRate: true,
383
+ errorRate: true,
384
+ latency: true,
385
+ queueDepth: true
386
+ })
387
+ agent ProductionAgent {
388
+ // Automatic metrics collection
389
+ }
390
+ ```
391
+
392
+ ---
393
+
394
+ ## The Bottom Line
395
+
396
+ **Multi-agent systems are hard in other languages.**
397
+
398
+ In Agentic:
399
+ - Agents are language primitives
400
+ - Channels are type-safe
401
+ - Protocols are verified at compile-time
402
+ - Sessions are persistent by default
403
+ - Handoffs are structured
404
+ - Everything is traceable
405
+
406
+ **It just works.**
407
+
408
+ ---
409
+
410
+ ## Try It
411
+
412
+ ```bash
413
+ # Install
414
+ npm install -g agentic-lang
415
+
416
+ # Run multi-agent example
417
+ agentic compile examples/multi-agent-example.agentic
418
+ node examples/multi-agent-example.js
419
+ ```
420
+
421
+ Or try in the [playground](https://agentic-lang.org/playground) (click "Multi-Agent" example).
422
+
423
+ ---
424
+
425
+ **Resources:**
426
+ - [Multi-Agent Cookbook](https://agentic-lang.org/docs/cookbook/multi-agent)
427
+ - [Session Types Guide](https://agentic-lang.org/docs/advanced/session-types)
428
+ - [Agent Patterns](https://agentic-lang.org/docs/patterns/agents)
429
+
430
+ **Join the discussion:** [Discord #multi-agent](https://discord.gg/agentic)
431
+
432
+ ---
433
+
434
+ **That's the series!** Thanks for reading.
435
+
436
+ **Next:** Start building with [Agentic tutorials](https://agentic-lang.org/docs/tutorials/01-hello-world)
package/dist/cli.d.ts ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Agentic CLI
4
+ * Command-line interface for the Agentic transpiler
5
+ */
6
+ export {};
7
+ //# sourceMappingURL=cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAEA;;;GAGG"}
package/dist/cli.js ADDED
@@ -0,0 +1,151 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ /**
4
+ * Agentic CLI
5
+ * Command-line interface for the Agentic transpiler
6
+ */
7
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
8
+ if (k2 === undefined) k2 = k;
9
+ var desc = Object.getOwnPropertyDescriptor(m, k);
10
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
11
+ desc = { enumerable: true, get: function() { return m[k]; } };
12
+ }
13
+ Object.defineProperty(o, k2, desc);
14
+ }) : (function(o, m, k, k2) {
15
+ if (k2 === undefined) k2 = k;
16
+ o[k2] = m[k];
17
+ }));
18
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
19
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
20
+ }) : function(o, v) {
21
+ o["default"] = v;
22
+ });
23
+ var __importStar = (this && this.__importStar) || (function () {
24
+ var ownKeys = function(o) {
25
+ ownKeys = Object.getOwnPropertyNames || function (o) {
26
+ var ar = [];
27
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
28
+ return ar;
29
+ };
30
+ return ownKeys(o);
31
+ };
32
+ return function (mod) {
33
+ if (mod && mod.__esModule) return mod;
34
+ var result = {};
35
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
36
+ __setModuleDefault(result, mod);
37
+ return result;
38
+ };
39
+ })();
40
+ var __importDefault = (this && this.__importDefault) || function (mod) {
41
+ return (mod && mod.__esModule) ? mod : { "default": mod };
42
+ };
43
+ Object.defineProperty(exports, "__esModule", { value: true });
44
+ const commander_1 = require("commander");
45
+ const fs = __importStar(require("fs"));
46
+ const parser_1 = require("./parser/parser");
47
+ const typescript_generator_1 = require("./generator/typescript-generator");
48
+ const chokidar_1 = __importDefault(require("chokidar"));
49
+ const program = new commander_1.Command();
50
+ program
51
+ .name('agentic')
52
+ .description('Agentic programming language transpiler')
53
+ .version('0.1.0');
54
+ program
55
+ .command('compile <input>')
56
+ .description('Compile an .agentic file to TypeScript')
57
+ .option('-o, --output <path>', 'Output file path')
58
+ .option('--source-map', 'Generate source map')
59
+ .action((input, options) => {
60
+ try {
61
+ const result = compileFile(input, options);
62
+ console.log(`✓ Compiled ${input} → ${result.outputPath}`);
63
+ if (result.diagnostics.length > 0) {
64
+ console.log('\nDiagnostics:');
65
+ result.diagnostics.forEach(d => {
66
+ console.log(` [${d.severity}] ${d.message} at line ${d.location.start.line}`);
67
+ });
68
+ }
69
+ }
70
+ catch (error) {
71
+ console.error('✗ Compilation failed:', error.message);
72
+ process.exit(1);
73
+ }
74
+ });
75
+ program
76
+ .command('watch <pattern>')
77
+ .description('Watch .agentic files and recompile on change')
78
+ .option('-o, --output-dir <dir>', 'Output directory')
79
+ .action((pattern, options) => {
80
+ console.log(`Watching: ${pattern}`);
81
+ const watcher = chokidar_1.default.watch(pattern, {
82
+ persistent: true,
83
+ ignoreInitial: false,
84
+ awaitWriteFinish: {
85
+ stabilityThreshold: 100,
86
+ pollInterval: 100,
87
+ },
88
+ });
89
+ watcher
90
+ .on('add', (file) => {
91
+ console.log(`\nFile added: ${file}`);
92
+ try {
93
+ compileFile(file, options);
94
+ console.log(`✓ Compiled ${file}`);
95
+ }
96
+ catch (error) {
97
+ console.error(`✗ Error compiling ${file}:`, error.message);
98
+ }
99
+ })
100
+ .on('change', (file) => {
101
+ console.log(`\nFile changed: ${file}`);
102
+ try {
103
+ compileFile(file, options);
104
+ console.log(`✓ Recompiled ${file}`);
105
+ }
106
+ catch (error) {
107
+ console.error(`✗ Error compiling ${file}:`, error.message);
108
+ }
109
+ })
110
+ .on('error', (error) => {
111
+ console.error('Watcher error:', error);
112
+ });
113
+ console.log('\nPress Ctrl+C to stop watching...');
114
+ process.on('SIGINT', () => {
115
+ console.log('\nStopping watcher...');
116
+ watcher.close();
117
+ process.exit(0);
118
+ });
119
+ });
120
+ program
121
+ .command('version')
122
+ .description('Show version information')
123
+ .action(() => {
124
+ console.log('Agentic v0.1.0');
125
+ console.log('An AI-native programming language');
126
+ });
127
+ function compileFile(inputPath, options) {
128
+ // Read source file
129
+ const source = fs.readFileSync(inputPath, 'utf-8');
130
+ // Parse
131
+ const parser = new parser_1.Parser();
132
+ const ast = parser.parse(source);
133
+ // Generate TypeScript
134
+ const generator = new typescript_generator_1.TypeScriptGenerator(inputPath);
135
+ const code = generator.generate(ast);
136
+ // Determine output path
137
+ const outputPath = options.output || inputPath.replace('.agentic', '.ts');
138
+ // Write output
139
+ fs.writeFileSync(outputPath, code, 'utf-8');
140
+ // Write source map if requested
141
+ if (options.sourceMap) {
142
+ const sourceMapPath = outputPath + '.map';
143
+ fs.writeFileSync(sourceMapPath, generator.getSourceMap(), 'utf-8');
144
+ }
145
+ return {
146
+ outputPath,
147
+ diagnostics: [],
148
+ };
149
+ }
150
+ program.parse();
151
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;AAEA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,yCAAoC;AACpC,uCAAyB;AAEzB,4CAAyC;AACzC,2EAAuE;AACvE,wDAAgC;AAEhC,MAAM,OAAO,GAAG,IAAI,mBAAO,EAAE,CAAC;AAE9B,OAAO;KACJ,IAAI,CAAC,SAAS,CAAC;KACf,WAAW,CAAC,yCAAyC,CAAC;KACtD,OAAO,CAAC,OAAO,CAAC,CAAC;AAEpB,OAAO;KACJ,OAAO,CAAC,iBAA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