@dayzehq/cli 0.0.0-stage → 0.2.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 (57) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +305 -2
  3. package/dist/add.d.ts +6 -0
  4. package/dist/add.js +72 -0
  5. package/dist/admin.d.ts +110 -0
  6. package/dist/admin.js +408 -0
  7. package/dist/agent-bridge.d.ts +50 -0
  8. package/dist/agent-bridge.js +146 -0
  9. package/dist/agent-mcp.d.ts +4 -0
  10. package/dist/agent-mcp.js +36 -0
  11. package/dist/ai-consent.d.ts +18 -0
  12. package/dist/ai-consent.js +93 -0
  13. package/dist/args.d.ts +5 -0
  14. package/dist/args.js +127 -0
  15. package/dist/auth.d.ts +20 -0
  16. package/dist/auth.js +198 -0
  17. package/dist/channel.d.ts +55 -0
  18. package/dist/channel.js +250 -0
  19. package/dist/chat.d.ts +67 -0
  20. package/dist/chat.js +170 -0
  21. package/dist/cli-errors.d.ts +13 -0
  22. package/dist/cli-errors.js +30 -0
  23. package/dist/coding-context.d.ts +12 -0
  24. package/dist/coding-context.js +130 -0
  25. package/dist/coding.d.ts +35 -0
  26. package/dist/coding.js +283 -0
  27. package/dist/config.d.ts +36 -0
  28. package/dist/config.js +149 -0
  29. package/dist/day.d.ts +22 -0
  30. package/dist/day.js +54 -0
  31. package/dist/dayze-cli-runtime +0 -0
  32. package/dist/dayze-days.d.ts +56 -0
  33. package/dist/dayze-days.js +276 -0
  34. package/dist/doctor.d.ts +32 -0
  35. package/dist/doctor.js +225 -0
  36. package/dist/focus.d.ts +9 -0
  37. package/dist/focus.js +163 -0
  38. package/dist/index.d.ts +2 -0
  39. package/dist/index.js +675 -0
  40. package/dist/inventory.d.ts +73 -0
  41. package/dist/inventory.js +1272 -0
  42. package/dist/life.d.ts +48 -0
  43. package/dist/life.js +146 -0
  44. package/dist/me.d.ts +94 -0
  45. package/dist/me.js +789 -0
  46. package/dist/people.d.ts +232 -0
  47. package/dist/people.js +2034 -0
  48. package/dist/projects.d.ts +21 -0
  49. package/dist/projects.js +132 -0
  50. package/dist/request-deadline.d.ts +11 -0
  51. package/dist/request-deadline.js +34 -0
  52. package/dist/runtime-build.json +1 -0
  53. package/dist/ui.d.ts +37 -0
  54. package/dist/ui.js +219 -0
  55. package/dist/version.d.ts +4 -0
  56. package/dist/version.js +16 -0
  57. package/package.json +54 -4
package/dist/focus.js ADDED
@@ -0,0 +1,163 @@
1
+ /**
2
+ * CLI: dayze focus — show / set / done today's platform priorities.
3
+ */
4
+ import { authHeader } from './config.js';
5
+ import { printJson } from './cli-errors.js';
6
+ import * as ui from './ui.js';
7
+ import { CLI_USER_AGENT } from './version.js';
8
+ const FOCUS_READ_TIMEOUT_MS = 15_000;
9
+ async function fetchFocus(creds, date) {
10
+ const header = authHeader(creds);
11
+ if (!header)
12
+ throw new Error('Not logged in');
13
+ const q = date ? `?date=${encodeURIComponent(date)}` : '';
14
+ const controller = new AbortController();
15
+ const timeoutError = new Error('Loading Focus timed out after 15 seconds. Check your connection and retry dayze focus.');
16
+ let timer;
17
+ const deadline = new Promise((_, reject) => {
18
+ timer = setTimeout(() => {
19
+ reject(timeoutError);
20
+ controller.abort(timeoutError);
21
+ }, FOCUS_READ_TIMEOUT_MS);
22
+ });
23
+ try {
24
+ // Bound both headers and body reads, even if a fetch adapter ignores cancellation.
25
+ return await Promise.race([
26
+ (async () => {
27
+ const res = await fetch(`${creds.apiBase}/api/cli/focus${q}`, {
28
+ headers: { Authorization: header, Accept: 'application/json', 'User-Agent': CLI_USER_AGENT },
29
+ signal: controller.signal,
30
+ });
31
+ if (!res.ok) {
32
+ const text = await res.text().catch(() => '');
33
+ throw new Error(`Failed to load focus (${res.status}): ${text.slice(0, 200)}`);
34
+ }
35
+ return (await res.json());
36
+ })(),
37
+ deadline,
38
+ ]);
39
+ }
40
+ finally {
41
+ clearTimeout(timer);
42
+ }
43
+ }
44
+ async function putFocus(creds, body) {
45
+ const header = authHeader(creds);
46
+ if (!header)
47
+ throw new Error('Not logged in');
48
+ const res = await fetch(`${creds.apiBase}/api/cli/focus`, {
49
+ method: 'PUT',
50
+ headers: {
51
+ Authorization: header,
52
+ Accept: 'application/json',
53
+ 'Content-Type': 'application/json',
54
+ 'User-Agent': CLI_USER_AGENT,
55
+ },
56
+ body: JSON.stringify(body),
57
+ });
58
+ if (!res.ok) {
59
+ const text = await res.text().catch(() => '');
60
+ throw new Error(`Failed (${res.status}): ${text.slice(0, 240)}`);
61
+ }
62
+ return (await res.json());
63
+ }
64
+ function printFocus(date, items) {
65
+ console.log('');
66
+ console.log(`${ui.c.brandBold('◆ Focus')} ${ui.c.dim(date)}`);
67
+ if (items.length === 0) {
68
+ console.log(ui.c.dim(' (empty) — dayze focus add "Ship notable CTA" --bet=1'));
69
+ console.log('');
70
+ return;
71
+ }
72
+ items.forEach((it, i) => {
73
+ const mark = it.done ? ui.c.green('✓') : ui.c.dim('○');
74
+ const bet = it.bet != null ? ui.c.dim(` [bet ${it.bet}]`) : '';
75
+ console.log(` ${mark} ${i + 1}. ${it.done ? ui.c.dim(it.text) : it.text}${bet}`);
76
+ });
77
+ console.log('');
78
+ }
79
+ export function printFocusHelp() {
80
+ console.log(`
81
+ ${ui.c.brandBold('dayze focus')} ${ui.c.dim("— today's 1–3 platform priorities")}
82
+
83
+ dayze focus
84
+ dayze focus add "Improve notable signup CTA" --bet=1
85
+ dayze focus done 1
86
+ dayze focus clear
87
+
88
+ Bets: 1 content→signup · 2 Day Zero→W2 · 3 invite/share
89
+ `.trimEnd());
90
+ }
91
+ export async function runFocusCommand(creds, positional, options = {}) {
92
+ const json = Boolean(options.json);
93
+ const [head, ...rest] = positional;
94
+ if (!head || head === 'help' || head === '--help' || head === '-h') {
95
+ if (!head) {
96
+ const { date, items } = await fetchFocus(creds);
97
+ if (json) {
98
+ printJson(items);
99
+ return;
100
+ }
101
+ printFocus(date, items);
102
+ return;
103
+ }
104
+ printFocusHelp();
105
+ return;
106
+ }
107
+ if (head === 'list' || head === 'show') {
108
+ const { date, items } = await fetchFocus(creds);
109
+ if (json) {
110
+ printJson(items);
111
+ return;
112
+ }
113
+ printFocus(date, items);
114
+ return;
115
+ }
116
+ if (head === 'clear') {
117
+ const { date, items } = await putFocus(creds, { action: 'clear' });
118
+ ui.ok('Cleared focus');
119
+ printFocus(date, items);
120
+ return;
121
+ }
122
+ if (head === 'add') {
123
+ const betFlag = rest.find((a) => a.startsWith('--bet='));
124
+ const betRaw = betFlag?.split('=')[1];
125
+ const textParts = rest.filter((a) => !a.startsWith('--'));
126
+ const text = textParts.join(' ').trim();
127
+ if (!text) {
128
+ ui.err('Usage: dayze focus add "priority text" [--bet=1|2|3]');
129
+ process.exitCode = 1;
130
+ return;
131
+ }
132
+ const bet = betRaw === '1' || betRaw === '2' || betRaw === '3' ? Number(betRaw) : undefined;
133
+ const { date, items } = await putFocus(creds, {
134
+ action: 'add',
135
+ text,
136
+ ...(bet != null ? { bet } : {}),
137
+ });
138
+ ui.ok('Added');
139
+ printFocus(date, items);
140
+ return;
141
+ }
142
+ if (head === 'done') {
143
+ const idx = parseInt(rest[0] || '', 10);
144
+ if (!Number.isFinite(idx) || idx < 1) {
145
+ ui.err('Usage: dayze focus done <n>');
146
+ process.exitCode = 1;
147
+ return;
148
+ }
149
+ const { date, items } = await putFocus(creds, {
150
+ action: 'done',
151
+ index: idx - 1,
152
+ done: true,
153
+ });
154
+ ui.ok(`Marked #${idx} done`);
155
+ printFocus(date, items);
156
+ return;
157
+ }
158
+ // `dayze focus "text"` → add
159
+ const text = [head, ...rest].join(' ').trim();
160
+ const { date, items } = await putFocus(creds, { action: 'add', text });
161
+ ui.ok('Added');
162
+ printFocus(date, items);
163
+ }
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};