checkbox-cli 1.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.
- package/dist/checkbox.d.ts +25 -0
- package/dist/checkbox.js +207 -0
- package/package.json +43 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Checkbox CLI
|
|
4
|
+
*
|
|
5
|
+
* Command-line interface for the Checkbox capability API.
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* checkbox capabilities — list all capabilities
|
|
9
|
+
* checkbox command <type> <payload-json> [--org <id>] — execute a command
|
|
10
|
+
* checkbox query <type> <payload-json> --org <id> — execute a query
|
|
11
|
+
* checkbox workspace --org <id> — get workspace graph
|
|
12
|
+
* checkbox entities --org <id> [--type <t>] [--search <s>] — find entities
|
|
13
|
+
* checkbox schema --org <id> [--type <t>] — get entity schemas
|
|
14
|
+
* checkbox permissions --org <id> — check permissions
|
|
15
|
+
*
|
|
16
|
+
* Environment variables:
|
|
17
|
+
* CHECKBOX_API_URL — Base URL (default: https://checkbox.my)
|
|
18
|
+
* CHECKBOX_API_TOKEN — API key (ck_live_...) or Supabase JWT
|
|
19
|
+
*
|
|
20
|
+
* Get your API key:
|
|
21
|
+
* 1. Log in to checkbox.my
|
|
22
|
+
* 2. Go to Developer Hub (sidebar)
|
|
23
|
+
* 3. Create an API key — it never expires unless you set an expiry
|
|
24
|
+
*/
|
|
25
|
+
export {};
|
package/dist/checkbox.js
ADDED
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Checkbox CLI
|
|
4
|
+
*
|
|
5
|
+
* Command-line interface for the Checkbox capability API.
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* checkbox capabilities — list all capabilities
|
|
9
|
+
* checkbox command <type> <payload-json> [--org <id>] — execute a command
|
|
10
|
+
* checkbox query <type> <payload-json> --org <id> — execute a query
|
|
11
|
+
* checkbox workspace --org <id> — get workspace graph
|
|
12
|
+
* checkbox entities --org <id> [--type <t>] [--search <s>] — find entities
|
|
13
|
+
* checkbox schema --org <id> [--type <t>] — get entity schemas
|
|
14
|
+
* checkbox permissions --org <id> — check permissions
|
|
15
|
+
*
|
|
16
|
+
* Environment variables:
|
|
17
|
+
* CHECKBOX_API_URL — Base URL (default: https://checkbox.my)
|
|
18
|
+
* CHECKBOX_API_TOKEN — API key (ck_live_...) or Supabase JWT
|
|
19
|
+
*
|
|
20
|
+
* Get your API key:
|
|
21
|
+
* 1. Log in to checkbox.my
|
|
22
|
+
* 2. Go to Developer Hub (sidebar)
|
|
23
|
+
* 3. Create an API key — it never expires unless you set an expiry
|
|
24
|
+
*/
|
|
25
|
+
const API_URL = process.env.CHECKBOX_API_URL ?? 'https://checkbox.my';
|
|
26
|
+
const API_TOKEN = process.env.CHECKBOX_API_TOKEN ?? '';
|
|
27
|
+
function getHeaders() {
|
|
28
|
+
return {
|
|
29
|
+
'Content-Type': 'application/json',
|
|
30
|
+
...(API_TOKEN ? { Authorization: `Bearer ${API_TOKEN}` } : {}),
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
async function apiGet(path) {
|
|
34
|
+
const res = await fetch(`${API_URL}${path}`, { method: 'GET', headers: getHeaders() });
|
|
35
|
+
return res.json();
|
|
36
|
+
}
|
|
37
|
+
async function apiPost(path, body) {
|
|
38
|
+
const res = await fetch(`${API_URL}${path}`, {
|
|
39
|
+
method: 'POST',
|
|
40
|
+
headers: getHeaders(),
|
|
41
|
+
body: JSON.stringify(body),
|
|
42
|
+
});
|
|
43
|
+
return res.json();
|
|
44
|
+
}
|
|
45
|
+
function print(data) {
|
|
46
|
+
console.log(JSON.stringify(data, null, 2));
|
|
47
|
+
}
|
|
48
|
+
function fail(message) {
|
|
49
|
+
console.error(`Error: ${message}`);
|
|
50
|
+
process.exit(1);
|
|
51
|
+
}
|
|
52
|
+
function getFlag(args, flag) {
|
|
53
|
+
const idx = args.indexOf(flag);
|
|
54
|
+
if (idx === -1 || idx + 1 >= args.length)
|
|
55
|
+
return undefined;
|
|
56
|
+
return args[idx + 1];
|
|
57
|
+
}
|
|
58
|
+
// ── Subcommands ─────────────────────────────────────────────────────
|
|
59
|
+
async function cmdCapabilities() {
|
|
60
|
+
print(await apiGet('/api/v2/introspection/capabilities'));
|
|
61
|
+
}
|
|
62
|
+
async function cmdCommand(args) {
|
|
63
|
+
const type = args[0];
|
|
64
|
+
const payloadRaw = args[1];
|
|
65
|
+
if (!type)
|
|
66
|
+
fail('Usage: checkbox command <type> <payload-json> [--org <id>]');
|
|
67
|
+
const payload = payloadRaw ? JSON.parse(payloadRaw) : {};
|
|
68
|
+
const orgId = getFlag(args, '--org');
|
|
69
|
+
const body = { type, payload };
|
|
70
|
+
if (orgId)
|
|
71
|
+
body.organization_id = orgId;
|
|
72
|
+
print(await apiPost('/api/v2/commands', body));
|
|
73
|
+
}
|
|
74
|
+
async function cmdQuery(args) {
|
|
75
|
+
const type = args[0];
|
|
76
|
+
const payloadRaw = args[1];
|
|
77
|
+
const orgId = getFlag(args, '--org');
|
|
78
|
+
if (!type || !orgId)
|
|
79
|
+
fail('Usage: checkbox query <type> <payload-json> --org <id>');
|
|
80
|
+
const payload = payloadRaw ? JSON.parse(payloadRaw) : {};
|
|
81
|
+
print(await apiPost('/api/v2/query', {
|
|
82
|
+
type,
|
|
83
|
+
organization_id: orgId,
|
|
84
|
+
payload: { ...payload, organization_id: orgId },
|
|
85
|
+
}));
|
|
86
|
+
}
|
|
87
|
+
async function cmdWorkspace(args) {
|
|
88
|
+
const orgId = getFlag(args, '--org');
|
|
89
|
+
if (!orgId)
|
|
90
|
+
fail('Usage: checkbox workspace --org <id>');
|
|
91
|
+
print(await apiPost('/api/v2/introspection/workspace', { organization_id: orgId }));
|
|
92
|
+
}
|
|
93
|
+
async function cmdEntities(args) {
|
|
94
|
+
const orgId = getFlag(args, '--org');
|
|
95
|
+
if (!orgId)
|
|
96
|
+
fail('Usage: checkbox entities --org <id> [--type <t>] [--search <s>]');
|
|
97
|
+
const entityType = getFlag(args, '--type');
|
|
98
|
+
const search = getFlag(args, '--search');
|
|
99
|
+
const limit = getFlag(args, '--limit');
|
|
100
|
+
print(await apiPost('/api/v2/introspection/entities', {
|
|
101
|
+
organization_id: orgId,
|
|
102
|
+
entity_type: entityType,
|
|
103
|
+
search,
|
|
104
|
+
limit: limit ? parseInt(limit, 10) : undefined,
|
|
105
|
+
}));
|
|
106
|
+
}
|
|
107
|
+
async function cmdSchema(args) {
|
|
108
|
+
const orgId = getFlag(args, '--org');
|
|
109
|
+
if (!orgId)
|
|
110
|
+
fail('Usage: checkbox schema --org <id> [--type <t>] [--entity-id <id>]');
|
|
111
|
+
const entityType = getFlag(args, '--type');
|
|
112
|
+
const entityId = getFlag(args, '--entity-id');
|
|
113
|
+
print(await apiPost('/api/v2/introspection/schema', {
|
|
114
|
+
organization_id: orgId,
|
|
115
|
+
entity_type: entityType,
|
|
116
|
+
entity_id: entityId,
|
|
117
|
+
}));
|
|
118
|
+
}
|
|
119
|
+
async function cmdPermissions(args) {
|
|
120
|
+
const orgId = getFlag(args, '--org');
|
|
121
|
+
if (!orgId)
|
|
122
|
+
fail('Usage: checkbox permissions --org <id>');
|
|
123
|
+
print(await apiPost('/api/v2/introspection/permissions', { organization_id: orgId }));
|
|
124
|
+
}
|
|
125
|
+
async function cmdOrganizations() {
|
|
126
|
+
print(await apiPost('/api/v2/query', {
|
|
127
|
+
type: 'list_my_organizations',
|
|
128
|
+
payload: {},
|
|
129
|
+
}));
|
|
130
|
+
}
|
|
131
|
+
function printUsage() {
|
|
132
|
+
console.log(`Checkbox CLI — interact with the Checkbox capability API
|
|
133
|
+
|
|
134
|
+
Usage:
|
|
135
|
+
checkbox orgs List your organizations
|
|
136
|
+
checkbox capabilities List all capabilities
|
|
137
|
+
checkbox command <type> [payload-json] [--org <id>] Execute a command
|
|
138
|
+
checkbox query <type> [payload-json] --org <id> Execute a query
|
|
139
|
+
checkbox workspace --org <id> Get workspace graph
|
|
140
|
+
checkbox entities --org <id> [--type <t>] [--search <s>] Find entities
|
|
141
|
+
checkbox schema --org <id> [--type <t>] Get entity schemas
|
|
142
|
+
checkbox permissions --org <id> Check permissions
|
|
143
|
+
|
|
144
|
+
Environment:
|
|
145
|
+
CHECKBOX_API_URL Base URL (default: https://checkbox.my)
|
|
146
|
+
CHECKBOX_API_TOKEN API key (ck_live_...) or Supabase JWT
|
|
147
|
+
|
|
148
|
+
Get your API key:
|
|
149
|
+
1. Log in to checkbox.my
|
|
150
|
+
2. Go to Developer Hub (sidebar)
|
|
151
|
+
3. Create an API key — it never expires unless you configure an expiry
|
|
152
|
+
|
|
153
|
+
Examples:
|
|
154
|
+
export CHECKBOX_API_TOKEN="ck_live_your_key_here"
|
|
155
|
+
|
|
156
|
+
checkbox orgs
|
|
157
|
+
checkbox capabilities
|
|
158
|
+
checkbox command create_plan '{"name":"Q2 Safety"}' --org <org-id>
|
|
159
|
+
checkbox command complete_task '{"task_id":"abc-123"}' --org <org-id>
|
|
160
|
+
checkbox query get_task_states '{"date":"2026-03-12"}' --org <org-id>
|
|
161
|
+
checkbox entities --org <org-id> --type task --search "Daily check"
|
|
162
|
+
`);
|
|
163
|
+
}
|
|
164
|
+
// ── Main ────────────────────────────────────────────────────────────
|
|
165
|
+
async function main() {
|
|
166
|
+
const args = process.argv.slice(2);
|
|
167
|
+
const sub = args[0];
|
|
168
|
+
const rest = args.slice(1);
|
|
169
|
+
if (!API_TOKEN && sub !== undefined && sub !== 'help' && sub !== '--help') {
|
|
170
|
+
console.error('Warning: CHECKBOX_API_TOKEN is not set. Authenticated requests will fail.');
|
|
171
|
+
console.error('Get an API key: log in to checkbox.my → Developer Hub → Create Key\n');
|
|
172
|
+
}
|
|
173
|
+
switch (sub) {
|
|
174
|
+
case 'orgs':
|
|
175
|
+
case 'organizations':
|
|
176
|
+
return cmdOrganizations();
|
|
177
|
+
case 'capabilities':
|
|
178
|
+
return cmdCapabilities();
|
|
179
|
+
case 'command':
|
|
180
|
+
case 'cmd':
|
|
181
|
+
return cmdCommand(rest);
|
|
182
|
+
case 'query':
|
|
183
|
+
return cmdQuery(rest);
|
|
184
|
+
case 'workspace':
|
|
185
|
+
return cmdWorkspace(rest);
|
|
186
|
+
case 'entities':
|
|
187
|
+
return cmdEntities(rest);
|
|
188
|
+
case 'schema':
|
|
189
|
+
return cmdSchema(rest);
|
|
190
|
+
case 'permissions':
|
|
191
|
+
return cmdPermissions(rest);
|
|
192
|
+
case 'help':
|
|
193
|
+
case '--help':
|
|
194
|
+
case '-h':
|
|
195
|
+
case undefined:
|
|
196
|
+
return printUsage();
|
|
197
|
+
default:
|
|
198
|
+
console.error(`Unknown subcommand: ${sub}\n`);
|
|
199
|
+
printUsage();
|
|
200
|
+
process.exit(1);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
main().catch((err) => {
|
|
204
|
+
console.error('Fatal:', err);
|
|
205
|
+
process.exit(1);
|
|
206
|
+
});
|
|
207
|
+
export {};
|
package/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "checkbox-cli",
|
|
3
|
+
"version": "1.1.0",
|
|
4
|
+
"description": "CLI for the Checkbox capability API — create compliance plans, manage tasks, query workspaces, and automate from the terminal.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/checkbox.js",
|
|
7
|
+
"bin": {
|
|
8
|
+
"checkbox": "dist/checkbox.js"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"dist"
|
|
12
|
+
],
|
|
13
|
+
"scripts": {
|
|
14
|
+
"build": "tsc",
|
|
15
|
+
"prepublishOnly": "tsc",
|
|
16
|
+
"start": "node dist/checkbox.js",
|
|
17
|
+
"dev": "tsx src/checkbox.ts"
|
|
18
|
+
},
|
|
19
|
+
"keywords": [
|
|
20
|
+
"checkbox",
|
|
21
|
+
"compliance",
|
|
22
|
+
"cli",
|
|
23
|
+
"automation",
|
|
24
|
+
"task-management",
|
|
25
|
+
"ai-agent"
|
|
26
|
+
],
|
|
27
|
+
"author": "Checkbox <hello@checkbox.my>",
|
|
28
|
+
"license": "MIT",
|
|
29
|
+
"repository": {
|
|
30
|
+
"type": "git",
|
|
31
|
+
"url": "https://github.com/fadhelcarlos/checkbox.git",
|
|
32
|
+
"directory": "cli"
|
|
33
|
+
},
|
|
34
|
+
"homepage": "https://checkbox.my",
|
|
35
|
+
"engines": {
|
|
36
|
+
"node": ">=18.0.0"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"typescript": "^5.7.0",
|
|
40
|
+
"tsx": "^4.19.0",
|
|
41
|
+
"@types/node": "^22.0.0"
|
|
42
|
+
}
|
|
43
|
+
}
|