open-wadah 1.2.3 → 1.3.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.
- package/README.md +105 -53
- package/cli.js +179 -28
- package/package.json +1 -1
- package/test/cli.test.js +7 -1
package/README.md
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
# open-wadah
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Command-line interface for Wadah task boards and autonomous agent workflows.
|
|
4
|
+
|
|
5
|
+
`open-wadah` gives teams and AI agents a fast, scriptable way to plan, assign, and deliver work from the terminal.
|
|
6
|
+
|
|
7
|
+
## Why teams use Wadah CLI
|
|
8
|
+
|
|
9
|
+
- Manage tasks, assignees, and board flow without leaving your terminal.
|
|
10
|
+
- Automate workflows with stable JSON output for scripts and CI.
|
|
11
|
+
- Power autonomous agents with scoped agent tokens.
|
|
12
|
+
- Keep human and agent work on the same board and process.
|
|
4
13
|
|
|
5
14
|
## Install
|
|
6
15
|
|
|
@@ -8,92 +17,135 @@ Open WADAH CLI — shared task board for humans and agents. Use it from the term
|
|
|
8
17
|
npm install -g open-wadah
|
|
9
18
|
```
|
|
10
19
|
|
|
11
|
-
|
|
20
|
+
Available commands: `wadah`, `ow`, `tm`.
|
|
21
|
+
|
|
22
|
+
## 60-second quick start
|
|
12
23
|
|
|
13
|
-
|
|
24
|
+
1. Sign in:
|
|
14
25
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
26
|
+
```bash
|
|
27
|
+
wadah login
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
2. Open your assigned tasks:
|
|
18
31
|
|
|
19
32
|
```bash
|
|
20
33
|
wadah open
|
|
21
|
-
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
3. Create and move work:
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
wadah add "Fix login issue" --board "Main"
|
|
40
|
+
wadah move <task-id> <bucket-id>
|
|
22
41
|
wadah complete <task-id>
|
|
23
42
|
```
|
|
24
43
|
|
|
25
|
-
|
|
44
|
+
Default API URL is `https://api.openwadah.com`. Override with `--api <url>` or `WADAH_API_URL`.
|
|
45
|
+
|
|
46
|
+
## Core workflows
|
|
26
47
|
|
|
27
|
-
|
|
28
|
-
|--------|-------------|
|
|
29
|
-
| **Auth** | `login`, `signup`, `logout`, `whoami` |
|
|
30
|
-
| **Tasks** | `open`, `list`, `search`, `requested`, `add`, `complete`, `reopen`, `view`, `update`, `move`, `assign`, `comment`, `subtask list/add/toggle/delete`, `delete` |
|
|
31
|
-
| **Relationships** | `add --blocks <id>`, `add --blocked-by <id>`, `update --blocks <id>` |
|
|
32
|
-
| **Board** | `boards --json`, `buckets --json`, `assignees --json`; `board create/delete`, `bucket create/update/delete`, `assignee create/update/delete` |
|
|
33
|
-
| **Files** | `folders`, `files`, `folder create` / `mkdir`, `upload` |
|
|
34
|
-
| **Calendar** | `calendar` (list; `--assignee`, `--task`, `--from`, `--to`), `calendar add`, `calendar update <id>`, `calendar delete <id>` |
|
|
35
|
-
| **Docs** | `docs` (list), `doc create [title]`, `doc show <id>`, `doc update <id>`, `doc delete <id>` |
|
|
36
|
-
| **Agent tokens** | `agent-tokens` (list), `agent-token create [name]`, `agent-token delete <id>` |
|
|
37
|
-
| **Workspace** | `state`, `members`, `invite`, `config` |
|
|
38
|
-
| **Other** | `do "<sentence>"` (natural language, needs `OPENAI_API_KEY`), `doctor`, `completion [bash\|zsh]` |
|
|
48
|
+
### Daily task operations
|
|
39
49
|
|
|
40
|
-
|
|
50
|
+
```bash
|
|
51
|
+
wadah list --board "Main"
|
|
52
|
+
wadah search "billing"
|
|
53
|
+
wadah view <task-id>
|
|
54
|
+
wadah update <task-id> --notes "Root cause + next steps"
|
|
55
|
+
wadah comment <task-id> "Investigating now"
|
|
56
|
+
```
|
|
41
57
|
|
|
42
|
-
|
|
58
|
+
### Dependencies and subtasks
|
|
43
59
|
|
|
44
60
|
```bash
|
|
61
|
+
wadah add "Ship release notes" --blocks <task-id>
|
|
45
62
|
wadah subtask add <task-id> "Write tests"
|
|
46
63
|
wadah subtask list <task-id>
|
|
47
64
|
wadah subtask toggle <task-id> <subtask-id>
|
|
48
|
-
wadah subtask delete <task-id> <subtask-id>
|
|
49
65
|
```
|
|
50
66
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
**Bash:**
|
|
67
|
+
### Board administration
|
|
54
68
|
|
|
55
69
|
```bash
|
|
56
|
-
wadah
|
|
57
|
-
|
|
70
|
+
wadah board create "Backend"
|
|
71
|
+
wadah bucket create "In Review" --board <board-id>
|
|
72
|
+
wadah assignee create "Cursor Agent" --type agent
|
|
73
|
+
wadah buckets --board "Backend" --json
|
|
58
74
|
```
|
|
59
75
|
|
|
60
|
-
|
|
76
|
+
## Command surface
|
|
77
|
+
|
|
78
|
+
| Area | Commands |
|
|
79
|
+
|---|---|
|
|
80
|
+
| Auth | `login`, `signup`, `logout`, `whoami` |
|
|
81
|
+
| Tasks | `open`, `list`, `search`, `requested`, `add`, `view`, `update`, `move`, `assign`, `comment`, `complete`, `reopen`, `delete` |
|
|
82
|
+
| Subtasks | `subtask list`, `subtask add`, `subtask toggle`, `subtask delete` |
|
|
83
|
+
| Boards & members | `boards`, `buckets`, `assignees`, `board create/delete`, `bucket create/update/delete`, `assignee create/update/delete` |
|
|
84
|
+
| Docs | `docs`, `doc create/show/update/delete` |
|
|
85
|
+
| Calendar | `calendar`, `calendar add/update/delete` |
|
|
86
|
+
| Files | `folders`, `files`, `folder create`, `mkdir`, `upload` |
|
|
87
|
+
| Agent tokens | `agent-tokens`, `agent-token create/delete` |
|
|
88
|
+
| Utilities | `doctor`, `completion bash`, `completion zsh`, `state`, `members`, `invite`, `config`, `do` |
|
|
89
|
+
|
|
90
|
+
Use `wadah --help` or `wadah <command> --help` for full flags and examples.
|
|
91
|
+
|
|
92
|
+
## AI agent mode
|
|
93
|
+
|
|
94
|
+
For autonomous workflows (Cursor, Claude Code, GitHub Actions):
|
|
95
|
+
|
|
96
|
+
- Create an agent token:
|
|
61
97
|
|
|
62
98
|
```bash
|
|
63
|
-
wadah
|
|
64
|
-
source ~/.zshrc
|
|
99
|
+
wadah agent-token create "My Agent"
|
|
65
100
|
```
|
|
66
101
|
|
|
67
|
-
|
|
102
|
+
- Set it as `WADAH_AGENT_TOKEN` in your environment.
|
|
103
|
+
- Use `--json` for deterministic machine output (`wadah open --json`).
|
|
104
|
+
- Optional natural-language command:
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
wadah do "add a task to fix onboarding bug"
|
|
108
|
+
```
|
|
68
109
|
|
|
69
|
-
|
|
70
|
-
- Use `--json` for machine-readable output: `wadah open --json`, `wadah list --json`, `wadah buckets --json`.
|
|
71
|
-
- Natural language: `wadah do "add a task to fix the bug"` (requires `OPENAI_API_KEY`).
|
|
72
|
-
- In Cursor/Claude/Kimi: see **WADAH_CLI.md** in the repo root for a short reference.
|
|
73
|
-
- For autonomous 24/7 agents with GitHub Actions: see **AGENTS.md** in the repo root.
|
|
110
|
+
`wadah do` requires `OPENAI_API_KEY`.
|
|
74
111
|
|
|
75
112
|
## Global flags
|
|
76
113
|
|
|
77
|
-
- `--api <url
|
|
78
|
-
- `--profile <name
|
|
79
|
-
- `--token <token
|
|
80
|
-
- `--json
|
|
81
|
-
- `--quiet
|
|
114
|
+
- `--api <url>`: API base URL
|
|
115
|
+
- `--profile <name>`: config profile
|
|
116
|
+
- `--token <token>`: token for current command only
|
|
117
|
+
- `--json`: machine-readable output
|
|
118
|
+
- `--quiet`: reduce non-essential output
|
|
82
119
|
|
|
83
|
-
##
|
|
120
|
+
## Environment variables
|
|
84
121
|
|
|
85
|
-
|
|
122
|
+
- `WADAH_AGENT_TOKEN`: preferred auth token for automation
|
|
123
|
+
- `WADAH_API_URL`: override API base URL
|
|
124
|
+
- `OPENAI_API_KEY`: required for `wadah do`
|
|
125
|
+
|
|
126
|
+
## Shell completion
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
# Bash
|
|
130
|
+
wadah completion bash >> ~/.bashrc && source ~/.bashrc
|
|
131
|
+
|
|
132
|
+
# Zsh
|
|
133
|
+
wadah completion zsh >> ~/.zshrc && source ~/.zshrc
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
## Development
|
|
86
137
|
|
|
87
138
|
```bash
|
|
88
|
-
npm
|
|
89
|
-
|
|
90
|
-
cd task-manager-cli && npm test
|
|
139
|
+
npm test
|
|
140
|
+
node cli.js --help
|
|
91
141
|
```
|
|
92
142
|
|
|
93
|
-
##
|
|
143
|
+
## JSON error codes
|
|
144
|
+
|
|
145
|
+
When running with `--json`, failures include structured error codes:
|
|
94
146
|
|
|
95
|
-
- `auth_error`
|
|
96
|
-
- `validation_error`
|
|
97
|
-
- `network_error`
|
|
98
|
-
- `api_error`
|
|
99
|
-
- `config`
|
|
147
|
+
- `auth_error`
|
|
148
|
+
- `validation_error`
|
|
149
|
+
- `network_error`
|
|
150
|
+
- `api_error`
|
|
151
|
+
- `config`
|
package/cli.js
CHANGED
|
@@ -31,7 +31,7 @@ function normalizeApiUrl(url) {
|
|
|
31
31
|
const conf = new Conf({ projectName: 'open-wadah' })
|
|
32
32
|
|
|
33
33
|
function getProfile() {
|
|
34
|
-
const profile = (process.env.
|
|
34
|
+
const profile = (process.env.WADAH_PROFILE ?? runtimeProfile ?? 'default').trim()
|
|
35
35
|
return profile || 'default'
|
|
36
36
|
}
|
|
37
37
|
|
|
@@ -55,15 +55,28 @@ function confDelete(key) {
|
|
|
55
55
|
|
|
56
56
|
function getApiBase() {
|
|
57
57
|
return (
|
|
58
|
-
(process.env.
|
|
58
|
+
(process.env.WADAH_API_URL ?? '').trim() ||
|
|
59
59
|
runtimeApiBase ||
|
|
60
60
|
confGet('api_url') ||
|
|
61
61
|
DEFAULT_API_BASE
|
|
62
62
|
)
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
+
/** Agent token from env: reads WADAH_AGENT_TOKEN. */
|
|
66
|
+
function envAgentToken() {
|
|
67
|
+
const w = (process.env.WADAH_AGENT_TOKEN ?? '').trim()
|
|
68
|
+
return w || null
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** Which env var supplied the agent token (for status output). */
|
|
72
|
+
function envAgentTokenVarName() {
|
|
73
|
+
if ((process.env.WADAH_AGENT_TOKEN ?? '').trim()) return 'WADAH_AGENT_TOKEN'
|
|
74
|
+
return null
|
|
75
|
+
}
|
|
76
|
+
|
|
65
77
|
function getAuthToken() {
|
|
66
|
-
|
|
78
|
+
const fromEnv = envAgentToken()
|
|
79
|
+
if (fromEnv) return fromEnv
|
|
67
80
|
if (runtimeToken) return runtimeToken
|
|
68
81
|
return confGet('access_token') ?? null
|
|
69
82
|
}
|
|
@@ -99,7 +112,7 @@ async function refreshAccessToken() {
|
|
|
99
112
|
}
|
|
100
113
|
|
|
101
114
|
async function ensureAuth() {
|
|
102
|
-
if (
|
|
115
|
+
if (envAgentToken()) return // agent token, no refresh needed
|
|
103
116
|
const expires = confGet('token_expires')
|
|
104
117
|
// Refresh if within 5 minutes of expiry or already expired
|
|
105
118
|
if (expires && Date.now() > (expires * 1000) - 300_000) {
|
|
@@ -120,7 +133,7 @@ async function api(path, options = {}, retry = true) {
|
|
|
120
133
|
}
|
|
121
134
|
|
|
122
135
|
// If 401 and we have a refresh token, try once more
|
|
123
|
-
if (res.status === 401 && retry && !
|
|
136
|
+
if (res.status === 401 && retry && !envAgentToken()) {
|
|
124
137
|
const refreshed = await refreshAccessToken()
|
|
125
138
|
if (refreshed) return api(path, options, false)
|
|
126
139
|
}
|
|
@@ -197,7 +210,7 @@ function handleError(err) {
|
|
|
197
210
|
} else if (authLike) {
|
|
198
211
|
console.error(chalk.red('\n✗ Not authenticated.'))
|
|
199
212
|
console.error(chalk.gray(' Humans: wadah login'))
|
|
200
|
-
console.error(chalk.gray(' Agents:
|
|
213
|
+
console.error(chalk.gray(' Agents: WADAH_AGENT_TOKEN=<token> wadah open\n'))
|
|
201
214
|
} else if (code === 'network_error') {
|
|
202
215
|
console.error(chalk.red('\n✗ Network error — could not reach the API.'))
|
|
203
216
|
console.error(chalk.gray(` Check your connection or API URL: ${getApiBase()}`))
|
|
@@ -738,7 +751,7 @@ program
|
|
|
738
751
|
.action(async () => {
|
|
739
752
|
if (isMachineOutput()) {
|
|
740
753
|
try {
|
|
741
|
-
if (
|
|
754
|
+
if (envAgentToken() || runtimeToken) {
|
|
742
755
|
const me = await api('/api/auth/me')
|
|
743
756
|
const ws = me.workspaces?.[0] ?? null
|
|
744
757
|
console.log(JSON.stringify({
|
|
@@ -771,8 +784,8 @@ program
|
|
|
771
784
|
return
|
|
772
785
|
}
|
|
773
786
|
|
|
774
|
-
if (
|
|
775
|
-
console.log(chalk.bold('\nAgent') +
|
|
787
|
+
if (envAgentToken()) {
|
|
788
|
+
console.log(chalk.bold('\nAgent') + ` (${envAgentTokenVarName()})`)
|
|
776
789
|
} else {
|
|
777
790
|
const email = confGet('user_email')
|
|
778
791
|
if (!email) {
|
|
@@ -1252,7 +1265,16 @@ program
|
|
|
1252
1265
|
if (requester) console.log(chalk.gray(` Requested: ${requester}`))
|
|
1253
1266
|
if (task.dueDate) console.log(chalk.gray(` Due: ${formatDate(task.dueDate)}`))
|
|
1254
1267
|
if (task.repo) console.log(chalk.gray(` Repo: ${task.repo}`))
|
|
1255
|
-
if (task.
|
|
1268
|
+
if (Array.isArray(task.contextLinks) && task.contextLinks.length > 0) {
|
|
1269
|
+
console.log(chalk.gray('\n Links:'))
|
|
1270
|
+
task.contextLinks.forEach((l) => {
|
|
1271
|
+
const lab = l.label ? `${l.label}: ` : ''
|
|
1272
|
+
console.log(chalk.gray(` ${lab}${l.url}`))
|
|
1273
|
+
})
|
|
1274
|
+
if (task.contextUrl) console.log(chalk.gray(` Primary: ${task.contextUrl}`))
|
|
1275
|
+
} else if (task.contextUrl) {
|
|
1276
|
+
console.log(chalk.gray(` Link: ${task.contextUrl}`))
|
|
1277
|
+
}
|
|
1256
1278
|
if (task.tags?.length) {
|
|
1257
1279
|
const relTags = task.tags.filter((t) => t.startsWith('blocks:') || t.startsWith('blocked-by:'))
|
|
1258
1280
|
const plainTags = task.tags.filter((t) => !t.startsWith('blocks:') && !t.startsWith('blocked-by:'))
|
|
@@ -1471,13 +1493,42 @@ const boardCmd = program.command('board').description('Create or delete a board
|
|
|
1471
1493
|
boardCmd
|
|
1472
1494
|
.command('create <name>')
|
|
1473
1495
|
.description('Create a new board')
|
|
1474
|
-
.
|
|
1496
|
+
.option('--flow <columns>', 'Comma-separated column flow, e.g. "Backlog,Ready,Doing,QA,Done"')
|
|
1497
|
+
.action(async function (name) {
|
|
1475
1498
|
try {
|
|
1499
|
+
const opts = this.opts()
|
|
1476
1500
|
const board = await api('/api/boards', { method: 'POST', body: JSON.stringify({ name: String(name).trim() }) })
|
|
1501
|
+
const createdBuckets = []
|
|
1502
|
+
if (opts.flow) {
|
|
1503
|
+
const flowColumns = String(opts.flow)
|
|
1504
|
+
.split(',')
|
|
1505
|
+
.map((c) => c.trim())
|
|
1506
|
+
.filter(Boolean)
|
|
1507
|
+
if (flowColumns.length === 0) {
|
|
1508
|
+
return fail('Flow is empty. Provide comma-separated columns, e.g. --flow "Backlog,Doing,Done".')
|
|
1509
|
+
}
|
|
1510
|
+
for (const column of flowColumns) {
|
|
1511
|
+
if (!column) continue
|
|
1512
|
+
const bucket = await api('/api/buckets', {
|
|
1513
|
+
method: 'POST',
|
|
1514
|
+
body: JSON.stringify({ title: column, boardId: board.id }),
|
|
1515
|
+
})
|
|
1516
|
+
createdBuckets.push(bucket)
|
|
1517
|
+
}
|
|
1518
|
+
}
|
|
1477
1519
|
if (isMachineOutput()) {
|
|
1478
|
-
console.log(JSON.stringify(
|
|
1520
|
+
console.log(JSON.stringify(
|
|
1521
|
+
{ ...board, flow: createdBuckets.map((b) => ({ id: b.id, title: b.title })) },
|
|
1522
|
+
null,
|
|
1523
|
+
runtimeJsonOutput ? 2 : 0
|
|
1524
|
+
))
|
|
1479
1525
|
} else {
|
|
1480
1526
|
console.log(chalk.green('\n✓ Board created') + ` ${chalk.bold(board.name)} ${chalk.gray(board.id?.slice(0, 8))}\n`)
|
|
1527
|
+
if (createdBuckets.length > 0) {
|
|
1528
|
+
console.log(chalk.gray(' Flow columns:'))
|
|
1529
|
+
createdBuckets.forEach((b) => console.log(` - ${b.title} ${chalk.gray(b.id?.slice(0, 8))}`))
|
|
1530
|
+
console.log()
|
|
1531
|
+
}
|
|
1481
1532
|
}
|
|
1482
1533
|
} catch (err) { handleError(err) }
|
|
1483
1534
|
})
|
|
@@ -1826,6 +1877,106 @@ prCmd
|
|
|
1826
1877
|
} catch (err) { handleError(err) }
|
|
1827
1878
|
})
|
|
1828
1879
|
|
|
1880
|
+
const linkCmd = program.command('link').description('Attach labeled URLs to tasks (Vercel, Figma, docs — without replacing the PR)')
|
|
1881
|
+
|
|
1882
|
+
function normalizeHttpUrlForLink(input) {
|
|
1883
|
+
let parsed
|
|
1884
|
+
try {
|
|
1885
|
+
parsed = new URL(String(input).trim())
|
|
1886
|
+
} catch {
|
|
1887
|
+
return null
|
|
1888
|
+
}
|
|
1889
|
+
if (!['http:', 'https:'].includes(parsed.protocol)) return null
|
|
1890
|
+
return parsed.toString()
|
|
1891
|
+
}
|
|
1892
|
+
|
|
1893
|
+
const MAX_TASK_LINKS = 20
|
|
1894
|
+
|
|
1895
|
+
linkCmd
|
|
1896
|
+
.command('add <taskId> <url>')
|
|
1897
|
+
.description('Append a URL to a task (use --label for display)')
|
|
1898
|
+
.option('--label <text>', 'Short label, e.g. Vercel, Figma', '')
|
|
1899
|
+
.action(async function (taskId, url) {
|
|
1900
|
+
const opts = this.opts()
|
|
1901
|
+
try {
|
|
1902
|
+
const normalizedUrl = normalizeHttpUrlForLink(url)
|
|
1903
|
+
if (!normalizedUrl) return fail('Provide a valid http(s) URL')
|
|
1904
|
+
|
|
1905
|
+
const task = await api(`/api/tasks/${taskId}`)
|
|
1906
|
+
const existing = Array.isArray(task.contextLinks) ? task.contextLinks : []
|
|
1907
|
+
if (existing.length >= MAX_TASK_LINKS) {
|
|
1908
|
+
return fail(`A task can have at most ${MAX_TASK_LINKS} links. Remove one with: wadah link remove <task-id> <link-id>`)
|
|
1909
|
+
}
|
|
1910
|
+
const label = String(opts.label ?? '').trim().slice(0, 64)
|
|
1911
|
+
const next = [...existing, { id: randomUUID(), label, url: normalizedUrl }]
|
|
1912
|
+
|
|
1913
|
+
await api(`/api/tasks/${taskId}`, {
|
|
1914
|
+
method: 'PATCH',
|
|
1915
|
+
body: JSON.stringify({ contextLinks: next }),
|
|
1916
|
+
})
|
|
1917
|
+
|
|
1918
|
+
if (isMachineOutput()) {
|
|
1919
|
+
console.log(JSON.stringify({ taskId, url: normalizedUrl, label, added: true, links: next }, null, runtimeJsonOutput ? 2 : 0))
|
|
1920
|
+
} else {
|
|
1921
|
+
console.log(chalk.green('\n✓ Link added') + ` ${chalk.bold(task.title)}`)
|
|
1922
|
+
console.log(chalk.gray(` ${label ? `${label} · ` : ''}${normalizedUrl}\n`))
|
|
1923
|
+
}
|
|
1924
|
+
} catch (err) { handleError(err) }
|
|
1925
|
+
})
|
|
1926
|
+
|
|
1927
|
+
linkCmd
|
|
1928
|
+
.command('list <taskId>')
|
|
1929
|
+
.description('List URLs attached to a task')
|
|
1930
|
+
.action(async (taskId) => {
|
|
1931
|
+
try {
|
|
1932
|
+
const task = await api(`/api/tasks/${taskId}`)
|
|
1933
|
+
const links = Array.isArray(task.contextLinks) ? task.contextLinks : []
|
|
1934
|
+
if (isMachineOutput()) {
|
|
1935
|
+
console.log(JSON.stringify({ taskId, links, contextUrl: task.contextUrl ?? null }, null, runtimeJsonOutput ? 2 : 0))
|
|
1936
|
+
return
|
|
1937
|
+
}
|
|
1938
|
+
if (links.length === 0) {
|
|
1939
|
+
console.log(chalk.gray('\nNo links on this task. Add one: wadah link add <task-id> <url> --label Vercel\n'))
|
|
1940
|
+
return
|
|
1941
|
+
}
|
|
1942
|
+
console.log()
|
|
1943
|
+
links.forEach((l) => {
|
|
1944
|
+
const lab = l.label ? chalk.cyan(l.label) : chalk.gray('link')
|
|
1945
|
+
console.log(` ${chalk.dim(l.id)} ${lab}`)
|
|
1946
|
+
console.log(chalk.gray(` ${l.url}`))
|
|
1947
|
+
})
|
|
1948
|
+
if (task.contextUrl) {
|
|
1949
|
+
console.log(chalk.gray(`\n Primary (e.g. wadah pr open): ${task.contextUrl}\n`))
|
|
1950
|
+
} else {
|
|
1951
|
+
console.log()
|
|
1952
|
+
}
|
|
1953
|
+
} catch (err) { handleError(err) }
|
|
1954
|
+
})
|
|
1955
|
+
|
|
1956
|
+
linkCmd
|
|
1957
|
+
.command('remove <taskId> <linkId>')
|
|
1958
|
+
.description('Remove a link by id (from wadah link list --json)')
|
|
1959
|
+
.action(async (taskId, linkId) => {
|
|
1960
|
+
try {
|
|
1961
|
+
const task = await api(`/api/tasks/${taskId}`)
|
|
1962
|
+
const existing = Array.isArray(task.contextLinks) ? task.contextLinks : []
|
|
1963
|
+
const needle = String(linkId).trim()
|
|
1964
|
+
const next = existing.filter((l) => l.id !== needle)
|
|
1965
|
+
if (next.length === existing.length) {
|
|
1966
|
+
return fail(`No link with id matching "${needle}". Use: wadah link list ${taskId} --json`)
|
|
1967
|
+
}
|
|
1968
|
+
await api(`/api/tasks/${taskId}`, {
|
|
1969
|
+
method: 'PATCH',
|
|
1970
|
+
body: JSON.stringify({ contextLinks: next }),
|
|
1971
|
+
})
|
|
1972
|
+
if (isMachineOutput()) {
|
|
1973
|
+
console.log(JSON.stringify({ taskId, removed: needle, links: next }, null, runtimeJsonOutput ? 2 : 0))
|
|
1974
|
+
} else {
|
|
1975
|
+
console.log(chalk.green('\n✓ Link removed') + ` ${chalk.bold(task.title)}\n`)
|
|
1976
|
+
}
|
|
1977
|
+
} catch (err) { handleError(err) }
|
|
1978
|
+
})
|
|
1979
|
+
|
|
1829
1980
|
// ── agent tokens ──────────────────────────────────────────────────────────────
|
|
1830
1981
|
|
|
1831
1982
|
program
|
|
@@ -1858,7 +2009,7 @@ const agentTokenCmd = program.command('agent-token').description('Create or dele
|
|
|
1858
2009
|
|
|
1859
2010
|
agentTokenCmd
|
|
1860
2011
|
.command('create [name]')
|
|
1861
|
-
.description('Create an agent token; token is shown once — store it as
|
|
2012
|
+
.description('Create an agent token; token is shown once — store it as WADAH_AGENT_TOKEN')
|
|
1862
2013
|
.option('--name <text>', 'Token name (if not passed as argument)')
|
|
1863
2014
|
.option('--assignee-name <text>', 'Display name for the agent (default: same as name)')
|
|
1864
2015
|
.action(async function (nameArg) {
|
|
@@ -1876,9 +2027,9 @@ agentTokenCmd
|
|
|
1876
2027
|
console.log(chalk.yellow('\n Token (store it now — shown once):'))
|
|
1877
2028
|
console.log(` ${result.token}`)
|
|
1878
2029
|
console.log(chalk.gray('\n Store it so you don’t lose it:'))
|
|
1879
|
-
console.log(chalk.gray(' · GitHub Actions: Repo → Settings → Secrets and variables → Actions → New secret →
|
|
1880
|
-
console.log(chalk.gray(' · Cursor: Settings → Environment variables →
|
|
1881
|
-
console.log(chalk.gray(' · Shell: export
|
|
2030
|
+
console.log(chalk.gray(' · GitHub Actions: Repo → Settings → Secrets and variables → Actions → New secret → WADAH_AGENT_TOKEN'))
|
|
2031
|
+
console.log(chalk.gray(' · Cursor: Settings → Environment variables → WADAH_AGENT_TOKEN'))
|
|
2032
|
+
console.log(chalk.gray(' · Shell: export WADAH_AGENT_TOKEN="<paste token here>"\n'))
|
|
1882
2033
|
}
|
|
1883
2034
|
} catch (err) { handleError(err) }
|
|
1884
2035
|
})
|
|
@@ -2202,12 +2353,12 @@ program
|
|
|
2202
2353
|
addCheck('api_ping', 'fail', `API ping failed: ${err.message}`)
|
|
2203
2354
|
}
|
|
2204
2355
|
|
|
2205
|
-
const hasEnvToken = Boolean(
|
|
2356
|
+
const hasEnvToken = Boolean(envAgentToken() || runtimeToken)
|
|
2206
2357
|
const hasSavedToken = Boolean(confGet('access_token'))
|
|
2207
2358
|
if (!hasEnvToken && !hasSavedToken) {
|
|
2208
2359
|
addCheck('auth_token', 'warn', 'No token available. Run wadah login.')
|
|
2209
2360
|
} else if (hasEnvToken) {
|
|
2210
|
-
addCheck('auth_token', 'pass',
|
|
2361
|
+
addCheck('auth_token', 'pass', `Using agent token from env/flag (${envAgentTokenVarName()})`)
|
|
2211
2362
|
} else {
|
|
2212
2363
|
addCheck('auth_token', 'pass', 'Using token from profile config')
|
|
2213
2364
|
}
|
|
@@ -2233,7 +2384,7 @@ program
|
|
|
2233
2384
|
addCheck('auth_me', 'warn', `Auth check failed: ${err.message}`)
|
|
2234
2385
|
}
|
|
2235
2386
|
|
|
2236
|
-
// Agent-specific checks (only when
|
|
2387
|
+
// Agent-specific checks (only when an env agent token is set)
|
|
2237
2388
|
if (hasEnvToken && meBody) {
|
|
2238
2389
|
const isAgent = meBody.workspaces?.[0]?.role === 'agent'
|
|
2239
2390
|
if (!isAgent) {
|
|
@@ -2359,7 +2510,7 @@ program
|
|
|
2359
2510
|
const config = {
|
|
2360
2511
|
api_url: getApiBase(),
|
|
2361
2512
|
signed_in_as: confGet('user_email') ?? null,
|
|
2362
|
-
agent_mode: Boolean(
|
|
2513
|
+
agent_mode: Boolean(envAgentToken() || runtimeToken),
|
|
2363
2514
|
profile: getProfile(),
|
|
2364
2515
|
default_board: defaultBoard ?? null,
|
|
2365
2516
|
config_file: conf.path,
|
|
@@ -2372,7 +2523,7 @@ program
|
|
|
2372
2523
|
console.log(chalk.bold('CLI config'))
|
|
2373
2524
|
console.log(chalk.gray(` API URL: ${config.api_url}`))
|
|
2374
2525
|
console.log(chalk.gray(` Signed in as: ${config.signed_in_as ?? '—'}`))
|
|
2375
|
-
console.log(chalk.gray(` Agent mode: ${config.agent_mode ?
|
|
2526
|
+
console.log(chalk.gray(` Agent mode: ${config.agent_mode ? `yes (${envAgentTokenVarName() ?? 'token flag'} set)` : 'no'}`))
|
|
2376
2527
|
console.log(chalk.gray(` Default board: ${defaultBoard ?? '— (not set, use: wadah config --default-board "Name")'}`))
|
|
2377
2528
|
console.log(chalk.gray(` Profile: ${getProfile()}`))
|
|
2378
2529
|
console.log(chalk.gray(` Config file: ${config.config_file}`))
|
|
@@ -2461,7 +2612,7 @@ program
|
|
|
2461
2612
|
.description('Interactive wizard: create an agent token, write it to your shell profile, and verify everything works')
|
|
2462
2613
|
.option('--name <name>', 'Agent name (skip prompt)')
|
|
2463
2614
|
.option('--board <board>', 'Default board name (skip prompt)')
|
|
2464
|
-
.option('--skip-env', 'Skip writing
|
|
2615
|
+
.option('--skip-env', 'Skip writing WADAH_AGENT_TOKEN to shell profile (print instructions only)')
|
|
2465
2616
|
.action(async (opts) => {
|
|
2466
2617
|
const readline = await import('node:readline/promises')
|
|
2467
2618
|
const os = await import('node:os')
|
|
@@ -2525,18 +2676,18 @@ program
|
|
|
2525
2676
|
|
|
2526
2677
|
// Step 4: write env var to shell profile
|
|
2527
2678
|
console.log()
|
|
2528
|
-
console.log(chalk.bold('Step 4/5 Setting up
|
|
2679
|
+
console.log(chalk.bold('Step 4/5 Setting up WADAH_AGENT_TOKEN…'))
|
|
2529
2680
|
|
|
2530
2681
|
const shell = process.env.SHELL ?? ''
|
|
2531
2682
|
const profileMap = { zsh: '.zshrc', bash: '.bashrc', fish: '.config/fish/config.fish' }
|
|
2532
2683
|
const profileKey = Object.keys(profileMap).find((k) => shell.includes(k))
|
|
2533
2684
|
const profileFile = profileKey ? path.join(os.homedir(), profileMap[profileKey]) : null
|
|
2534
2685
|
const marker = '# added by wadah setup-agent'
|
|
2535
|
-
const exportLine = `\nexport
|
|
2686
|
+
const exportLine = `\nexport WADAH_AGENT_TOKEN="${rawToken}" ${marker}\n`
|
|
2536
2687
|
|
|
2537
2688
|
if (opts.skipEnv || !profileFile) {
|
|
2538
2689
|
console.log(chalk.gray(' Skipping automatic profile write. Add this line manually:'))
|
|
2539
|
-
console.log(chalk.gray(` export
|
|
2690
|
+
console.log(chalk.gray(` export WADAH_AGENT_TOKEN="${rawToken}"`))
|
|
2540
2691
|
const rcGuess = shell.includes('zsh') ? '~/.zshrc' : shell.includes('fish') ? '~/.config/fish/config.fish' : '~/.bashrc'
|
|
2541
2692
|
console.log(chalk.gray(` Then reload: source ${rcGuess}`))
|
|
2542
2693
|
} else {
|
|
@@ -2546,7 +2697,7 @@ program
|
|
|
2546
2697
|
const existing = fs.existsSync(profileFile) ? fs.readFileSync(profileFile, 'utf8') : ''
|
|
2547
2698
|
const filtered = existing
|
|
2548
2699
|
.split('\n')
|
|
2549
|
-
.filter((line) => !line.includes('
|
|
2700
|
+
.filter((line) => !line.includes('WADAH_AGENT_TOKEN=') && !line.includes(marker))
|
|
2550
2701
|
.join('\n')
|
|
2551
2702
|
const next = `${filtered.trimEnd()}${exportLine}`
|
|
2552
2703
|
fs.writeFileSync(profileFile, `${next.endsWith('\n') ? next : `${next}\n`}`)
|
|
@@ -2554,10 +2705,10 @@ program
|
|
|
2554
2705
|
console.log(chalk.gray(` Reload now: source ${profileFile}`))
|
|
2555
2706
|
} catch (e) {
|
|
2556
2707
|
console.log(chalk.yellow(` ⚠ Could not write to ${profileFile}: ${e.message}`))
|
|
2557
|
-
console.log(chalk.gray(` Add manually: export
|
|
2708
|
+
console.log(chalk.gray(` Add manually: export WADAH_AGENT_TOKEN="${rawToken}"`))
|
|
2558
2709
|
}
|
|
2559
2710
|
} else {
|
|
2560
|
-
console.log(chalk.gray(` Skipped. Add manually: export
|
|
2711
|
+
console.log(chalk.gray(` Skipped. Add manually: export WADAH_AGENT_TOKEN="${rawToken}"`))
|
|
2561
2712
|
}
|
|
2562
2713
|
}
|
|
2563
2714
|
|
package/package.json
CHANGED
package/test/cli.test.js
CHANGED
|
@@ -11,7 +11,7 @@ function runCli(args) {
|
|
|
11
11
|
return new Promise((resolvePromise, reject) => {
|
|
12
12
|
const child = spawn(process.execPath, [cliPath, ...args], {
|
|
13
13
|
stdio: ['ignore', 'pipe', 'pipe'],
|
|
14
|
-
env: { ...process.env,
|
|
14
|
+
env: { ...process.env, WADAH_AGENT_TOKEN: '' },
|
|
15
15
|
})
|
|
16
16
|
let stdout = ''
|
|
17
17
|
let stderr = ''
|
|
@@ -47,6 +47,12 @@ test('wadah open --help shows open command help', async () => {
|
|
|
47
47
|
assert.match(stdout, /open|List/)
|
|
48
48
|
})
|
|
49
49
|
|
|
50
|
+
test('wadah link --help shows link subcommands', async () => {
|
|
51
|
+
const { code, stdout } = await runCli(['link', '--help'])
|
|
52
|
+
assert.equal(code, 0)
|
|
53
|
+
assert.match(stdout, /add|list|remove/)
|
|
54
|
+
})
|
|
55
|
+
|
|
50
56
|
test('wadah doctor runs without crashing', async () => {
|
|
51
57
|
const { code } = await runCli(['doctor'])
|
|
52
58
|
// Doctor may exit 0 or 1 depending on API/token; we only assert it doesn't throw
|