optimal-cli 0.1.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 (56) hide show
  1. package/README.md +175 -0
  2. package/dist/bin/optimal.d.ts +2 -0
  3. package/dist/bin/optimal.js +995 -0
  4. package/dist/lib/budget/projections.d.ts +115 -0
  5. package/dist/lib/budget/projections.js +384 -0
  6. package/dist/lib/budget/scenarios.d.ts +93 -0
  7. package/dist/lib/budget/scenarios.js +214 -0
  8. package/dist/lib/cms/publish-blog.d.ts +62 -0
  9. package/dist/lib/cms/publish-blog.js +74 -0
  10. package/dist/lib/cms/strapi-client.d.ts +123 -0
  11. package/dist/lib/cms/strapi-client.js +213 -0
  12. package/dist/lib/config.d.ts +55 -0
  13. package/dist/lib/config.js +206 -0
  14. package/dist/lib/infra/deploy.d.ts +29 -0
  15. package/dist/lib/infra/deploy.js +58 -0
  16. package/dist/lib/infra/migrate.d.ts +34 -0
  17. package/dist/lib/infra/migrate.js +103 -0
  18. package/dist/lib/kanban.d.ts +46 -0
  19. package/dist/lib/kanban.js +118 -0
  20. package/dist/lib/newsletter/distribute.d.ts +52 -0
  21. package/dist/lib/newsletter/distribute.js +193 -0
  22. package/dist/lib/newsletter/generate-insurance.d.ts +42 -0
  23. package/dist/lib/newsletter/generate-insurance.js +36 -0
  24. package/dist/lib/newsletter/generate.d.ts +104 -0
  25. package/dist/lib/newsletter/generate.js +571 -0
  26. package/dist/lib/returnpro/anomalies.d.ts +64 -0
  27. package/dist/lib/returnpro/anomalies.js +166 -0
  28. package/dist/lib/returnpro/audit.d.ts +32 -0
  29. package/dist/lib/returnpro/audit.js +147 -0
  30. package/dist/lib/returnpro/diagnose.d.ts +52 -0
  31. package/dist/lib/returnpro/diagnose.js +281 -0
  32. package/dist/lib/returnpro/kpis.d.ts +32 -0
  33. package/dist/lib/returnpro/kpis.js +192 -0
  34. package/dist/lib/returnpro/templates.d.ts +48 -0
  35. package/dist/lib/returnpro/templates.js +229 -0
  36. package/dist/lib/returnpro/upload-income.d.ts +25 -0
  37. package/dist/lib/returnpro/upload-income.js +235 -0
  38. package/dist/lib/returnpro/upload-netsuite.d.ts +37 -0
  39. package/dist/lib/returnpro/upload-netsuite.js +566 -0
  40. package/dist/lib/returnpro/upload-r1.d.ts +48 -0
  41. package/dist/lib/returnpro/upload-r1.js +398 -0
  42. package/dist/lib/social/post-generator.d.ts +83 -0
  43. package/dist/lib/social/post-generator.js +333 -0
  44. package/dist/lib/social/publish.d.ts +66 -0
  45. package/dist/lib/social/publish.js +226 -0
  46. package/dist/lib/social/scraper.d.ts +67 -0
  47. package/dist/lib/social/scraper.js +361 -0
  48. package/dist/lib/supabase.d.ts +4 -0
  49. package/dist/lib/supabase.js +20 -0
  50. package/dist/lib/transactions/delete-batch.d.ts +60 -0
  51. package/dist/lib/transactions/delete-batch.js +203 -0
  52. package/dist/lib/transactions/ingest.d.ts +43 -0
  53. package/dist/lib/transactions/ingest.js +555 -0
  54. package/dist/lib/transactions/stamp.d.ts +51 -0
  55. package/dist/lib/transactions/stamp.js +524 -0
  56. package/package.json +50 -0
package/README.md ADDED
@@ -0,0 +1,175 @@
1
+ # Optimal CLI
2
+
3
+ Unified command-line interface for agent config sync, financial analytics, content management, and infrastructure.
4
+
5
+ [![npm version](https://img.shields.io/npm/v/@clenisa/optimal-cli.svg)](https://www.npmjs.com/package/@clenisa/optimal-cli)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
7
+
8
+ ## Installation
9
+
10
+ ```bash
11
+ # Install globally
12
+ npm install -g @clenisa/optimal-cli
13
+
14
+ # Or use with npx (no install)
15
+ npx @clenisa/optimal-cli <command>
16
+ ```
17
+
18
+ ## Quick Start
19
+
20
+ 1. **Set up environment variables** in `~/.optimal/.env`:
21
+ ```bash
22
+ # OptimalOS Supabase (for config sync, kanban)
23
+ OPTIMAL_SUPABASE_URL=https://hbfalrpswysryltysonm.supabase.co
24
+ OPTIMAL_SUPABASE_SERVICE_KEY=your_service_key
25
+
26
+ # ReturnPro Supabase (for financial data)
27
+ RETURNPRO_SUPABASE_URL=https://vvutttwunexshxkmygik.supabase.co
28
+ RETURNPRO_SUPABASE_SERVICE_KEY=your_service_key
29
+
30
+ # Strapi CMS
31
+ STRAPI_URL=https://strapi.op-hub.com
32
+ STRAPI_API_TOKEN=your_token
33
+
34
+ # AI Provider
35
+ OPENAI_API_KEY=your_key
36
+ ```
37
+
38
+ 2. **Authenticate** (required for config sync):
39
+ ```bash
40
+ optimal auth login
41
+ ```
42
+
43
+ 3. **Sync your agent config**:
44
+ ```bash
45
+ optimal config push --agent kimklaw
46
+ ```
47
+
48
+ ## Commands
49
+
50
+ ### Config Sync (Agent Management)
51
+
52
+ Synchronize OpenClaw configurations across multiple agents.
53
+
54
+ | Command | Description |
55
+ |---------|-------------|
56
+ | `optimal config push --agent <name>` | Push local `~/.openclaw/openclaw.json` to cloud |
57
+ | `optimal config pull --agent <name>` | Pull config from cloud to local |
58
+ | `optimal config list` | List all saved agent configs |
59
+ | `optimal config diff --agent <name>` | Compare local vs cloud config |
60
+ | `optimal config sync --agent <name>` | Two-way sync (newer wins) |
61
+
62
+ **Example workflow:**
63
+ ```bash
64
+ # Push Oracle's config
65
+ optimal config push --agent oracle
66
+
67
+ # Pull it on another machine
68
+ optimal config pull --agent oracle
69
+
70
+ # Auto-sync (detects which is newer)
71
+ optimal config sync --agent oracle
72
+ ```
73
+
74
+ ### Kanban Board
75
+
76
+ Manage tasks across agents.
77
+
78
+ | Command | Description |
79
+ |---------|-------------|
80
+ | `optimal board view` | Display kanban board |
81
+ | `optimal board create --title "Task name"` | Create new task |
82
+ | `optimal board update --id <uuid> --status done` | Update task status |
83
+
84
+ ### Financial Analytics (ReturnPro)
85
+
86
+ | Command | Description |
87
+ |---------|-------------|
88
+ | `optimal audit-financials` | Compare staged vs confirmed financials |
89
+ | `optimal export-kpis --format csv` | Export KPI data |
90
+ | `optimal project-budget --adjustment-value 4` | Run budget projections |
91
+ | `optimal rate-anomalies` | Detect rate anomalies |
92
+ | `optimal upload-r1 --file data.xlsx --month 2025-01` | Upload R1 data |
93
+
94
+ ### Content Management (Strapi CMS)
95
+
96
+ | Command | Description |
97
+ |---------|-------------|
98
+ | `optimal generate-newsletter --brand CRE-11TRUST` | Generate newsletter |
99
+ | `optimal distribute-newsletter --document-id <id>` | Send newsletter |
100
+ | `optimal generate-social-posts --brand LIFEINSUR` | Generate social posts |
101
+ | `optimal publish-social-posts --brand CRE-11TRUST` | Publish to platforms |
102
+ | `optimal blog-drafts` | List unpublished blogs |
103
+ | `optimal publish-blog --slug my-post` | Publish blog post |
104
+
105
+ ### Infrastructure
106
+
107
+ | Command | Description |
108
+ |---------|-------------|
109
+ | `optimal deploy <app> --prod` | Deploy to Vercel |
110
+ | `optimal health-check` | Check all services |
111
+ | `optimal migrate push --target optimalos` | Run DB migrations |
112
+
113
+ ## Authentication
114
+
115
+ All config sync operations require Supabase authentication. The CLI uses your service role key for server-side operations.
116
+
117
+ **To get your credentials:**
118
+ 1. Go to [Supabase Dashboard](https://supabase.com/dashboard)
119
+ 2. Select your project
120
+ 3. Settings → API → Copy "service_role key"
121
+
122
+ ## Environment Variables
123
+
124
+ | Variable | Required | Description |
125
+ |----------|----------|-------------|
126
+ | `OPTIMAL_SUPABASE_URL` | ✅ | OptimalOS Supabase URL |
127
+ | `OPTIMAL_SUPABASE_SERVICE_KEY` | ✅ | OptimalOS service role key |
128
+ | `RETURNPRO_SUPABASE_URL` | For financial commands | ReturnPro Supabase URL |
129
+ | `RETURNPRO_SUPABASE_SERVICE_KEY` | For financial commands | ReturnPro service key |
130
+ | `STRAPI_URL` | For CMS commands | Strapi CMS URL |
131
+ | `STRAPI_API_TOKEN` | For CMS commands | Strapi API token |
132
+ | `OPENAI_API_KEY` | For AI commands | OpenAI API key |
133
+
134
+ ## Multi-Agent Sync Workflow
135
+
136
+ 1. **Oracle (primary)** makes config changes:
137
+ ```bash
138
+ optimal config push --agent oracle
139
+ ```
140
+
141
+ 2. **Opal** pulls latest config:
142
+ ```bash
143
+ optimal config pull --agent oracle
144
+ # or
145
+ optimal config sync --agent oracle
146
+ ```
147
+
148
+ 3. **Kimklaw** verifies sync:
149
+ ```bash
150
+ optimal config diff --agent oracle
151
+ ```
152
+
153
+ ## Development
154
+
155
+ ```bash
156
+ # Clone repo
157
+ git clone https://github.com/clenisa/optimal-cli.git
158
+ cd optimal-cli
159
+
160
+ # Install dependencies
161
+ pnpm install
162
+
163
+ # Run in dev mode
164
+ pnpm dev
165
+
166
+ # Build
167
+ pnpm build
168
+
169
+ # Lint
170
+ pnpm lint
171
+ ```
172
+
173
+ ## License
174
+
175
+ MIT © Carlos Lenis
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env tsx
2
+ import 'dotenv/config';