optimal-cli 0.1.0 → 1.0.1
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.
- package/agents/.gitkeep +0 -0
- package/agents/content-ops.md +227 -0
- package/agents/financial-ops.md +184 -0
- package/agents/infra-ops.md +206 -0
- package/agents/profiles.json +5 -0
- package/dist/bin/optimal.d.ts +1 -1
- package/dist/bin/optimal.js +706 -111
- package/dist/lib/assets/index.d.ts +79 -0
- package/dist/lib/assets/index.js +153 -0
- package/dist/lib/assets.d.ts +20 -0
- package/dist/lib/assets.js +112 -0
- package/dist/lib/auth/index.d.ts +83 -0
- package/dist/lib/auth/index.js +146 -0
- package/dist/lib/board/index.d.ts +39 -0
- package/dist/lib/board/index.js +285 -0
- package/dist/lib/board/types.d.ts +111 -0
- package/dist/lib/board/types.js +1 -0
- package/dist/lib/bot/claim.d.ts +3 -0
- package/dist/lib/bot/claim.js +20 -0
- package/dist/lib/bot/coordinator.d.ts +27 -0
- package/dist/lib/bot/coordinator.js +178 -0
- package/dist/lib/bot/heartbeat.d.ts +6 -0
- package/dist/lib/bot/heartbeat.js +30 -0
- package/dist/lib/bot/index.d.ts +9 -0
- package/dist/lib/bot/index.js +6 -0
- package/dist/lib/bot/protocol.d.ts +12 -0
- package/dist/lib/bot/protocol.js +74 -0
- package/dist/lib/bot/reporter.d.ts +3 -0
- package/dist/lib/bot/reporter.js +27 -0
- package/dist/lib/bot/skills.d.ts +26 -0
- package/dist/lib/bot/skills.js +69 -0
- package/dist/lib/config/registry.d.ts +17 -0
- package/dist/lib/config/registry.js +182 -0
- package/dist/lib/config/schema.d.ts +31 -0
- package/dist/lib/config/schema.js +25 -0
- package/dist/lib/errors.d.ts +25 -0
- package/dist/lib/errors.js +91 -0
- package/dist/lib/format.d.ts +28 -0
- package/dist/lib/format.js +98 -0
- package/dist/lib/returnpro/validate.d.ts +37 -0
- package/dist/lib/returnpro/validate.js +124 -0
- package/dist/lib/social/meta.d.ts +90 -0
- package/dist/lib/social/meta.js +160 -0
- package/docs/CLI-REFERENCE.md +361 -0
- package/package.json +13 -24
- package/dist/lib/kanban.d.ts +0 -46
- package/dist/lib/kanban.js +0 -118
|
@@ -0,0 +1,361 @@
|
|
|
1
|
+
# optimal-cli Command Reference
|
|
2
|
+
|
|
3
|
+
> 51 commands across 9 command groups + 12 standalone commands
|
|
4
|
+
|
|
5
|
+
## Quick Start
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
# Run any command
|
|
9
|
+
npx tsx bin/optimal.ts <command> [options]
|
|
10
|
+
|
|
11
|
+
# Or alias it
|
|
12
|
+
alias optimal="npx tsx bin/optimal.ts"
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Environment Variables
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
# Required for board/bot/project/asset commands (OptimalOS Supabase)
|
|
19
|
+
OPTIMAL_SUPABASE_URL=https://hbfalrpswysryltysonm.supabase.co
|
|
20
|
+
OPTIMAL_SUPABASE_SERVICE_KEY=<service_role_key>
|
|
21
|
+
|
|
22
|
+
# Required for financial commands (ReturnPro Supabase)
|
|
23
|
+
RETURNPRO_SUPABASE_URL=https://vvutttwunexshxkmygik.supabase.co
|
|
24
|
+
RETURNPRO_SUPABASE_SERVICE_KEY=<service_role_key>
|
|
25
|
+
|
|
26
|
+
# Required for content commands
|
|
27
|
+
STRAPI_URL=https://strapi.op-hub.com
|
|
28
|
+
STRAPI_API_TOKEN=<token>
|
|
29
|
+
GROQ_API_KEY=<key>
|
|
30
|
+
GROQ_MODEL=llama-3.3-70b-versatile
|
|
31
|
+
|
|
32
|
+
# Required for Instagram publishing
|
|
33
|
+
META_ACCESS_TOKEN=<meta_graph_api_token>
|
|
34
|
+
META_IG_ACCOUNT_ID_CRE_11TRUST=<ig_account_id>
|
|
35
|
+
META_IG_ACCOUNT_ID_LIFEINSUR=<ig_account_id>
|
|
36
|
+
|
|
37
|
+
# Optional
|
|
38
|
+
NEWSAPI_KEY=<key>
|
|
39
|
+
NO_COLOR=1 # Disable colored output
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## Board Commands (Kanban)
|
|
45
|
+
|
|
46
|
+
Manage the task kanban board. All tasks live in Supabase.
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
# View the full board
|
|
50
|
+
optimal board view
|
|
51
|
+
|
|
52
|
+
# Filter by status, project, or agent
|
|
53
|
+
optimal board view -s ready
|
|
54
|
+
optimal board view -s in_progress
|
|
55
|
+
optimal board view -p cli-consolidation
|
|
56
|
+
optimal board view --mine bot1
|
|
57
|
+
|
|
58
|
+
# Create a task
|
|
59
|
+
optimal board create \
|
|
60
|
+
-t "Fix login bug" \
|
|
61
|
+
-p cli-consolidation \
|
|
62
|
+
--priority 1 \
|
|
63
|
+
--effort m \
|
|
64
|
+
--skill "auth"
|
|
65
|
+
|
|
66
|
+
# Update a task
|
|
67
|
+
optimal board update --id <uuid> --status in_progress
|
|
68
|
+
optimal board update --id <uuid> --priority 2
|
|
69
|
+
|
|
70
|
+
# Claim a task (bot pull model)
|
|
71
|
+
optimal board claim --id <uuid> --agent bot1
|
|
72
|
+
|
|
73
|
+
# Comment on a task
|
|
74
|
+
optimal board comment --id <uuid> --author bot1 --body "Working on it"
|
|
75
|
+
|
|
76
|
+
# View activity log
|
|
77
|
+
optimal board log
|
|
78
|
+
optimal board log --actor bot1 --limit 10
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
**Statuses:** `backlog` > `ready` > `claimed` > `in_progress` > `review` > `done` | `blocked`
|
|
82
|
+
|
|
83
|
+
**Priorities:** P1 (Critical), P2 (High), P3 (Medium), P4 (Low)
|
|
84
|
+
|
|
85
|
+
**Effort sizes:** xs, s, m, l, xl
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
## Bot Commands (Agent Orchestration)
|
|
90
|
+
|
|
91
|
+
Manage bot agents that claim and work tasks from the board.
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
# Send heartbeat (proves agent is alive)
|
|
95
|
+
optimal bot heartbeat --agent bot1
|
|
96
|
+
optimal bot heartbeat --agent bot1 --status working
|
|
97
|
+
|
|
98
|
+
# List active agents (heartbeat in last 5 min)
|
|
99
|
+
optimal bot agents
|
|
100
|
+
|
|
101
|
+
# Claim the next available task (auto-selects highest priority)
|
|
102
|
+
optimal bot claim --agent bot1
|
|
103
|
+
optimal bot claim --agent bot1 --skill generate-social-posts
|
|
104
|
+
|
|
105
|
+
# Report progress
|
|
106
|
+
optimal bot report --task <uuid> --agent bot1 --message "50% complete"
|
|
107
|
+
|
|
108
|
+
# Mark task done
|
|
109
|
+
optimal bot complete --task <uuid> --agent bot1 --summary "All tests pass"
|
|
110
|
+
|
|
111
|
+
# Release a task back to ready
|
|
112
|
+
optimal bot release --task <uuid> --agent bot1
|
|
113
|
+
optimal bot release --task <uuid> --agent bot1 --reason "Need more context"
|
|
114
|
+
|
|
115
|
+
# Mark task blocked
|
|
116
|
+
optimal bot blocked --task <uuid> --agent bot1 --reason "Waiting on API key"
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
## Project Commands
|
|
122
|
+
|
|
123
|
+
Manage project groupings that tasks belong to.
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
optimal project list
|
|
127
|
+
|
|
128
|
+
optimal project create \
|
|
129
|
+
--slug my-project \
|
|
130
|
+
--name "My Project" \
|
|
131
|
+
--priority 1 \
|
|
132
|
+
--owner clenisa
|
|
133
|
+
|
|
134
|
+
optimal project update --slug my-project -s completed
|
|
135
|
+
optimal project update --slug my-project --priority 2
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
---
|
|
139
|
+
|
|
140
|
+
## Asset Commands (Digital Asset Tracking)
|
|
141
|
+
|
|
142
|
+
Track domains, servers, API keys, services, and repos.
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
# List all assets
|
|
146
|
+
optimal asset list
|
|
147
|
+
optimal asset list --type domain --status active
|
|
148
|
+
|
|
149
|
+
# Add an asset
|
|
150
|
+
optimal asset add \
|
|
151
|
+
--name "op-hub.com" \
|
|
152
|
+
--type domain \
|
|
153
|
+
--owner clenisa \
|
|
154
|
+
--expires "2027-01-15"
|
|
155
|
+
|
|
156
|
+
# Update asset
|
|
157
|
+
optimal asset update --id <uuid> --status inactive
|
|
158
|
+
|
|
159
|
+
# Get single asset
|
|
160
|
+
optimal asset get --id <uuid>
|
|
161
|
+
|
|
162
|
+
# Remove asset
|
|
163
|
+
optimal asset remove --id <uuid>
|
|
164
|
+
|
|
165
|
+
# Track usage event
|
|
166
|
+
optimal asset track --id <uuid> --event "SSL renewed" --actor clenisa
|
|
167
|
+
|
|
168
|
+
# View usage log
|
|
169
|
+
optimal asset usage --id <uuid>
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
**Asset types:** domain, server, api_key, service, repo
|
|
173
|
+
|
|
174
|
+
---
|
|
175
|
+
|
|
176
|
+
## Financial Commands (ReturnPro)
|
|
177
|
+
|
|
178
|
+
All financial data flows through the ReturnPro Supabase instance.
|
|
179
|
+
|
|
180
|
+
```bash
|
|
181
|
+
# Upload financial data
|
|
182
|
+
optimal upload-netsuite --file data.csv --period 2025-06
|
|
183
|
+
optimal upload-r1 --file r1-export.xlsx --period 2025-06
|
|
184
|
+
optimal upload-income-statements --file confirmed.csv
|
|
185
|
+
|
|
186
|
+
# Audit & diagnostics
|
|
187
|
+
optimal audit-financials --months 2025-01,2025-02
|
|
188
|
+
optimal diagnose-months --months 2025-03
|
|
189
|
+
optimal rate-anomalies --client "Acme Corp" --period 2025-06
|
|
190
|
+
|
|
191
|
+
# KPIs
|
|
192
|
+
optimal export-kpis --format table
|
|
193
|
+
optimal export-kpis --format csv > kpis.csv
|
|
194
|
+
|
|
195
|
+
# Budget projections
|
|
196
|
+
optimal project-budget --adjustment-type percentage --adjustment-value 4
|
|
197
|
+
optimal export-budget --format csv > budget.csv
|
|
198
|
+
|
|
199
|
+
# Batch delete (dry-run by default)
|
|
200
|
+
optimal delete-batch --table stg_financials_raw --client "Test Corp"
|
|
201
|
+
optimal delete-batch --table stg_financials_raw --client "Test Corp" --execute
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
---
|
|
205
|
+
|
|
206
|
+
## Budget Scenario Commands
|
|
207
|
+
|
|
208
|
+
Save, compare, and manage budget projection scenarios.
|
|
209
|
+
|
|
210
|
+
```bash
|
|
211
|
+
optimal scenario list
|
|
212
|
+
|
|
213
|
+
optimal scenario save \
|
|
214
|
+
--name "4pct-growth" \
|
|
215
|
+
--adjustment-type percentage \
|
|
216
|
+
--adjustment-value 4
|
|
217
|
+
|
|
218
|
+
optimal scenario compare --names "baseline,4pct-growth"
|
|
219
|
+
|
|
220
|
+
optimal scenario delete --name "old-scenario"
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
---
|
|
224
|
+
|
|
225
|
+
## Content Commands (Newsletter, Social, Blog)
|
|
226
|
+
|
|
227
|
+
Generate and publish content across channels.
|
|
228
|
+
|
|
229
|
+
```bash
|
|
230
|
+
# Generate newsletter (AI-powered via Groq)
|
|
231
|
+
optimal generate-newsletter --brand CRE-11TRUST
|
|
232
|
+
optimal generate-newsletter --brand LIFEINSUR
|
|
233
|
+
|
|
234
|
+
# Distribute newsletter
|
|
235
|
+
optimal distribute-newsletter --newsletter-id 42
|
|
236
|
+
optimal distribution-status --newsletter-id 42
|
|
237
|
+
|
|
238
|
+
# Generate social posts (AI-powered)
|
|
239
|
+
optimal generate-social-posts --brand CRE-11TRUST --count 5
|
|
240
|
+
|
|
241
|
+
# View social queue
|
|
242
|
+
optimal social-queue --brand CRE-11TRUST
|
|
243
|
+
|
|
244
|
+
# Publish social posts (via n8n)
|
|
245
|
+
optimal publish-social-posts --brand CRE-11TRUST
|
|
246
|
+
|
|
247
|
+
# Publish to Instagram (direct Meta Graph API)
|
|
248
|
+
optimal publish-instagram --brand CRE-11TRUST
|
|
249
|
+
optimal publish-instagram --brand CRE-11TRUST --dry-run
|
|
250
|
+
optimal publish-instagram --brand LIFEINSUR --limit 3
|
|
251
|
+
|
|
252
|
+
# Scrape competitor ads
|
|
253
|
+
optimal scrape-ads --brand CRE-11TRUST
|
|
254
|
+
|
|
255
|
+
# Blog
|
|
256
|
+
optimal blog-drafts --brand CRE-11TRUST
|
|
257
|
+
optimal publish-blog --id 15
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
**Brands:** `CRE-11TRUST` (ElevenTrust, commercial real estate), `LIFEINSUR` (AnchorPoint, insurance)
|
|
261
|
+
|
|
262
|
+
---
|
|
263
|
+
|
|
264
|
+
## Config Commands
|
|
265
|
+
|
|
266
|
+
Manage local CLI configuration.
|
|
267
|
+
|
|
268
|
+
```bash
|
|
269
|
+
optimal config init --owner oracle --brand CRE-11TRUST
|
|
270
|
+
optimal config doctor # Validate config
|
|
271
|
+
optimal config export --out ./backup.json
|
|
272
|
+
optimal config import --in ./backup.json
|
|
273
|
+
optimal config sync # Sync with shared registry
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
---
|
|
277
|
+
|
|
278
|
+
## Infrastructure Commands
|
|
279
|
+
|
|
280
|
+
```bash
|
|
281
|
+
# Deploy apps to Vercel
|
|
282
|
+
optimal deploy dashboard --prod
|
|
283
|
+
optimal deploy board # Preview deployment
|
|
284
|
+
|
|
285
|
+
# Database migrations
|
|
286
|
+
optimal migrate pending --target optimalos
|
|
287
|
+
optimal migrate push --target returnpro --dry-run
|
|
288
|
+
optimal migrate push --target optimalos
|
|
289
|
+
optimal migrate create --target optimalos --name "add-index"
|
|
290
|
+
|
|
291
|
+
# Health check
|
|
292
|
+
optimal health-check
|
|
293
|
+
|
|
294
|
+
# Generate upload templates
|
|
295
|
+
optimal generate-netsuite-template --output template.xlsx
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
---
|
|
299
|
+
|
|
300
|
+
## Milestone & Label Commands
|
|
301
|
+
|
|
302
|
+
```bash
|
|
303
|
+
# Milestones
|
|
304
|
+
optimal milestone create --project <uuid> --name "v1.0" --due 2026-04-01
|
|
305
|
+
optimal milestone list
|
|
306
|
+
optimal milestone list --project <uuid>
|
|
307
|
+
|
|
308
|
+
# Labels
|
|
309
|
+
optimal label create --name "migration" --color "#3B82F6"
|
|
310
|
+
optimal label list
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
---
|
|
314
|
+
|
|
315
|
+
## Architecture Overview
|
|
316
|
+
|
|
317
|
+
```
|
|
318
|
+
optimal-cli/
|
|
319
|
+
bin/optimal.ts CLI entry point (Commander.js)
|
|
320
|
+
lib/ Implementation modules
|
|
321
|
+
auth/ Auth primitives (session, service client)
|
|
322
|
+
assets/ Asset tracking CRUD
|
|
323
|
+
board/ Kanban board CRUD + formatting
|
|
324
|
+
bot/ Bot orchestration (heartbeat, claim, report, skills, coordinator)
|
|
325
|
+
budget/ Budget projections + scenarios
|
|
326
|
+
cms/ Strapi client + blog publishing
|
|
327
|
+
config/ Config registry + schema
|
|
328
|
+
format.ts ANSI colors, tables, badges
|
|
329
|
+
infra/ Deploy + migrate
|
|
330
|
+
newsletter/ Newsletter generation + distribution
|
|
331
|
+
returnpro/ Financial uploads, audit, KPIs, anomalies, validation
|
|
332
|
+
social/ Social post generation, publishing, scraping, Meta API
|
|
333
|
+
supabase.ts Supabase client factory (dual-instance)
|
|
334
|
+
transactions/ Transaction ingestion, stamping, batch delete
|
|
335
|
+
apps/ Read-only Next.js dashboards
|
|
336
|
+
board/ Kanban board (deployed: optimal-board.vercel.app)
|
|
337
|
+
newsletter-preview/ Newsletter HTML preview
|
|
338
|
+
returnpro-dashboard/ ReturnPro financial overview
|
|
339
|
+
wes-dashboard/ Budget dashboard
|
|
340
|
+
activity/ Agent activity timeline
|
|
341
|
+
portfolio/ Portfolio site stub
|
|
342
|
+
agents/profiles.json Bot agent definitions
|
|
343
|
+
scripts/ Seed scripts
|
|
344
|
+
skills/ Agent-facing skill definitions (.md)
|
|
345
|
+
supabase/migrations/ SQL migration files
|
|
346
|
+
tests/ Test suite (node:test)
|
|
347
|
+
docs/ Plans, specs, API docs
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
## Supabase Instances
|
|
351
|
+
|
|
352
|
+
| Instance | Ref | Tables | Used By |
|
|
353
|
+
|----------|-----|--------|---------|
|
|
354
|
+
| OptimalOS | hbfalrpswysryltysonm | projects, tasks, milestones, labels, comments, activity_log, task_labels | board, bot, project, asset commands |
|
|
355
|
+
| ReturnPro | vvutttwunexshxkmygik | stg_financials_raw, confirmed_income_statements, dim_account, dim_client, dim_master_program, dim_program_id | financial, budget, KPI commands |
|
|
356
|
+
|
|
357
|
+
## Dashboard URLs
|
|
358
|
+
|
|
359
|
+
| Dashboard | URL | What It Shows |
|
|
360
|
+
|-----------|-----|---------------|
|
|
361
|
+
| Kanban Board | https://optimal-board.vercel.app | Task board, project progress, activity feed |
|
package/package.json
CHANGED
|
@@ -1,39 +1,28 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "optimal-cli",
|
|
3
|
-
"version": "0.1
|
|
4
|
-
"description": "Optimal CLI — unified command-line interface for
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "Optimal CLI — unified command-line interface for bot orchestration, financial analytics, content management, and infrastructure",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"main": "./dist/bin/optimal.js",
|
|
7
6
|
"bin": {
|
|
8
7
|
"optimal": "./dist/bin/optimal.js"
|
|
9
8
|
},
|
|
10
9
|
"files": [
|
|
11
|
-
"dist
|
|
12
|
-
"
|
|
13
|
-
"
|
|
10
|
+
"dist/",
|
|
11
|
+
"agents/",
|
|
12
|
+
"docs/CLI-REFERENCE.md"
|
|
14
13
|
],
|
|
15
|
-
"
|
|
16
|
-
|
|
17
|
-
"dev": "tsx watch bin/optimal.ts",
|
|
18
|
-
"lint": "tsc --noEmit",
|
|
19
|
-
"prepublishOnly": "pnpm build"
|
|
20
|
-
},
|
|
21
|
-
"keywords": [
|
|
22
|
-
"cli",
|
|
23
|
-
"optimal",
|
|
24
|
-
"openclaw",
|
|
25
|
-
"supabase",
|
|
26
|
-
"agent-config",
|
|
27
|
-
"automation"
|
|
28
|
-
],
|
|
29
|
-
"author": "Carlos Lenis <clenis@optimaltech.ai>",
|
|
14
|
+
"keywords": ["cli", "supabase", "kanban", "bot-orchestration", "financial-analytics"],
|
|
15
|
+
"author": "Carlos Lenis <clenis@users.noreply.github.com>",
|
|
30
16
|
"license": "MIT",
|
|
31
17
|
"repository": {
|
|
32
18
|
"type": "git",
|
|
33
|
-
"url": "
|
|
19
|
+
"url": "https://github.com/clenisa/optimal-cli.git"
|
|
34
20
|
},
|
|
35
|
-
"
|
|
36
|
-
"
|
|
21
|
+
"scripts": {
|
|
22
|
+
"build": "tsc",
|
|
23
|
+
"dev": "tsx watch bin/optimal.ts",
|
|
24
|
+
"lint": "tsc --noEmit",
|
|
25
|
+
"test": "tsx --test tests/*.test.ts"
|
|
37
26
|
},
|
|
38
27
|
"devDependencies": {
|
|
39
28
|
"@types/node": "^22.0.0",
|
package/dist/lib/kanban.d.ts
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
export interface CliTask {
|
|
2
|
-
id: string;
|
|
3
|
-
project_id: string;
|
|
4
|
-
parent_id: string | null;
|
|
5
|
-
title: string;
|
|
6
|
-
description: string | null;
|
|
7
|
-
status: 'backlog' | 'ready' | 'in_progress' | 'blocked' | 'review' | 'done' | 'canceled';
|
|
8
|
-
priority: 1 | 2 | 3 | 4;
|
|
9
|
-
assigned_agent: string | null;
|
|
10
|
-
skill_ref: string | null;
|
|
11
|
-
source_repo: string | null;
|
|
12
|
-
blocked_by: string[] | null;
|
|
13
|
-
labels: string[];
|
|
14
|
-
metadata: Record<string, unknown>;
|
|
15
|
-
started_at: string | null;
|
|
16
|
-
completed_at: string | null;
|
|
17
|
-
created_at: string;
|
|
18
|
-
updated_at: string;
|
|
19
|
-
}
|
|
20
|
-
export interface CreateTaskInput {
|
|
21
|
-
project_slug: string;
|
|
22
|
-
title: string;
|
|
23
|
-
description?: string;
|
|
24
|
-
priority?: 1 | 2 | 3 | 4;
|
|
25
|
-
skill_ref?: string;
|
|
26
|
-
source_repo?: string;
|
|
27
|
-
labels?: string[];
|
|
28
|
-
parent_id?: string;
|
|
29
|
-
blocked_by?: string[];
|
|
30
|
-
}
|
|
31
|
-
export declare function getProjectBySlug(slug: string): Promise<any>;
|
|
32
|
-
export declare function createTask(input: CreateTaskInput): Promise<CliTask>;
|
|
33
|
-
export declare function updateTask(taskId: string, updates: Partial<Pick<CliTask, 'status' | 'assigned_agent' | 'priority' | 'metadata' | 'labels'>>): Promise<CliTask>;
|
|
34
|
-
export declare function getNextTask(projectSlug: string, agentName: string): Promise<CliTask | null>;
|
|
35
|
-
export declare function getBoard(projectSlug: string): Promise<CliTask[]>;
|
|
36
|
-
export declare function logActivity(taskId: string, entry: {
|
|
37
|
-
agent: string;
|
|
38
|
-
action: string;
|
|
39
|
-
message?: string;
|
|
40
|
-
metadata?: Record<string, unknown>;
|
|
41
|
-
}): Promise<void>;
|
|
42
|
-
export declare function logSkillExecution(skillName: string, agent: string, result: {
|
|
43
|
-
success: boolean;
|
|
44
|
-
message: string;
|
|
45
|
-
metadata?: Record<string, unknown>;
|
|
46
|
-
}): Promise<void>;
|
package/dist/lib/kanban.js
DELETED
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
import { getSupabase } from './supabase.js';
|
|
2
|
-
const sb = () => getSupabase('optimal');
|
|
3
|
-
// --- Projects ---
|
|
4
|
-
export async function getProjectBySlug(slug) {
|
|
5
|
-
const { data, error } = await sb()
|
|
6
|
-
.from('cli_projects')
|
|
7
|
-
.select('*')
|
|
8
|
-
.eq('slug', slug)
|
|
9
|
-
.single();
|
|
10
|
-
if (error)
|
|
11
|
-
throw new Error(`Project not found: ${slug} — ${error.message}`);
|
|
12
|
-
return data;
|
|
13
|
-
}
|
|
14
|
-
// --- Tasks ---
|
|
15
|
-
export async function createTask(input) {
|
|
16
|
-
const project = await getProjectBySlug(input.project_slug);
|
|
17
|
-
const { data, error } = await sb()
|
|
18
|
-
.from('cli_tasks')
|
|
19
|
-
.insert({
|
|
20
|
-
project_id: project.id,
|
|
21
|
-
title: input.title,
|
|
22
|
-
description: input.description ?? null,
|
|
23
|
-
priority: input.priority ?? 3,
|
|
24
|
-
skill_ref: input.skill_ref ?? null,
|
|
25
|
-
source_repo: input.source_repo ?? null,
|
|
26
|
-
labels: input.labels ?? [],
|
|
27
|
-
parent_id: input.parent_id ?? null,
|
|
28
|
-
blocked_by: input.blocked_by ?? null,
|
|
29
|
-
})
|
|
30
|
-
.select()
|
|
31
|
-
.single();
|
|
32
|
-
if (error)
|
|
33
|
-
throw new Error(`Failed to create task: ${error.message}`);
|
|
34
|
-
return data;
|
|
35
|
-
}
|
|
36
|
-
export async function updateTask(taskId, updates) {
|
|
37
|
-
const { data, error } = await sb()
|
|
38
|
-
.from('cli_tasks')
|
|
39
|
-
.update(updates)
|
|
40
|
-
.eq('id', taskId)
|
|
41
|
-
.select()
|
|
42
|
-
.single();
|
|
43
|
-
if (error)
|
|
44
|
-
throw new Error(`Failed to update task ${taskId}: ${error.message}`);
|
|
45
|
-
return data;
|
|
46
|
-
}
|
|
47
|
-
export async function getNextTask(projectSlug, agentName) {
|
|
48
|
-
const project = await getProjectBySlug(projectSlug);
|
|
49
|
-
const { data, error } = await sb()
|
|
50
|
-
.from('cli_tasks')
|
|
51
|
-
.select('*')
|
|
52
|
-
.eq('project_id', project.id)
|
|
53
|
-
.in('status', ['ready', 'backlog'])
|
|
54
|
-
.is('assigned_agent', null)
|
|
55
|
-
.order('priority', { ascending: true })
|
|
56
|
-
.order('created_at', { ascending: true })
|
|
57
|
-
.limit(10);
|
|
58
|
-
if (error)
|
|
59
|
-
throw new Error(`Failed to fetch tasks: ${error.message}`);
|
|
60
|
-
if (!data || data.length === 0)
|
|
61
|
-
return null;
|
|
62
|
-
for (const task of data) {
|
|
63
|
-
if (!task.blocked_by || task.blocked_by.length === 0)
|
|
64
|
-
return task;
|
|
65
|
-
const { data: blockers } = await sb()
|
|
66
|
-
.from('cli_tasks')
|
|
67
|
-
.select('id, status')
|
|
68
|
-
.in('id', task.blocked_by);
|
|
69
|
-
const allDone = blockers?.every(b => b.status === 'done' || b.status === 'canceled');
|
|
70
|
-
if (allDone)
|
|
71
|
-
return task;
|
|
72
|
-
}
|
|
73
|
-
return null;
|
|
74
|
-
}
|
|
75
|
-
export async function getBoard(projectSlug) {
|
|
76
|
-
const project = await getProjectBySlug(projectSlug);
|
|
77
|
-
const { data, error } = await sb()
|
|
78
|
-
.from('cli_tasks')
|
|
79
|
-
.select('*')
|
|
80
|
-
.eq('project_id', project.id)
|
|
81
|
-
.not('status', 'eq', 'canceled')
|
|
82
|
-
.order('priority', { ascending: true })
|
|
83
|
-
.order('created_at', { ascending: true });
|
|
84
|
-
if (error)
|
|
85
|
-
throw new Error(`Failed to fetch board: ${error.message}`);
|
|
86
|
-
return (data ?? []);
|
|
87
|
-
}
|
|
88
|
-
// --- Logging ---
|
|
89
|
-
export async function logActivity(taskId, entry) {
|
|
90
|
-
const { error } = await sb()
|
|
91
|
-
.from('cli_task_logs')
|
|
92
|
-
.insert({
|
|
93
|
-
task_id: taskId,
|
|
94
|
-
agent: entry.agent,
|
|
95
|
-
action: entry.action,
|
|
96
|
-
message: entry.message ?? null,
|
|
97
|
-
metadata: entry.metadata ?? {},
|
|
98
|
-
});
|
|
99
|
-
if (error)
|
|
100
|
-
throw new Error(`Failed to log activity: ${error.message}`);
|
|
101
|
-
}
|
|
102
|
-
export async function logSkillExecution(skillName, agent, result) {
|
|
103
|
-
const { data: tasks } = await sb()
|
|
104
|
-
.from('cli_tasks')
|
|
105
|
-
.select('id')
|
|
106
|
-
.eq('skill_ref', skillName)
|
|
107
|
-
.eq('status', 'in_progress')
|
|
108
|
-
.limit(1);
|
|
109
|
-
const taskId = tasks?.[0]?.id;
|
|
110
|
-
if (taskId) {
|
|
111
|
-
await logActivity(taskId, {
|
|
112
|
-
agent,
|
|
113
|
-
action: result.success ? 'skill_success' : 'skill_error',
|
|
114
|
-
message: result.message,
|
|
115
|
-
metadata: result.metadata,
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
}
|