@agentuity/cli 2.0.6 → 2.0.8

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 (201) hide show
  1. package/README.md +11 -0
  2. package/dist/cli.d.ts.map +1 -1
  3. package/dist/cli.js +4 -2
  4. package/dist/cli.js.map +1 -1
  5. package/dist/cmd/build/vite/route-discovery.d.ts.map +1 -1
  6. package/dist/cmd/build/vite/route-discovery.js +6 -0
  7. package/dist/cmd/build/vite/route-discovery.js.map +1 -1
  8. package/dist/cmd/cloud/sandbox/fs/rm.d.ts.map +1 -1
  9. package/dist/cmd/cloud/sandbox/fs/rm.js +9 -3
  10. package/dist/cmd/cloud/sandbox/fs/rm.js.map +1 -1
  11. package/dist/cmd/cloud/sandbox/fs/rmdir.d.ts.map +1 -1
  12. package/dist/cmd/cloud/sandbox/fs/rmdir.js +9 -3
  13. package/dist/cmd/cloud/sandbox/fs/rmdir.js.map +1 -1
  14. package/dist/cmd/cloud/task/close.d.ts +3 -0
  15. package/dist/cmd/cloud/task/close.d.ts.map +1 -0
  16. package/dist/cmd/cloud/task/close.js +286 -0
  17. package/dist/cmd/cloud/task/close.js.map +1 -0
  18. package/dist/cmd/cloud/task/delete.d.ts +1 -5
  19. package/dist/cmd/cloud/task/delete.d.ts.map +1 -1
  20. package/dist/cmd/cloud/task/delete.js +15 -38
  21. package/dist/cmd/cloud/task/delete.js.map +1 -1
  22. package/dist/cmd/cloud/task/index.d.ts.map +1 -1
  23. package/dist/cmd/cloud/task/index.js +10 -0
  24. package/dist/cmd/cloud/task/index.js.map +1 -1
  25. package/dist/cmd/cloud/task/list.d.ts.map +1 -1
  26. package/dist/cmd/cloud/task/list.js +97 -3
  27. package/dist/cmd/cloud/task/list.js.map +1 -1
  28. package/dist/cmd/cloud/task/util.d.ts +10 -0
  29. package/dist/cmd/cloud/task/util.d.ts.map +1 -1
  30. package/dist/cmd/cloud/task/util.js +47 -3
  31. package/dist/cmd/cloud/task/util.js.map +1 -1
  32. package/dist/cmd/coder/archive.d.ts +2 -0
  33. package/dist/cmd/coder/archive.d.ts.map +1 -0
  34. package/dist/cmd/coder/archive.js +57 -0
  35. package/dist/cmd/coder/archive.js.map +1 -0
  36. package/dist/cmd/coder/create.d.ts +2 -0
  37. package/dist/cmd/coder/create.d.ts.map +1 -0
  38. package/dist/cmd/coder/create.js +245 -0
  39. package/dist/cmd/coder/create.js.map +1 -0
  40. package/dist/cmd/coder/delete.d.ts +2 -0
  41. package/dist/cmd/coder/delete.d.ts.map +1 -0
  42. package/dist/cmd/coder/delete.js +64 -0
  43. package/dist/cmd/coder/delete.js.map +1 -0
  44. package/dist/cmd/coder/events.d.ts +2 -0
  45. package/dist/cmd/coder/events.d.ts.map +1 -0
  46. package/dist/cmd/coder/events.js +99 -0
  47. package/dist/cmd/coder/events.js.map +1 -0
  48. package/dist/cmd/coder/extension-path.d.ts +8 -0
  49. package/dist/cmd/coder/extension-path.d.ts.map +1 -0
  50. package/dist/cmd/coder/extension-path.js +59 -0
  51. package/dist/cmd/coder/extension-path.js.map +1 -0
  52. package/dist/cmd/coder/get.d.ts +2 -0
  53. package/dist/cmd/coder/get.d.ts.map +1 -0
  54. package/dist/cmd/coder/{inspect.js → get.js} +37 -33
  55. package/dist/cmd/coder/get.js.map +1 -0
  56. package/dist/cmd/coder/index.d.ts.map +1 -1
  57. package/dist/cmd/coder/index.js +54 -4
  58. package/dist/cmd/coder/index.js.map +1 -1
  59. package/dist/cmd/coder/list.d.ts.map +1 -1
  60. package/dist/cmd/coder/list.js +25 -34
  61. package/dist/cmd/coder/list.js.map +1 -1
  62. package/dist/cmd/coder/loop.d.ts +2 -0
  63. package/dist/cmd/coder/loop.d.ts.map +1 -0
  64. package/dist/cmd/coder/loop.js +78 -0
  65. package/dist/cmd/coder/loop.js.map +1 -0
  66. package/dist/cmd/coder/participants.d.ts +2 -0
  67. package/dist/cmd/coder/participants.d.ts.map +1 -0
  68. package/dist/cmd/coder/participants.js +93 -0
  69. package/dist/cmd/coder/participants.js.map +1 -0
  70. package/dist/cmd/coder/replay.d.ts +2 -0
  71. package/dist/cmd/coder/replay.d.ts.map +1 -0
  72. package/dist/cmd/coder/replay.js +53 -0
  73. package/dist/cmd/coder/replay.js.map +1 -0
  74. package/dist/cmd/coder/resolve-repo.d.ts +27 -0
  75. package/dist/cmd/coder/resolve-repo.d.ts.map +1 -0
  76. package/dist/cmd/coder/resolve-repo.js +97 -0
  77. package/dist/cmd/coder/resolve-repo.js.map +1 -0
  78. package/dist/cmd/coder/skill/buckets.d.ts +2 -0
  79. package/dist/cmd/coder/skill/buckets.d.ts.map +1 -0
  80. package/dist/cmd/coder/skill/buckets.js +174 -0
  81. package/dist/cmd/coder/skill/buckets.js.map +1 -0
  82. package/dist/cmd/coder/skill/delete.d.ts +2 -0
  83. package/dist/cmd/coder/skill/delete.d.ts.map +1 -0
  84. package/dist/cmd/coder/skill/delete.js +64 -0
  85. package/dist/cmd/coder/skill/delete.js.map +1 -0
  86. package/dist/cmd/coder/skill/index.d.ts +2 -0
  87. package/dist/cmd/coder/skill/index.d.ts.map +1 -0
  88. package/dist/cmd/coder/skill/index.js +33 -0
  89. package/dist/cmd/coder/skill/index.js.map +1 -0
  90. package/dist/cmd/coder/skill/list.d.ts +2 -0
  91. package/dist/cmd/coder/skill/list.d.ts.map +1 -0
  92. package/dist/cmd/coder/skill/list.js +93 -0
  93. package/dist/cmd/coder/skill/list.js.map +1 -0
  94. package/dist/cmd/coder/skill/save.d.ts +2 -0
  95. package/dist/cmd/coder/skill/save.d.ts.map +1 -0
  96. package/dist/cmd/coder/skill/save.js +77 -0
  97. package/dist/cmd/coder/skill/save.js.map +1 -0
  98. package/dist/cmd/coder/start.d.ts.map +1 -1
  99. package/dist/cmd/coder/start.js +88 -117
  100. package/dist/cmd/coder/start.js.map +1 -1
  101. package/dist/cmd/coder/tui-init.d.ts +4 -1
  102. package/dist/cmd/coder/tui-init.d.ts.map +1 -1
  103. package/dist/cmd/coder/tui-init.js +9 -3
  104. package/dist/cmd/coder/tui-init.js.map +1 -1
  105. package/dist/cmd/coder/update.d.ts +2 -0
  106. package/dist/cmd/coder/update.d.ts.map +1 -0
  107. package/dist/cmd/coder/update.js +126 -0
  108. package/dist/cmd/coder/update.js.map +1 -0
  109. package/dist/cmd/coder/users.d.ts +2 -0
  110. package/dist/cmd/coder/users.d.ts.map +1 -0
  111. package/dist/cmd/coder/users.js +97 -0
  112. package/dist/cmd/coder/users.js.map +1 -0
  113. package/dist/cmd/coder/workspace/create.d.ts +2 -0
  114. package/dist/cmd/coder/workspace/create.d.ts.map +1 -0
  115. package/dist/cmd/coder/workspace/create.js +97 -0
  116. package/dist/cmd/coder/workspace/create.js.map +1 -0
  117. package/dist/cmd/coder/workspace/delete.d.ts +2 -0
  118. package/dist/cmd/coder/workspace/delete.d.ts.map +1 -0
  119. package/dist/cmd/coder/workspace/delete.js +64 -0
  120. package/dist/cmd/coder/workspace/delete.js.map +1 -0
  121. package/dist/cmd/coder/workspace/get.d.ts +2 -0
  122. package/dist/cmd/coder/workspace/get.d.ts.map +1 -0
  123. package/dist/cmd/coder/workspace/get.js +109 -0
  124. package/dist/cmd/coder/workspace/get.js.map +1 -0
  125. package/dist/cmd/coder/workspace/index.d.ts +2 -0
  126. package/dist/cmd/coder/workspace/index.d.ts.map +1 -0
  127. package/dist/cmd/coder/workspace/index.js +38 -0
  128. package/dist/cmd/coder/workspace/index.js.map +1 -0
  129. package/dist/cmd/coder/workspace/list.d.ts +2 -0
  130. package/dist/cmd/coder/workspace/list.d.ts.map +1 -0
  131. package/dist/cmd/coder/workspace/list.js +93 -0
  132. package/dist/cmd/coder/workspace/list.js.map +1 -0
  133. package/dist/cmd/dev/sync.js +5 -5
  134. package/dist/cmd/dev/sync.js.map +1 -1
  135. package/dist/coder-hub-url.d.ts +3 -0
  136. package/dist/coder-hub-url.d.ts.map +1 -0
  137. package/dist/coder-hub-url.js +32 -0
  138. package/dist/coder-hub-url.js.map +1 -0
  139. package/dist/config.d.ts +1 -0
  140. package/dist/config.d.ts.map +1 -1
  141. package/dist/config.js +14 -3
  142. package/dist/config.js.map +1 -1
  143. package/dist/internal-logger.d.ts +4 -0
  144. package/dist/internal-logger.d.ts.map +1 -1
  145. package/dist/internal-logger.js +64 -2
  146. package/dist/internal-logger.js.map +1 -1
  147. package/dist/keychain.d.ts +3 -0
  148. package/dist/keychain.d.ts.map +1 -1
  149. package/dist/keychain.js +47 -28
  150. package/dist/keychain.js.map +1 -1
  151. package/dist/types.d.ts +1 -1
  152. package/package.json +7 -6
  153. package/src/cli.ts +4 -2
  154. package/src/cmd/ai/prompt/agent.md +6 -6
  155. package/src/cmd/build/vite/route-discovery.ts +8 -0
  156. package/src/cmd/cloud/sandbox/fs/rm.ts +8 -3
  157. package/src/cmd/cloud/sandbox/fs/rmdir.ts +8 -3
  158. package/src/cmd/cloud/task/close.ts +319 -0
  159. package/src/cmd/cloud/task/delete.ts +15 -43
  160. package/src/cmd/cloud/task/index.ts +10 -0
  161. package/src/cmd/cloud/task/list.ts +111 -4
  162. package/src/cmd/cloud/task/util.ts +59 -5
  163. package/src/cmd/coder/archive.ts +59 -0
  164. package/src/cmd/coder/create.ts +268 -0
  165. package/src/cmd/coder/delete.ts +67 -0
  166. package/src/cmd/coder/events.ts +106 -0
  167. package/src/cmd/coder/extension-path.ts +71 -0
  168. package/src/cmd/coder/{inspect.ts → get.ts} +44 -45
  169. package/src/cmd/coder/index.ts +54 -4
  170. package/src/cmd/coder/list.ts +28 -65
  171. package/src/cmd/coder/loop.ts +85 -0
  172. package/src/cmd/coder/participants.ts +100 -0
  173. package/src/cmd/coder/replay.ts +58 -0
  174. package/src/cmd/coder/resolve-repo.ts +119 -0
  175. package/src/cmd/coder/skill/buckets.ts +191 -0
  176. package/src/cmd/coder/skill/delete.ts +67 -0
  177. package/src/cmd/coder/skill/index.ts +35 -0
  178. package/src/cmd/coder/skill/list.ts +97 -0
  179. package/src/cmd/coder/skill/save.ts +84 -0
  180. package/src/cmd/coder/start.ts +104 -141
  181. package/src/cmd/coder/tui-init.ts +13 -4
  182. package/src/cmd/coder/update.ts +128 -0
  183. package/src/cmd/coder/users.ts +101 -0
  184. package/src/cmd/coder/workspace/create.ts +104 -0
  185. package/src/cmd/coder/workspace/delete.ts +70 -0
  186. package/src/cmd/coder/workspace/get.ts +112 -0
  187. package/src/cmd/coder/workspace/index.ts +38 -0
  188. package/src/cmd/coder/workspace/list.ts +101 -0
  189. package/src/cmd/dev/sync.ts +5 -5
  190. package/src/coder-hub-url.ts +32 -0
  191. package/src/config.ts +17 -3
  192. package/src/internal-logger.ts +83 -2
  193. package/src/keychain.ts +68 -39
  194. package/dist/cmd/coder/hub-url.d.ts +0 -36
  195. package/dist/cmd/coder/hub-url.d.ts.map +0 -1
  196. package/dist/cmd/coder/hub-url.js +0 -106
  197. package/dist/cmd/coder/hub-url.js.map +0 -1
  198. package/dist/cmd/coder/inspect.d.ts +0 -2
  199. package/dist/cmd/coder/inspect.d.ts.map +0 -1
  200. package/dist/cmd/coder/inspect.js.map +0 -1
  201. package/src/cmd/coder/hub-url.ts +0 -111
@@ -1,46 +1,13 @@
1
1
  import { z } from 'zod';
2
2
  import { createCommand } from '../../../types';
3
3
  import * as tui from '../../../tui';
4
- import { createStorageAdapter } from './util';
4
+ import { createStorageAdapter, resolveMeId, parseDuration, truncate } from './util';
5
5
  import { getCommand } from '../../../command-prefix';
6
6
  import { isDryRunMode, outputDryRun } from '../../../explain';
7
7
  import type { TaskPriority, TaskStatus, TaskType, BatchDeletedTask } from '@agentuity/core';
8
8
 
9
- const DURATION_UNITS: Record<string, number> = {
10
- s: 1000,
11
- m: 60 * 1000,
12
- h: 60 * 60 * 1000,
13
- d: 24 * 60 * 60 * 1000,
14
- w: 7 * 24 * 60 * 60 * 1000,
15
- };
16
-
17
- /**
18
- * Parse a human-friendly duration string (e.g. "30s", "7d", "24h", "30m", "2w")
19
- * into milliseconds. Exported for testing.
20
- */
21
- export function parseDuration(duration: string): number {
22
- const match = duration.match(/^(\d+)([smhdw])$/);
23
- if (!match) {
24
- tui.fatal(
25
- `Invalid duration format: "${duration}". Use a number followed by s (seconds), m (minutes), h (hours), d (days), or w (weeks). Examples: 30s, 30m, 24h, 7d, 2w`
26
- );
27
- // tui.fatal exits, but TypeScript doesn't know that
28
- throw new Error('unreachable');
29
- }
30
- const value = parseInt(match[1]!, 10);
31
- const unit = match[2]!;
32
- const ms = DURATION_UNITS[unit];
33
- if (!ms) {
34
- tui.fatal(`Unknown duration unit: "${unit}"`);
35
- throw new Error('unreachable');
36
- }
37
- return value * ms;
38
- }
39
-
40
- function truncate(s: string, max: number): string {
41
- if (s.length <= max) return s;
42
- return `${s.slice(0, max - 1)}…`;
43
- }
9
+ // Re-export for testing
10
+ export { parseDuration } from './util';
44
11
 
45
12
  const TaskDeleteResponseSchema = z.object({
46
13
  success: z.boolean().describe('Whether the operation succeeded'),
@@ -104,7 +71,16 @@ export const deleteSubcommand = createCommand({
104
71
  .optional()
105
72
  .describe('filter batch delete by age (e.g. 30s, 7d, 24h, 2w)'),
106
73
  parentId: z.string().optional().describe('filter batch delete by parent task ID'),
107
- createdId: z.string().optional().describe('filter batch delete by creator ID'),
74
+ createdId: z
75
+ .string()
76
+ .optional()
77
+ .describe('filter batch delete by creator ID (use "me" for current user)'),
78
+ orgId: z.string().optional().describe('organization ID (uses default if not specified)'),
79
+ dryRun: z
80
+ .boolean()
81
+ .optional()
82
+ .default(false)
83
+ .describe('preview changes without executing'),
108
84
  limit: z.coerce
109
85
  .number()
110
86
  .int()
@@ -198,7 +174,7 @@ export const deleteSubcommand = createCommand({
198
174
  type: opts.type as TaskType | undefined,
199
175
  priority: opts.priority as TaskPriority | undefined,
200
176
  parent_id: opts.parentId,
201
- created_id: opts.createdId,
177
+ created_id: resolveMeId(opts.createdId, ctx),
202
178
  older_than: opts.olderThan,
203
179
  limit: opts.limit,
204
180
  };
@@ -212,6 +188,7 @@ export const deleteSubcommand = createCommand({
212
188
  type: batchParams.type,
213
189
  priority: batchParams.priority,
214
190
  parent_id: batchParams.parent_id,
191
+ created_id: batchParams.created_id,
215
192
  limit: batchParams.limit,
216
193
  sort: 'created_at',
217
194
  order: 'asc',
@@ -219,11 +196,6 @@ export const deleteSubcommand = createCommand({
219
196
 
220
197
  // Client-side filters for preview (server will apply these on actual delete)
221
198
  let candidates = preview.tasks;
222
- if (batchParams.created_id) {
223
- candidates = candidates.filter(
224
- (t: { created_id: string }) => t.created_id === batchParams.created_id
225
- );
226
- }
227
199
  if (opts.olderThan) {
228
200
  const durationMs = parseDuration(opts.olderThan);
229
201
  const cutoff = new Date(Date.now() - durationMs);
@@ -4,6 +4,7 @@ import { createSubcommand } from './create';
4
4
  import { updateSubcommand } from './update';
5
5
  import { listSubcommand } from './list';
6
6
  import { deleteSubcommand } from './delete';
7
+ import { closeSubcommand } from './close';
7
8
  import { statsSubcommand } from './stats';
8
9
  import { attachmentSubcommand } from './attachment';
9
10
  import { userSubcommand } from './user';
@@ -36,6 +37,14 @@ export const taskCommand = createCommand({
36
37
  command: getCommand('cloud task delete task_abc123'),
37
38
  description: 'Delete a task by ID',
38
39
  },
40
+ {
41
+ command: getCommand('cloud task close task_abc123'),
42
+ description: 'Close a task by ID',
43
+ },
44
+ {
45
+ command: getCommand('cloud task close --status done --older-than 7d'),
46
+ description: 'Batch close done tasks older than 7 days',
47
+ },
39
48
  {
40
49
  command: getCommand('cloud task delete --status done --older-than 7d'),
41
50
  description: 'Batch delete done tasks older than 7 days',
@@ -59,6 +68,7 @@ export const taskCommand = createCommand({
59
68
  updateSubcommand,
60
69
  listSubcommand,
61
70
  deleteSubcommand,
71
+ closeSubcommand,
62
72
  statsSubcommand,
63
73
  attachmentSubcommand,
64
74
  userSubcommand,
@@ -1,9 +1,9 @@
1
1
  import { z } from 'zod';
2
2
  import { createCommand } from '../../../types';
3
3
  import * as tui from '../../../tui';
4
- import { createStorageAdapter } from './util';
4
+ import { createStorageAdapter, resolveMeId } from './util';
5
5
  import { getCommand } from '../../../command-prefix';
6
- import type { TaskPriority, TaskStatus, TaskType, Task } from '@agentuity/core';
6
+ import type { TaskPriority, TaskStatus, TaskType, Task, TaskIncludeField } from '@agentuity/core';
7
7
 
8
8
  const TaskListResponseSchema = z.object({
9
9
  success: z.boolean().describe('Whether the operation succeeded'),
@@ -14,6 +14,12 @@ const TaskListResponseSchema = z.object({
14
14
  type: z.string(),
15
15
  status: z.string(),
16
16
  priority: z.string(),
17
+ description: z.string().optional(),
18
+ metadata: z.record(z.string(), z.unknown()).optional(),
19
+ tags: z.array(z.object({ id: z.string(), name: z.string() })).optional(),
20
+ subtask_count: z.number().optional(),
21
+ created_id: z.string().optional(),
22
+ deleted: z.boolean().optional(),
17
23
  creator: z
18
24
  .object({
19
25
  id: z.string(),
@@ -73,6 +79,38 @@ function truncate(s: string, max: number): string {
73
79
  return `${s.slice(0, max - 1)}…`;
74
80
  }
75
81
 
82
+ const VALID_INCLUDE_FIELDS = new Set<TaskIncludeField>([
83
+ 'description',
84
+ 'metadata',
85
+ 'tags',
86
+ 'subtask_count',
87
+ 'created_id',
88
+ 'deleted',
89
+ ]);
90
+
91
+ function parseIncludeParam(include: string | undefined): TaskIncludeField[] | undefined {
92
+ if (!include) return undefined;
93
+ const fields: TaskIncludeField[] = [];
94
+ for (const f of include.split(',')) {
95
+ const trimmed = f.trim() as TaskIncludeField;
96
+ if (VALID_INCLUDE_FIELDS.has(trimmed)) {
97
+ fields.push(trimmed);
98
+ } else {
99
+ tui.fatal(
100
+ `Invalid include field: "${trimmed}". Valid fields are: ${[...VALID_INCLUDE_FIELDS].join(', ')}`
101
+ );
102
+ }
103
+ }
104
+ return fields.length > 0 ? fields : undefined;
105
+ }
106
+
107
+ function hasIncludeField(
108
+ include: TaskIncludeField[] | undefined,
109
+ field: TaskIncludeField
110
+ ): boolean {
111
+ return include?.includes(field) ?? false;
112
+ }
113
+
76
114
  export const listSubcommand = createCommand({
77
115
  name: 'list',
78
116
  aliases: ['ls'],
@@ -103,6 +141,14 @@ export const listSubcommand = createCommand({
103
141
  command: getCommand('cloud task list --assigned-id agent_001 --limit 10'),
104
142
  description: 'List first 10 tasks assigned to an agent',
105
143
  },
144
+ {
145
+ command: getCommand('cloud task list --created-id me --include description,metadata,tags'),
146
+ description: 'List tasks created by me with full details',
147
+ },
148
+ {
149
+ command: getCommand('cloud task list --project-id proj_abc123'),
150
+ description: 'List tasks for a specific project',
151
+ },
106
152
  ],
107
153
  schema: {
108
154
  options: z.object({
@@ -118,8 +164,24 @@ export const listSubcommand = createCommand({
118
164
  .enum(['high', 'medium', 'low', 'none'])
119
165
  .optional()
120
166
  .describe('filter by priority'),
121
- assignedId: z.string().optional().describe('filter by assigned agent or user ID'),
167
+ assignedId: z
168
+ .string()
169
+ .optional()
170
+ .describe('filter by assigned agent or user ID (use "me" for current user)'),
171
+ createdId: z
172
+ .string()
173
+ .optional()
174
+ .describe('filter by creator ID (use "me" for current user)'),
122
175
  parentId: z.string().optional().describe('filter by parent task ID'),
176
+ projectId: z.string().optional().describe('filter by project ID'),
177
+ tagId: z.string().optional().describe('filter by tag ID'),
178
+ deleted: z.boolean().optional().describe('include soft-deleted tasks'),
179
+ include: z
180
+ .string()
181
+ .optional()
182
+ .describe(
183
+ 'comma-separated fields to include: description,metadata,tags,subtask_count,created_id,deleted'
184
+ ),
123
185
  sort: z
124
186
  .enum(['created_at', 'updated_at', 'priority'])
125
187
  .optional()
@@ -127,6 +189,7 @@ export const listSubcommand = createCommand({
127
189
  order: z.enum(['asc', 'desc']).optional().describe('sort order (default: desc)'),
128
190
  limit: z.coerce.number().optional().describe('max results to return (default: 50)'),
129
191
  offset: z.coerce.number().optional().describe('offset for pagination'),
192
+ orgId: z.string().optional().describe('organization ID (uses default if not specified)'),
130
193
  }),
131
194
  response: TaskListResponseSchema,
132
195
  },
@@ -136,12 +199,22 @@ export const listSubcommand = createCommand({
136
199
  const started = Date.now();
137
200
  const storage = await createStorageAdapter(ctx);
138
201
 
202
+ const createdId = resolveMeId(opts.createdId, ctx);
203
+ const assignedId = resolveMeId(opts.assignedId, ctx);
204
+
205
+ const includeFields = parseIncludeParam(opts.include);
206
+
139
207
  const result = await storage.list({
140
208
  status: opts.status as TaskStatus | undefined,
141
209
  type: opts.type as TaskType | undefined,
142
210
  priority: opts.priority as TaskPriority | undefined,
143
- assigned_id: opts.assignedId,
211
+ assigned_id: assignedId,
212
+ created_id: createdId,
144
213
  parent_id: opts.parentId,
214
+ project_id: opts.projectId,
215
+ tag_id: opts.tagId,
216
+ deleted: opts.deleted,
217
+ include: includeFields,
145
218
  sort: opts.sort,
146
219
  order: opts.order,
147
220
  limit: opts.limit,
@@ -154,6 +227,10 @@ export const listSubcommand = createCommand({
154
227
  if (result.tasks.length === 0) {
155
228
  tui.info('No tasks found');
156
229
  } else {
230
+ const showDescription = hasIncludeField(includeFields, 'description');
231
+ const showTags = hasIncludeField(includeFields, 'tags');
232
+ const showMetadata = hasIncludeField(includeFields, 'metadata');
233
+
157
234
  const tableData = result.tasks.map((task: Task) => ({
158
235
  ID: tui.muted(truncate(task.id, 28)),
159
236
  Title: truncate(task.title, 40),
@@ -176,6 +253,30 @@ export const listSubcommand = createCommand({
176
253
  { name: 'Updated', alignment: 'left' },
177
254
  ]);
178
255
 
256
+ // Show extra details for each task if included
257
+ if (showDescription || showTags || showMetadata) {
258
+ for (const task of result.tasks) {
259
+ const extras: string[] = [];
260
+ if (showDescription && task.description) {
261
+ extras.push(`${tui.muted('Desc:')} ${truncate(task.description, 80)}`);
262
+ }
263
+ if (showTags && task.tags && task.tags.length > 0) {
264
+ const tagList = task.tags.map((t) => t.name).join(', ');
265
+ extras.push(`${tui.muted('Tags:')} ${tagList}`);
266
+ }
267
+ if (showMetadata && task.metadata) {
268
+ const metaStr =
269
+ typeof task.metadata === 'object'
270
+ ? JSON.stringify(task.metadata)
271
+ : String(task.metadata);
272
+ extras.push(`${tui.muted('Meta:')} ${truncate(metaStr, 80)}`);
273
+ }
274
+ if (extras.length > 0) {
275
+ tui.output(` ${tui.muted(truncate(task.id, 28))} → ${extras.join(' | ')}`);
276
+ }
277
+ }
278
+ }
279
+
179
280
  tui.info(
180
281
  `Showing ${result.tasks.length} of ${result.total} ${tui.plural(result.total, 'task', 'tasks')} (${durationMs.toFixed(1)}ms)`
181
282
  );
@@ -190,6 +291,12 @@ export const listSubcommand = createCommand({
190
291
  type: task.type,
191
292
  status: task.status,
192
293
  priority: task.priority,
294
+ description: task.description,
295
+ metadata: task.metadata,
296
+ tags: task.tags,
297
+ subtask_count: task.subtask_count,
298
+ created_id: task.created_id,
299
+ deleted: task.deleted,
193
300
  creator: task.creator,
194
301
  assignee: task.assignee,
195
302
  project: task.project,
@@ -11,11 +11,14 @@ export interface TaskContext {
11
11
  auth: AuthData;
12
12
  config: Config | null;
13
13
  options: GlobalOptions;
14
+ project?: {
15
+ projectId: string;
16
+ orgId: string;
17
+ };
14
18
  }
15
19
 
16
20
  export async function createStorageAdapter(ctx: TaskContext) {
17
- const orgId =
18
- ctx.options.orgId ?? (process.env.AGENTUITY_CLOUD_ORG_ID || ctx.config?.preferences?.orgId);
21
+ const orgId = resolveOrgId(ctx);
19
22
  if (!orgId) {
20
23
  tui.fatal('Organization ID is required. Use --org-id flag or set AGENTUITY_CLOUD_ORG_ID.');
21
24
  }
@@ -37,8 +40,7 @@ export async function createStorageAdapter(ctx: TaskContext) {
37
40
  }
38
41
 
39
42
  export async function createStorageAdapterOptionalOrg(ctx: TaskContext) {
40
- const orgId =
41
- ctx.options.orgId ?? (process.env.AGENTUITY_CLOUD_ORG_ID || ctx.config?.preferences?.orgId);
43
+ const orgId = resolveOrgId(ctx);
42
44
 
43
45
  const headers: Record<string, string> = {
44
46
  Authorization: `Bearer ${ctx.auth.apiKey}`,
@@ -54,17 +56,30 @@ export async function createStorageAdapterOptionalOrg(ctx: TaskContext) {
54
56
  return new TaskStorageService(baseUrl, adapter);
55
57
  }
56
58
 
59
+ function resolveOrgId(ctx: TaskContext): string | undefined {
60
+ return (
61
+ ctx.options.orgId ??
62
+ process.env.AGENTUITY_CLOUD_ORG_ID ??
63
+ ctx.project?.orgId ??
64
+ ctx.config?.preferences?.orgId
65
+ );
66
+ }
67
+
57
68
  export async function cacheTaskId(
58
69
  ctx: {
59
70
  config: Config | null;
60
71
  options: GlobalOptions;
72
+ project?: { orgId: string };
61
73
  },
62
74
  taskId: string
63
75
  ) {
64
76
  const profileName = ctx.config?.name ?? defaultProfileName;
65
77
  const region = await getDefaultRegion(profileName, ctx.config);
66
78
  const orgId =
67
- ctx.options.orgId ?? (process.env.AGENTUITY_CLOUD_ORG_ID || ctx.config?.preferences?.orgId);
79
+ ctx.options.orgId ??
80
+ process.env.AGENTUITY_CLOUD_ORG_ID ??
81
+ ctx.project?.orgId ??
82
+ ctx.config?.preferences?.orgId;
68
83
  await setResourceInfo('task', profileName, taskId, region, orgId);
69
84
  }
70
85
 
@@ -76,3 +91,42 @@ export function parseMetadataFlag(raw: string | undefined): Record<string, unkno
76
91
  tui.fatal('Invalid JSON for --metadata flag');
77
92
  }
78
93
  }
94
+
95
+ const DURATION_UNITS: Record<string, number> = {
96
+ s: 1000,
97
+ m: 60 * 1000,
98
+ h: 60 * 60 * 1000,
99
+ d: 24 * 60 * 60 * 1000,
100
+ w: 7 * 24 * 60 * 60 * 1000,
101
+ };
102
+
103
+ export function parseDuration(duration: string): number {
104
+ const match = duration.match(/^(\d+)([smhdw])$/);
105
+ if (!match) {
106
+ tui.fatal(
107
+ `Invalid duration format: "${duration}". Use a number followed by s (seconds), m (minutes), h (hours), d (days), or w (weeks). Examples: 30s, 30m, 24h, 7d, 2w`
108
+ );
109
+ throw new Error('unreachable');
110
+ }
111
+ const value = parseInt(match[1]!, 10);
112
+ const unit = match[2]!;
113
+ const ms = DURATION_UNITS[unit];
114
+ if (!ms) {
115
+ tui.fatal(`Unknown duration unit: "${unit}"`);
116
+ throw new Error('unreachable');
117
+ }
118
+ return value * ms;
119
+ }
120
+
121
+ export function truncate(s: string, max: number): string {
122
+ if (s.length <= max) return s;
123
+ return `${s.slice(0, max - 1)}…`;
124
+ }
125
+
126
+ export function resolveMeId(id: string | undefined, ctx: TaskContext): string | undefined {
127
+ if (!id) return undefined;
128
+ if (id === 'me') {
129
+ return ctx.auth.userId;
130
+ }
131
+ return id;
132
+ }
@@ -0,0 +1,59 @@
1
+ import { z } from 'zod';
2
+ import { CoderClient } from '@agentuity/core/coder';
3
+ import { ValidationOutputError } from '@agentuity/core';
4
+ import { createSubcommand } from '../../types';
5
+ import * as tui from '../../tui';
6
+ import { getCommand } from '../../command-prefix';
7
+ import { ErrorCode } from '../../errors';
8
+
9
+ export const archiveSubcommand = createSubcommand({
10
+ name: 'archive',
11
+ description: 'Archive a Coder Hub session',
12
+ tags: ['mutating', 'requires-auth'],
13
+ requires: { auth: true, org: true },
14
+ examples: [
15
+ {
16
+ command: getCommand('coder archive codesess_abc123'),
17
+ description: 'Archive a session',
18
+ },
19
+ {
20
+ command: getCommand('coder archive codesess_abc123 --json'),
21
+ description: 'Archive a session and return JSON output',
22
+ },
23
+ ],
24
+ schema: {
25
+ args: z.object({
26
+ sessionId: z.string().describe('Session ID to archive'),
27
+ }),
28
+ options: z.object({
29
+ url: z.string().optional().describe('Coder API URL override'),
30
+ }),
31
+ },
32
+ async handler(ctx) {
33
+ const { args, opts, options } = ctx;
34
+ const client = new CoderClient({
35
+ apiKey: ctx.auth.apiKey,
36
+ url: opts?.url,
37
+ orgId: ctx.orgId,
38
+ });
39
+
40
+ try {
41
+ const session = await client.archiveSession(args.sessionId);
42
+ const result = session ?? { archived: true, sessionId: args.sessionId };
43
+
44
+ if (options.json) {
45
+ return result;
46
+ }
47
+
48
+ tui.success(`Session ${args.sessionId} archived.`);
49
+ return result;
50
+ } catch (err) {
51
+ if (err instanceof ValidationOutputError) {
52
+ ctx.logger.trace('Validation response URL: %s', err.url ?? 'unknown');
53
+ ctx.logger.trace('Validation issues: %s', JSON.stringify(err.issues, null, 2));
54
+ }
55
+ const msg = err instanceof Error ? err.message : String(err);
56
+ tui.fatal(`Failed to archive session ${args.sessionId}: ${msg}`, ErrorCode.NETWORK_ERROR);
57
+ }
58
+ },
59
+ });