@dawnai/cli 1.0.5 → 1.0.7
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/dist/index.js +48 -22
- package/package.json +2 -1
- package/postinstall.js +46 -1
- package/public/SKILLS.md +169 -0
- package/skills/dawn-account/SKILL.md +13 -2
- package/skills/dawn-auth/SKILL.md +2 -1
package/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import path from 'node:path';
|
|
|
6
6
|
import process from 'node:process';
|
|
7
7
|
import { spawn } from 'node:child_process';
|
|
8
8
|
import { fileURLToPath } from 'node:url';
|
|
9
|
-
const CLI_VERSION = '1.0.
|
|
9
|
+
const CLI_VERSION = '1.0.7';
|
|
10
10
|
const DAWN_API_BASE_URL = 'https://api.dawn.ai';
|
|
11
11
|
const FUNDING_LINK_TEMPLATE = process.env.DAWN_HELIO_LINK_TEMPLATE || '';
|
|
12
12
|
const CLI_HOME = process.env.DAWN_CLI_HOME || path.join(os.homedir(), '.dawn-cli');
|
|
@@ -16,6 +16,11 @@ function getBundledSkillsDir() {
|
|
|
16
16
|
const currentDir = path.dirname(currentFilePath);
|
|
17
17
|
return path.join(currentDir, '..', 'skills');
|
|
18
18
|
}
|
|
19
|
+
function getMainSkillFilePath() {
|
|
20
|
+
const currentFilePath = fileURLToPath(import.meta.url);
|
|
21
|
+
const currentDir = path.dirname(currentFilePath);
|
|
22
|
+
return path.join(currentDir, '..', 'public', 'SKILLS.md');
|
|
23
|
+
}
|
|
19
24
|
function getClaudeSkillsDir() {
|
|
20
25
|
return path.join(os.homedir(), '.claude', 'skills');
|
|
21
26
|
}
|
|
@@ -23,6 +28,10 @@ function parseSkillDescription(content) {
|
|
|
23
28
|
const descriptionMatch = content.match(/^description:\s*(.+)$/m);
|
|
24
29
|
return descriptionMatch?.[1]?.replace(/^["']|["']$/g, '') ?? '';
|
|
25
30
|
}
|
|
31
|
+
function parseSkillName(content) {
|
|
32
|
+
const nameMatch = content.match(/^name:\s*(.+)$/m);
|
|
33
|
+
return nameMatch?.[1]?.replace(/^["']|["']$/g, '') ?? '';
|
|
34
|
+
}
|
|
26
35
|
async function pathExists(targetPath) {
|
|
27
36
|
try {
|
|
28
37
|
await fs.access(targetPath);
|
|
@@ -34,26 +43,38 @@ async function pathExists(targetPath) {
|
|
|
34
43
|
}
|
|
35
44
|
async function listBundledSkills() {
|
|
36
45
|
const skillsDir = getBundledSkillsDir();
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
46
|
+
const mainSkillPath = getMainSkillFilePath();
|
|
47
|
+
const skills = [];
|
|
48
|
+
if (await pathExists(skillsDir)) {
|
|
49
|
+
const entries = await fs.readdir(skillsDir, { withFileTypes: true });
|
|
50
|
+
const bundledSkills = await Promise.all(entries
|
|
51
|
+
.filter((entry) => entry.isDirectory())
|
|
52
|
+
.map(async (entry) => {
|
|
53
|
+
const skillFilePath = path.join(skillsDir, entry.name, 'SKILL.md');
|
|
54
|
+
if (!(await pathExists(skillFilePath))) {
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
const content = await fs.readFile(skillFilePath, 'utf8');
|
|
58
|
+
return {
|
|
59
|
+
name: entry.name,
|
|
60
|
+
description: parseSkillDescription(content),
|
|
61
|
+
sourcePath: path.join(skillsDir, entry.name),
|
|
62
|
+
isDirectory: true,
|
|
63
|
+
};
|
|
64
|
+
}));
|
|
65
|
+
skills.push(...bundledSkills.filter((skill) => skill !== null));
|
|
66
|
+
}
|
|
67
|
+
if (await pathExists(mainSkillPath)) {
|
|
68
|
+
const content = await fs.readFile(mainSkillPath, 'utf8');
|
|
69
|
+
const parsedName = parseSkillName(content);
|
|
70
|
+
skills.push({
|
|
71
|
+
name: parsedName || 'dawn',
|
|
51
72
|
description: parseSkillDescription(content),
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
73
|
+
sourcePath: mainSkillPath,
|
|
74
|
+
isDirectory: false,
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
return skills.sort((a, b) => a.name.localeCompare(b.name));
|
|
57
78
|
}
|
|
58
79
|
async function installBundledSkills(force, dir) {
|
|
59
80
|
const skillsDir = getBundledSkillsDir();
|
|
@@ -62,13 +83,18 @@ async function installBundledSkills(force, dir) {
|
|
|
62
83
|
await fs.mkdir(destinationDir, { recursive: true });
|
|
63
84
|
const results = [];
|
|
64
85
|
for (const skill of skills) {
|
|
65
|
-
const src = path.join(skillsDir, skill.name);
|
|
66
86
|
const dest = path.join(destinationDir, skill.name);
|
|
67
87
|
if ((await pathExists(dest)) && !force) {
|
|
68
88
|
results.push({ name: skill.name, installed: false });
|
|
69
89
|
continue;
|
|
70
90
|
}
|
|
71
|
-
|
|
91
|
+
if (skill.isDirectory) {
|
|
92
|
+
await fs.cp(skill.sourcePath, dest, { recursive: true, force: true });
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
await fs.mkdir(dest, { recursive: true });
|
|
96
|
+
await fs.copyFile(skill.sourcePath, path.join(dest, 'SKILL.md'));
|
|
97
|
+
}
|
|
72
98
|
results.push({ name: skill.name, installed: true });
|
|
73
99
|
}
|
|
74
100
|
return results;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dawnai/cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.7",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "User-facing Dawn CLI",
|
|
6
6
|
"license": "MIT",
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
"files": [
|
|
14
14
|
"dist",
|
|
15
15
|
"skills",
|
|
16
|
+
"public",
|
|
16
17
|
"README.md",
|
|
17
18
|
"CLAUDE.md",
|
|
18
19
|
"postinstall.js"
|
package/postinstall.js
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
+
import fs from 'node:fs/promises';
|
|
4
|
+
import os from 'node:os';
|
|
5
|
+
import path from 'node:path';
|
|
6
|
+
import { fileURLToPath } from 'node:url';
|
|
7
|
+
|
|
3
8
|
// Only show the banner for global installs (skip when installing as a dependency).
|
|
4
9
|
const isGlobal =
|
|
5
10
|
process.env.npm_config_global === 'true' ||
|
|
@@ -10,15 +15,55 @@ if (!isGlobal) {
|
|
|
10
15
|
process.exit(0);
|
|
11
16
|
}
|
|
12
17
|
|
|
18
|
+
async function installDefaultClaudeSkill() {
|
|
19
|
+
const currentFilePath = fileURLToPath(import.meta.url);
|
|
20
|
+
const currentDir = path.dirname(currentFilePath);
|
|
21
|
+
const sourceSkillPath = path.join(currentDir, 'public', 'SKILLS.md');
|
|
22
|
+
const destinationDir = path.join(os.homedir(), '.claude', 'skills', 'dawn');
|
|
23
|
+
const destinationSkillPath = path.join(destinationDir, 'SKILL.md');
|
|
24
|
+
|
|
25
|
+
try {
|
|
26
|
+
await fs.access(sourceSkillPath);
|
|
27
|
+
} catch {
|
|
28
|
+
return { status: 'missing' };
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
try {
|
|
32
|
+
await fs.access(destinationSkillPath);
|
|
33
|
+
return { status: 'exists', path: destinationSkillPath };
|
|
34
|
+
} catch {
|
|
35
|
+
// Destination does not exist yet.
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
await fs.mkdir(destinationDir, { recursive: true });
|
|
39
|
+
await fs.copyFile(sourceSkillPath, destinationSkillPath);
|
|
40
|
+
return { status: 'installed', path: destinationSkillPath };
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
let skillInstallMessage = '';
|
|
44
|
+
try {
|
|
45
|
+
const result = await installDefaultClaudeSkill();
|
|
46
|
+
if (result.status === 'installed') {
|
|
47
|
+
skillInstallMessage = `\n Installed default Claude skill:\n ${result.path}\n`;
|
|
48
|
+
} else if (result.status === 'exists') {
|
|
49
|
+
skillInstallMessage = `\n Default Claude skill already present:\n ${result.path}\n`;
|
|
50
|
+
}
|
|
51
|
+
} catch (error) {
|
|
52
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
53
|
+
skillInstallMessage = `\n Note: could not auto-install default Claude skill (${message}).\n`;
|
|
54
|
+
}
|
|
55
|
+
|
|
13
56
|
console.log(`
|
|
14
57
|
@dawnai/cli installed successfully.
|
|
15
58
|
|
|
16
59
|
Get started:
|
|
17
60
|
dawn --version Check installed version
|
|
18
61
|
dawn auth login Authenticate (opens browser)
|
|
19
|
-
dawn skill install Install Claude Code skills
|
|
62
|
+
dawn skill install Install all bundled Claude Code skills
|
|
20
63
|
dawn --help Show all commands
|
|
21
64
|
|
|
65
|
+
${skillInstallMessage}
|
|
66
|
+
|
|
22
67
|
Headless / CI / agent environments:
|
|
23
68
|
export DAWN_JWT_TOKEN="<your-token>"
|
|
24
69
|
|
package/public/SKILLS.md
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: prediction-market-bot
|
|
3
|
+
description: Runs the full Dawn CLI strategy lifecycle from authentication and funding through strategy creation, launch, monitoring, and termination. Use when the user asks to create, launch, monitor, debug, or operate a strategy/agent using dawn-cli commands.
|
|
4
|
+
tags: [trading, strategy, operations, prediction-market]
|
|
5
|
+
metadata:
|
|
6
|
+
openclaw:
|
|
7
|
+
emoji: "🌅"
|
|
8
|
+
homepage: https://dawn.ai
|
|
9
|
+
requires:
|
|
10
|
+
bins: [dawn]
|
|
11
|
+
install:
|
|
12
|
+
- kind: node
|
|
13
|
+
package: "@dawnai/cli"
|
|
14
|
+
bins: [dawn]
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
# Run a Dawn strategy lifecycle
|
|
18
|
+
|
|
19
|
+
## Goal
|
|
20
|
+
|
|
21
|
+
Execute a complete `dawn` strategy workflow: install/check CLI, authenticate, prepare funding, create and iterate strategy code, launch paper/live runs, monitor status, and stop safely when requested.
|
|
22
|
+
|
|
23
|
+
## When to use
|
|
24
|
+
|
|
25
|
+
Use this skill when the user asks to:
|
|
26
|
+
- create a strategy from plain-English intent,
|
|
27
|
+
- revise or upload strategy code,
|
|
28
|
+
- launch paper or live strategy runs,
|
|
29
|
+
- monitor run health/positions/logs,
|
|
30
|
+
- stop or debug an active run.
|
|
31
|
+
|
|
32
|
+
## Install and preflight
|
|
33
|
+
|
|
34
|
+
Install `dawn` if needed:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
npm install -g @dawnai/cli
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Verify:
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
# Print current Dawn CLI version
|
|
44
|
+
dawn version
|
|
45
|
+
dawn --help
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Local source workflow only:
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
cd dawn-cli
|
|
52
|
+
npm install
|
|
53
|
+
npm run build
|
|
54
|
+
./install.sh
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Command map
|
|
58
|
+
|
|
59
|
+
Auth:
|
|
60
|
+
- `dawn auth login`
|
|
61
|
+
- `dawn auth status`
|
|
62
|
+
- `dawn auth logout`
|
|
63
|
+
|
|
64
|
+
Account:
|
|
65
|
+
- `dawn account overview`
|
|
66
|
+
- `dawn account fund`
|
|
67
|
+
- `dawn account wallet`
|
|
68
|
+
|
|
69
|
+
Strategy authoring:
|
|
70
|
+
- `dawn strategy list`
|
|
71
|
+
- `dawn strategy create "<text>"`
|
|
72
|
+
- `dawn strategy status <conversationId>`
|
|
73
|
+
- `dawn strategy revise <conversationId> "<text>"`
|
|
74
|
+
- `dawn strategy rules <conversationId> list`
|
|
75
|
+
- `dawn strategy rules <conversationId> approve <rule-index>`
|
|
76
|
+
- `dawn strategy rules <conversationId> approve-all`
|
|
77
|
+
- `dawn strategy code <conversationId> status`
|
|
78
|
+
- `dawn strategy code <conversationId> generate`
|
|
79
|
+
- `dawn strategy code <conversationId> export [--out <path>] [--json]`
|
|
80
|
+
- `dawn strategy code <conversationId> upload <path-to-file>`
|
|
81
|
+
|
|
82
|
+
Launch and operations:
|
|
83
|
+
- `dawn strategy launch <conversationId> --budget <usd> [--live] [--hours N]`
|
|
84
|
+
- `dawn strategy positions <conversationId> [--strategy-id <strategyId>]`
|
|
85
|
+
- `dawn run list`
|
|
86
|
+
- `dawn run status <conversationId>`
|
|
87
|
+
- `dawn run logs <conversationId> [--limit N]`
|
|
88
|
+
- `dawn run stop <conversationId>`
|
|
89
|
+
|
|
90
|
+
## Standard flow
|
|
91
|
+
|
|
92
|
+
1. Authenticate: `dawn auth login`.
|
|
93
|
+
2. Confirm funding path: `dawn account fund` (required for live runs).
|
|
94
|
+
3. Create strategy: `dawn strategy create "<request>"` and capture `conversationId`.
|
|
95
|
+
4. Iterate strategy:
|
|
96
|
+
- revise prompt (`strategy revise`) and/or upload files (`strategy code ... upload`),
|
|
97
|
+
- review/approve rules,
|
|
98
|
+
- generate code,
|
|
99
|
+
- export code when needed (`--json` for multi-file map).
|
|
100
|
+
5. Launch:
|
|
101
|
+
- paper: `dawn strategy launch <conversationId> --budget 50`
|
|
102
|
+
- live: `dawn strategy launch <conversationId> --budget 50 --live`
|
|
103
|
+
- custom duration: add `--hours N`
|
|
104
|
+
6. Monitor:
|
|
105
|
+
- `dawn run status <conversationId>`
|
|
106
|
+
- `dawn strategy positions <conversationId>`
|
|
107
|
+
- `dawn run logs <conversationId> --limit N`
|
|
108
|
+
7. Stop when requested: `dawn run stop <conversationId>`, then verify status again.
|
|
109
|
+
|
|
110
|
+
## Monitoring loop
|
|
111
|
+
|
|
112
|
+
For active monitoring sessions:
|
|
113
|
+
1. Query `dawn run status <conversationId>`.
|
|
114
|
+
2. Record timestamp, `isRunning`, status, and active strategy IDs.
|
|
115
|
+
3. Query `dawn strategy positions <conversationId>` for holdings/PnL.
|
|
116
|
+
4. Query `dawn run logs <conversationId> --limit N` for execution details.
|
|
117
|
+
5. If records look stale or missing, wait briefly and retry once.
|
|
118
|
+
|
|
119
|
+
## Troubleshooting
|
|
120
|
+
|
|
121
|
+
- `"Not authenticated. Run: dawn auth login"`: run `dawn auth login` and retry.
|
|
122
|
+
- Auth callback completes but CLI appears stuck: interrupt once and retry login.
|
|
123
|
+
- `"No strategy version found..."`: create/revise/upload strategy code, then relaunch.
|
|
124
|
+
- `"No strategies found for this agent"` on stop: verify `conversationId`, then check `dawn run status`.
|
|
125
|
+
- Live launch fails: re-check funding path with `dawn account fund`.
|
|
126
|
+
|
|
127
|
+
## Run checklist
|
|
128
|
+
|
|
129
|
+
```text
|
|
130
|
+
Dawn Strategy Runbook
|
|
131
|
+
- [ ] Preflight complete
|
|
132
|
+
- [ ] Auth complete
|
|
133
|
+
- [ ] Funding path checked (or user confirmed paper-only)
|
|
134
|
+
- [ ] conversationId captured
|
|
135
|
+
- [ ] Strategy code generated/uploaded
|
|
136
|
+
- [ ] Launch run completed (paper/live)
|
|
137
|
+
- [ ] strategyId captured (if launched)
|
|
138
|
+
- [ ] Monitoring snapshots collected
|
|
139
|
+
- [ ] Stop executed (if requested)
|
|
140
|
+
- [ ] Final status verified
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
## Skills
|
|
144
|
+
|
|
145
|
+
Individual skills for each command:
|
|
146
|
+
|
|
147
|
+
| Skill | Purpose |
|
|
148
|
+
|-------|---------|
|
|
149
|
+
| **dawn-auth** | Install, authenticate, check status, logout |
|
|
150
|
+
| **dawn-account** | Account overview, funding, wallet balances |
|
|
151
|
+
| **dawn-strategy-create** | Create a strategy from plain-English prompt |
|
|
152
|
+
| **dawn-strategy-list** | List all strategies |
|
|
153
|
+
| **dawn-strategy-status** | Full strategy status and health |
|
|
154
|
+
| **dawn-strategy-revise** | Iterate on a strategy with revisions |
|
|
155
|
+
| **dawn-strategy-rules** | List, approve, and manage rules |
|
|
156
|
+
| **dawn-strategy-code** | Code generation, status, export, upload |
|
|
157
|
+
| **dawn-strategy-launch** | Launch paper or live runs |
|
|
158
|
+
| **dawn-strategy-positions** | View positions and PnL |
|
|
159
|
+
| **dawn-run-monitor** | List runs, check status, view logs |
|
|
160
|
+
| **dawn-run-stop** | Stop a running strategy |
|
|
161
|
+
|
|
162
|
+
## Required output
|
|
163
|
+
|
|
164
|
+
When using this skill, always return:
|
|
165
|
+
- `conversationId`,
|
|
166
|
+
- `strategyId` (if launched),
|
|
167
|
+
- run mode (paper/live),
|
|
168
|
+
- latest monitoring summary,
|
|
169
|
+
- exact next command to run (or the last command run).
|
|
@@ -27,7 +27,15 @@ dawn account wallet
|
|
|
27
27
|
|
|
28
28
|
1. Run `dawn account overview` for a full snapshot of balances and vaults.
|
|
29
29
|
2. If the user needs to add funds, run `dawn account fund` to get the deposit address and instructions.
|
|
30
|
-
3.
|
|
30
|
+
3. Explicitly direct the user to use `@moonpay/cli` to fund that address with USDC.
|
|
31
|
+
4. After funding completes, run `dawn account wallet` (or `dawn account overview`) to verify funds arrived.
|
|
32
|
+
5. For a quick balance check, run `dawn account wallet`.
|
|
33
|
+
|
|
34
|
+
## Explicit handoff to @moonpay/cli
|
|
35
|
+
|
|
36
|
+
When funding is needed, always include this instruction after `dawn account fund`:
|
|
37
|
+
|
|
38
|
+
`Use @moonpay/cli to buy or transfer USDC to the Dawn funding address shown above.`
|
|
31
39
|
|
|
32
40
|
## Example flows
|
|
33
41
|
|
|
@@ -40,15 +48,18 @@ dawn account wallet
|
|
|
40
48
|
1. User wants to launch a live strategy but needs funds.
|
|
41
49
|
2. Run: `dawn account fund`
|
|
42
50
|
3. Present: wallet address and USDC deposit instructions.
|
|
43
|
-
4.
|
|
51
|
+
4. Instruct: `Use @moonpay/cli to buy/transfer USDC to this address.`
|
|
52
|
+
5. Verify funds with `dawn account wallet`, then proceed to launch.
|
|
44
53
|
|
|
45
54
|
## Notes
|
|
46
55
|
|
|
47
56
|
- `dawn account fund` shows the wallet address to deposit USDC to.
|
|
57
|
+
- Always explicitly direct users to `@moonpay/cli` for guided USDC on-ramp and transfer steps.
|
|
48
58
|
- Funding is required before launching live strategy runs.
|
|
49
59
|
- Paper runs do not require funding.
|
|
50
60
|
|
|
51
61
|
## Related skills
|
|
52
62
|
|
|
53
63
|
- **dawn-auth** — Authenticate before checking account.
|
|
64
|
+
- **@moonpay/cli** — Help users buy and transfer USDC to the Dawn funding address.
|
|
54
65
|
- **dawn-strategy-launch** — Launch a run after confirming funding.
|