@simonfestl/husky-cli 1.19.2 → 1.20.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.
@@ -480,26 +480,38 @@ configCommand
480
480
  }
481
481
  }
482
482
  console.log(`API connection successful (API URL: ${config.apiUrl})`);
483
- // Now fetch role/permissions from whoami
484
- const whoamiUrl = new URL("/api/auth/whoami", config.apiUrl);
485
- const whoamiRes = await fetch(whoamiUrl.toString(), {
486
- headers: { "x-api-key": apiKey },
487
- });
488
- if (whoamiRes.ok) {
489
- const data = await whoamiRes.json();
490
- // Cache the role/permissions
491
- const updatedConfig = getConfig();
492
- updatedConfig.role = data.role;
493
- updatedConfig.permissions = data.permissions;
494
- updatedConfig.roleLastChecked = new Date().toISOString();
495
- saveConfig(updatedConfig);
496
- console.log(`\nRBAC Info:`);
497
- console.log(` Role: ${data.role || "(not assigned)"}`);
498
- if (data.permissions && data.permissions.length > 0) {
499
- console.log(` Permissions: ${data.permissions.join(", ")}`);
500
- }
501
- if (data.agentId) {
502
- console.log(` Agent ID: ${data.agentId}`);
483
+ // Check if there's an active session
484
+ const hasActiveSession = isSessionActive();
485
+ if (hasActiveSession) {
486
+ // Show session info instead of fetching from API
487
+ console.log(`\nSession Info:`);
488
+ console.log(` Agent: ${config.sessionAgent || "(unknown)"}`);
489
+ console.log(` Role: ${config.sessionRole || "(unknown)"}`);
490
+ console.log(` Expires: ${config.sessionExpiresAt ? new Date(config.sessionExpiresAt).toLocaleString() : "(unknown)"}`);
491
+ console.log(`\n Use 'husky auth permissions' to see full permissions.`);
492
+ }
493
+ else {
494
+ // No session - fetch API key role from whoami
495
+ const whoamiUrl = new URL("/api/auth/whoami", config.apiUrl);
496
+ const whoamiRes = await fetch(whoamiUrl.toString(), {
497
+ headers: { "x-api-key": apiKey },
498
+ });
499
+ if (whoamiRes.ok) {
500
+ const data = await whoamiRes.json();
501
+ // Cache the role/permissions (only if no session)
502
+ const updatedConfig = getConfig();
503
+ updatedConfig.role = data.role;
504
+ updatedConfig.permissions = data.permissions;
505
+ updatedConfig.roleLastChecked = new Date().toISOString();
506
+ saveConfig(updatedConfig);
507
+ console.log(`\nRBAC Info (API Key):`);
508
+ console.log(` Role: ${data.role || "(not assigned)"}`);
509
+ if (data.permissions && data.permissions.length > 0) {
510
+ console.log(` Permissions: ${data.permissions.join(", ")}`);
511
+ }
512
+ if (data.agentId) {
513
+ console.log(` Agent ID: ${data.agentId}`);
514
+ }
503
515
  }
504
516
  }
505
517
  }
@@ -1,4 +1,4 @@
1
- export declare function generateLLMContext(): string;
2
- export declare function printLLMContext(): void;
1
+ export declare function generateLLMContext(role?: string, permissions?: string[]): string;
2
+ export declare function printLLMContext(): Promise<void>;
3
3
  import { Command } from "commander";
4
4
  export declare const llmCommand: Command;
@@ -1,131 +1,86 @@
1
1
  import { createRequire } from "module";
2
+ import { getConfig, isSessionActive } from "./config.js";
2
3
  const require = createRequire(import.meta.url);
3
4
  const packageJson = require("../../package.json");
4
- export function generateLLMContext() {
5
+ // Permission check helper (simplified - checks prefix match)
6
+ function hasPermission(permissions, required) {
7
+ if (permissions.includes("*"))
8
+ return true;
9
+ if (permissions.includes(required))
10
+ return true;
11
+ const [scope] = required.split(":");
12
+ if (permissions.includes(`${scope}:*`))
13
+ return true;
14
+ return false;
15
+ }
16
+ // Section generators
17
+ function getHeader(role) {
5
18
  return `# Husky CLI Reference (v${packageJson.version})
6
19
 
20
+ > **Your Role:** \`${role}\`
21
+
7
22
  > [!CAUTION]
8
23
  > ## MANDATORY: You MUST Use Husky CLI
9
- >
10
- > As an AI agent working in this environment, you are **REQUIRED** to use the Husky CLI for all business operations and task management.
11
- >
24
+ >
25
+ > As an AI agent working in this environment, you are **REQUIRED** to use the Husky CLI for all operations.
26
+ >
12
27
  > **DO NOT:**
13
- > - Make direct API calls to Billbee, Zendesk, or other services
14
- > - Make direct API calls to husky-api (use CLI instead)
28
+ > - Make direct API calls to external services
15
29
  > - Bypass Husky CLI for task management
16
- > - Create custom integrations when Husky commands exist
17
- >
30
+ >
18
31
  > **ALWAYS:**
19
- > - Use \`husky biz\` commands for business operations
20
- > - Use \`husky task\` commands for task lifecycle
21
- > - Use \`husky worktree\` for Git isolation
22
- > - Use \`husky chat\` commands for Google Chat communication
23
32
  > - Check \`husky config test\` before operations
24
-
25
- ---
26
-
27
- ## What is Husky?
28
-
29
- Husky is the **central orchestration layer** for AI agents. It provides:
30
- - **Dashboard API** - Task management, projects, roadmaps
31
- - **Billbee** - E-commerce orders and products
32
- - **Zendesk** - Customer support tickets
33
- - **SeaTable** - Supply chain and inventory
34
- - **Qdrant** - Vector database for semantic search
35
- - **Vertex AI** - Embeddings for similarity search
33
+ > - Use the commands listed below for your role
36
34
 
37
35
  ---
38
36
 
39
37
  ## Configuration
40
38
 
41
39
  \`\`\`bash
42
- husky config set api-url <dashboard-url>
43
- husky config set api-key <key>
44
- husky config list
45
- husky config test
40
+ husky config list # Show current config
41
+ husky config test # Verify API connection
42
+ husky auth session # Check session status
43
+ husky auth permissions # Show your permissions
46
44
  \`\`\`
47
-
45
+ `;
46
+ }
47
+ function getTaskSection(permissions) {
48
+ const canCreate = hasPermission(permissions, "task:create");
49
+ const canStart = hasPermission(permissions, "task:start");
50
+ const canDone = hasPermission(permissions, "task:done");
51
+ const canComplete = hasPermission(permissions, "task:complete");
52
+ let section = `
48
53
  ---
49
54
 
50
- ## Core Commands
55
+ ## Tasks
51
56
 
52
- ### Tasks
53
57
  \`\`\`bash
54
58
  husky task list [--status <status>] # List tasks
55
59
  husky task get <id> # Get task details
56
- husky task create # Create new task
57
- husky task start <id> # Start task (auto-creates worktree!)
58
- husky task start <id> --no-worktree # Start without worktree
59
- husky task done <id> [--pr <url>] # Mark task as done
60
- husky task update <id> # Update task fields
61
- husky task assign <id> <assignee> # Assign task
62
- husky task log <id> # View task activity log
63
- husky task message <id> "msg" # Post status message (positional)
64
- husky task message -m "msg" --id <id> # Post status message (flags)
65
- husky task message -m "msg" # Uses HUSKY_TASK_ID env var
66
- \`\`\`
67
-
68
- ### Projects
69
- \`\`\`bash
70
- husky project list # List projects
71
- husky project get <id> # Get project details
72
- husky project create # Create new project
73
- husky project tasks <id> # List project tasks
74
- \`\`\`
75
-
76
- ### Roadmaps
77
- \`\`\`bash
78
- husky roadmap list # List roadmaps
79
- husky roadmap get <id> # Get roadmap details
80
- husky roadmap create # Create new roadmap
81
- husky roadmap milestones <id> # List milestones
82
- husky roadmap add-milestone <id> # Add milestone to roadmap
83
- \`\`\`
84
-
85
- ### Ideas
86
- \`\`\`bash
87
- husky idea list # List ideas
88
- husky idea get <id> # Get idea details
89
- husky idea create # Create new idea
90
- husky idea vote <id> # Vote on idea
91
- \`\`\`
92
-
93
- ### Workflows
94
- \`\`\`bash
95
- husky workflow list # List workflows
96
- husky workflow get <id> # Get workflow details
97
- husky workflow create # Create new workflow
98
- husky workflow run <id> # Execute workflow
99
- \`\`\`
100
-
101
- ### Departments
102
- \`\`\`bash
103
- husky department list # List departments
104
- husky department get <id> # Get department details
105
- husky department members <id> # List department members
106
- \`\`\`
107
-
108
- ### Processes
109
- \`\`\`bash
110
- husky process list # List processes
111
- husky process get <id> # Get process details
112
- husky process run <id> # Run process
113
- \`\`\`
114
-
115
- ### Strategy
116
- \`\`\`bash
117
- husky strategy list # List strategy items
118
- husky strategy get <id> # Get strategy details
119
- husky strategy update <id> # Update strategy
120
- \`\`\`
60
+ husky task message <id> "msg" # Post status message
61
+ `;
62
+ if (canCreate) {
63
+ section += `husky task create # Create new task
64
+ `;
65
+ }
66
+ if (canStart) {
67
+ section += `husky task start <id> # Start task (auto-creates worktree!)
68
+ `;
69
+ }
70
+ if (canDone || canComplete) {
71
+ section += `husky task done <id> [--pr <url>] # Mark task as done
72
+ `;
73
+ }
74
+ section += `\`\`\`
75
+ `;
76
+ return section;
77
+ }
78
+ function getWorktreeSection() {
79
+ return `
80
+ ---
121
81
 
122
- ### Changelog
123
- \`\`\`bash
124
- husky changelog generate # Generate changelog from commits
125
- husky changelog list # List changelogs
126
- \`\`\`
82
+ ## Worktrees (Git Isolation)
127
83
 
128
- ### Worktrees (Git Isolation)
129
84
  \`\`\`bash
130
85
  husky worktree list # List worktrees
131
86
  husky worktree create <name> # Create isolated worktree
@@ -134,94 +89,74 @@ husky worktree merge <name> # Merge back to base branch
134
89
  husky worktree push <name> # Push branch to remote
135
90
  husky worktree pr <name> -t "Title" # Create pull request
136
91
  husky worktree remove <name> # Remove worktree
137
- husky worktree sync-stats <name> --task-id <id> # Sync stats to dashboard
138
- \`\`\`
139
-
140
- ### VM Sessions (Cloud Agents)
141
- \`\`\`bash
142
- husky vm list # List VM sessions
143
- husky vm create # Create new VM
144
- husky vm status <id> # Get VM status
145
- husky vm ssh <id> # SSH into VM
146
- husky vm delete <id> # Delete VM
147
- \`\`\`
148
-
149
- ### Workers (Multi-Agent Coordination)
150
- \`\`\`bash
151
- husky worker whoami # Show current worker identity
152
- husky worker register # Register worker with API
153
- husky worker list # List all workers
154
- husky worker sessions # List active sessions
155
- husky worker activity # Who is working on what
156
- \`\`\`
157
-
158
- ### Chat (Google Chat Integration)
159
- \`\`\`bash
160
- husky chat reply-chat --space <space-id> "<message>" # Send message to Google Chat
161
- husky chat inbox # Get messages from Google Chat
162
- husky chat inbox --unread # Only unread messages
163
- husky chat pending # Get pending messages from user
164
- husky chat send "<message>" # Send message as supervisor
165
- husky chat reply <messageId> "<response>" # Reply to specific message
166
- husky chat review "<question>" # Request human review via Google Chat
167
- husky chat review-status <reviewId> # Check review status
168
- husky chat watch # Watch for new messages (blocking)
169
92
  \`\`\`
93
+ `;
94
+ }
95
+ function getPRSection() {
96
+ return `
97
+ ---
170
98
 
171
- ### Agent Messaging (agent-to-agent communication)
172
- \`\`\`bash
173
- husky agent-msg send --type <type> --title "<title>" # Send message (types: approval_request, status_update, error_report, completion, query)
174
- husky agent-msg list # List messages
175
- husky agent-msg list --status pending # Filter by status
176
- husky agent-msg pending # List pending messages (for supervisor)
177
- husky agent-msg respond <id> --approve # Approve request
178
- husky agent-msg respond <id> --reject # Reject request
179
- husky agent-msg get <id> # Get message details
180
- husky agent-msg wait <id> # Wait for response (blocking)
181
- \`\`\`
99
+ ## Pull Requests
182
100
 
183
- ### Utility Commands
184
101
  \`\`\`bash
185
- husky explain <command> # Explain CLI commands
186
- husky settings list # List dashboard settings
187
- husky settings set <key> <value> # Update setting
188
- husky completion bash|zsh|fish # Generate shell completion
189
- husky llm # Output LLM reference docs
102
+ husky worktree pr <name> -t "Title" # Create PR from worktree
103
+ husky worktree push <name> # Push branch to remote
104
+ husky worktree merge <name> # Merge back to base
190
105
  \`\`\`
191
-
106
+ `;
107
+ }
108
+ function getBizSection(permissions) {
109
+ const hasBizAll = hasPermission(permissions, "biz:*");
110
+ const hasBizRead = hasPermission(permissions, "biz:read");
111
+ const hasTickets = hasBizAll || hasPermission(permissions, "biz:tickets");
112
+ const hasOrders = hasBizAll || hasPermission(permissions, "biz:orders");
113
+ const hasProducts = hasBizAll || hasPermission(permissions, "biz:products");
114
+ let section = `
192
115
  ---
193
116
 
194
117
  ## Business Operations (husky biz)
195
-
118
+ `;
119
+ if (hasTickets) {
120
+ section += `
196
121
  ### Tickets (Zendesk)
197
122
  \`\`\`bash
198
123
  husky biz tickets list # List recent tickets
199
124
  husky biz tickets get <id> # Get ticket details
200
125
  husky biz tickets search "<query>" # Search tickets
201
- husky biz tickets reply <id> "<msg>" # Reply to ticket
126
+ `;
127
+ if (hasBizAll) {
128
+ section += `husky biz tickets reply <id> "<msg>" # Reply to ticket
202
129
  husky biz tickets note <id> "<note>" # Add internal note
203
130
  husky biz tickets close <id> # Close ticket
204
-
205
- # Prebuild (Semantic Search)
206
- husky biz tickets similar <id> # Find similar tickets
207
- husky biz tickets find-similar "<q>" # Semantic ticket search
131
+ `;
132
+ }
133
+ section += `husky biz tickets similar <id> # Find similar tickets
208
134
  husky biz tickets knowledge "<query>" # Search resolved tickets
209
135
  \`\`\`
210
-
136
+ `;
137
+ }
138
+ if (hasOrders || hasBizRead) {
139
+ section += `
211
140
  ### Orders (Billbee)
212
141
  \`\`\`bash
213
142
  husky biz orders list # List orders
214
143
  husky biz orders get <id> # Get order details
215
144
  husky biz orders search "<query>" # Search orders
216
145
  \`\`\`
217
-
146
+ `;
147
+ }
148
+ if (hasProducts || hasBizRead) {
149
+ section += `
218
150
  ### Products (Billbee)
219
151
  \`\`\`bash
220
152
  husky biz products list # List products
221
153
  husky biz products get <id> # Get product details
222
154
  husky biz products sku <sku> # Get by SKU
223
155
  \`\`\`
224
-
156
+ `;
157
+ }
158
+ if (hasBizAll || hasBizRead) {
159
+ section += `
225
160
  ### Customers
226
161
  \`\`\`bash
227
162
  husky biz customers search <email> # Search by email
@@ -232,118 +167,304 @@ husky biz customers 360 <email> # Full customer view (Billbee + Zendesk)
232
167
  ### SeaTable (Supply Chain)
233
168
  \`\`\`bash
234
169
  husky biz seatable tables # List tables
235
- husky biz seatable rows <table> # List rows
236
170
  husky biz seatable find-supplier "<q>" # Search suppliers
237
- husky biz seatable order-status <no> # Get order status
238
171
  husky biz seatable stock-check <sku> # Check stock levels
239
172
  \`\`\`
173
+ `;
174
+ }
175
+ return section;
176
+ }
177
+ function getWorkflowSection() {
178
+ return `
179
+ ---
180
+
181
+ ## Workflows & Processes
182
+
183
+ Diese Dokumentation hilft dir, Geschaeftsprozesse zu verstehen (z.B. Warenfluss, Bestellprozess).
240
184
 
241
- ### Qdrant (Vector DB)
242
185
  \`\`\`bash
243
- husky biz qdrant collections # List collections
244
- husky biz qdrant info <name> # Collection info
245
- husky biz qdrant count <name> # Count points
246
- husky biz qdrant search <coll> "<q>" # Semantic search
186
+ husky workflow list # List workflows
187
+ husky workflow get <id> # Get workflow details (inkl. Mermaid diagram)
188
+
189
+ husky process list # List processes/SOPs
190
+ husky process get <id> # Get process details
247
191
  \`\`\`
192
+ `;
193
+ }
194
+ function getRoadmapSection(canWrite) {
195
+ let section = `
196
+ ---
197
+
198
+ ## Roadmaps
248
199
 
200
+ \`\`\`bash
201
+ husky roadmap list # List roadmaps
202
+ husky roadmap get <id> # Get roadmap details
203
+ husky roadmap milestones <id> # List milestones
204
+ `;
205
+ if (canWrite) {
206
+ section += `husky roadmap create # Create new roadmap
207
+ husky roadmap add-milestone <id> # Add milestone
208
+ `;
209
+ }
210
+ section += `\`\`\`
211
+ `;
212
+ return section;
213
+ }
214
+ function getProjectSection() {
215
+ return `
249
216
  ---
250
217
 
251
- ## Agent Brain (Lernender Agent)
218
+ ## Projects
252
219
 
253
- > [!IMPORTANT]
254
- > **MANDATORY WORKFLOW für Daily Ops (Support, Worker, etc.)**
255
- >
256
- > 1. **VOR der Arbeit**: \`husky brain recall\` - Prüfe ob ähnliches Problem bereits gelöst wurde
257
- > 2. **NACH der Arbeit**: \`husky brain remember\` - Speichere neue Erkenntnisse
220
+ \`\`\`bash
221
+ husky project list # List projects
222
+ husky project get <id> # Get project details
223
+ husky project tasks <id> # List project tasks
224
+ \`\`\`
225
+ `;
226
+ }
227
+ function getChatSection(permissions) {
228
+ const canReply = hasPermission(permissions, "chat:reply") || hasPermission(permissions, "chat:*");
229
+ let section = `
230
+ ---
231
+
232
+ ## Chat (Google Chat Integration)
233
+
234
+ \`\`\`bash
235
+ husky chat inbox # Get messages
236
+ husky chat inbox --unread # Only unread messages
237
+ husky chat pending # Get pending messages
238
+ `;
239
+ if (canReply) {
240
+ section += `husky chat reply-chat --space <id> "msg" # Send message
241
+ husky chat send "<message>" # Send as supervisor
242
+ husky chat review "<question>" # Request human review
243
+ \`\`\`
244
+ `;
245
+ }
246
+ else {
247
+ section += `\`\`\`
248
+ `;
249
+ }
250
+ return section;
251
+ }
252
+ function getDeploySection() {
253
+ return `
254
+ ---
258
255
 
259
- ### Role-Based Access
256
+ ## Deployment
260
257
 
261
- Jeder Agent-Typ hat sein **eigenes Brain** und kann NUR auf eigene Memories zugreifen:
258
+ \`\`\`bash
259
+ husky deploy sandbox # Deploy to sandbox environment
260
+ \`\`\`
261
+ `;
262
+ }
263
+ function getBrainSection(role) {
264
+ return `
265
+ ---
262
266
 
263
- | Agent Type | Brain Collection | Zugriff |
264
- |------------|------------------|---------|
265
- | \`support\` | brain_support | Nur Support-Wissen |
266
- | \`worker\` | brain_worker | Nur Worker-Wissen |
267
- | \`supervisor\` | brain_supervisor | Nur Supervisor-Wissen |
268
- | \`claude\` | brain_claude | Nur Claude-Wissen |
267
+ ## Agent Brain (Lernender Agent)
269
268
 
270
- Der Agent-Typ wird automatisch aus \`HUSKY_AGENT_TYPE\` oder Config gelesen.
269
+ > [!IMPORTANT]
270
+ > **MANDATORY WORKFLOW**
271
+ >
272
+ > 1. **VOR der Arbeit**: \`husky brain recall\` - Pruefe ob aehnliches Problem bereits geloest wurde
273
+ > 2. **NACH der Arbeit**: \`husky brain remember\` - Speichere neue Erkenntnisse
271
274
 
272
- ### Commands
275
+ Dein Brain-Typ: \`${role}\`
273
276
 
274
277
  \`\`\`bash
275
- # ZUERST: Bestehendes Wissen abrufen
276
- husky brain recall "kunde kann nicht einloggen" # Semantic Search
277
- husky brain recall "billing problem" --limit 10 # Mehr Ergebnisse
278
+ # Wissen abrufen
279
+ husky brain recall "suchbegriff" # Semantic Search
280
+ husky brain recall "problem" --limit 10 # Mehr Ergebnisse
278
281
 
279
- # DANACH: Neues Wissen speichern
280
- husky brain remember "Login-Problem bei Safari gelöst durch Cache löschen" --tags "login,safari,cache"
282
+ # Wissen speichern
283
+ husky brain remember "Loesung..." --tags "tag1,tag2"
281
284
 
282
285
  # Weitere Commands
283
286
  husky brain list # Alle eigenen Memories
284
- husky brain tags "billing,refund" # Nach Tags suchen
287
+ husky brain tags "tag1,tag2" # Nach Tags suchen
285
288
  husky brain stats # Statistiken
286
- husky brain info # Aktuelle Konfiguration
287
- husky brain forget <id> # Memory löschen
288
289
  \`\`\`
290
+ `;
291
+ }
292
+ function getVMSection() {
293
+ return `
294
+ ---
289
295
 
290
- ### Workflow Beispiel: Support Agent
296
+ ## VM Sessions (Cloud Agents)
291
297
 
292
298
  \`\`\`bash
293
- # 1. Neues Ticket kommt rein: "Kunde kann Rechnung nicht herunterladen"
294
- husky brain recall "rechnung download problem"
295
-
296
- # 2. Brain findet ähnliche gelöste Fälle:
297
- # [92.3%] PDF-Download funktioniert nicht bei AdBlocker - Lösung: AdBlocker deaktivieren
298
- # [87.1%] Rechnung lädt nicht - Browser-Cache war voll
299
-
300
- # 3. Agent nutzt Wissen, löst Ticket
301
-
302
- # 4. Nach Lösung: Neues Wissen speichern
303
- husky brain remember "Rechnungs-Download fehlgeschlagen wegen Corporate Firewall - IT musste *.billbee.io freigeben" --tags "billing,download,firewall,corporate"
299
+ husky vm list # List VM sessions
300
+ husky vm create # Create new VM
301
+ husky vm status <id> # Get VM status
302
+ husky vm ssh <id> # SSH into VM
303
+ husky vm delete <id> # Delete VM
304
304
  \`\`\`
305
+ `;
306
+ }
307
+ function getWorkerSection() {
308
+ return `
309
+ ---
305
310
 
306
- ### Best Practices
307
-
308
- - **Tags verwenden**: Immer relevante Tags hinzufügen für bessere Auffindbarkeit
309
- - **Konkret sein**: "Safari Cache löschen löst Login" statt "Login Problem gelöst"
310
- - **Kontext speichern**: Ursache UND Lösung dokumentieren
311
- - **Regelmäßig recall**: Vor JEDER neuen Aufgabe prüfen ob Wissen existiert
311
+ ## Workers (Multi-Agent Coordination)
312
312
 
313
+ \`\`\`bash
314
+ husky worker whoami # Show current worker identity
315
+ husky worker list # List all workers
316
+ husky worker activity # Who is working on what
317
+ \`\`\`
318
+ `;
319
+ }
320
+ function getAgentMsgSection() {
321
+ return `
313
322
  ---
314
323
 
315
- ## Environment Variables
324
+ ## Agent Messaging
316
325
 
317
- | Variable | Description |
318
- |----------|-------------|
319
- | \`HUSKY_ENV\` | Environment prefix (PROD/SANDBOX) |
320
- | \`HUSKY_AGENT_TYPE\` | Agent type for brain access (support/worker/supervisor/claude) |
321
- | \`HUSKY_AGENT_ID\` | Unique agent identifier |
322
- | \`PROD_BILLBEE_API_KEY\` | Billbee API key |
323
- | \`PROD_ZENDESK_API_TOKEN\` | Zendesk token |
324
- | \`PROD_SEATABLE_API_TOKEN\` | SeaTable token |
325
- | \`HUSKY_QDRANT_URL\` | Qdrant URL (internal: http://10.132.0.46:6333) |
326
+ \`\`\`bash
327
+ husky agent-msg send --type <type> --title "<title>"
328
+ husky agent-msg list # List messages
329
+ husky agent-msg pending # Pending messages
330
+ husky agent-msg respond <id> --approve # Approve request
331
+ husky agent-msg wait <id> # Wait for response
332
+ \`\`\`
333
+ `;
334
+ }
335
+ function getAdminSection() {
336
+ return `
337
+ ---
326
338
 
327
- > **Note:** Qdrant runs on internal VM (VPC). No API key needed - access is secured by VPC isolation.
339
+ ## Admin Commands
328
340
 
341
+ \`\`\`bash
342
+ husky settings list # List dashboard settings
343
+ husky settings set <key> <value> # Update setting
344
+ husky auth keys # List API keys
345
+ husky auth create-key --name <n> --role <r> # Create API key
346
+ \`\`\`
347
+ `;
348
+ }
349
+ function getTips() {
350
+ return `
329
351
  ---
330
352
 
331
- ## Usage Tips for LLM Agents
353
+ ## Tips
332
354
 
333
- 1. **Always use \`--json\` flag** when available for structured output
334
- 2. **Check config first**: \`husky config test\` before API calls
335
- 3. **Use prebuild commands** for complex workflows (e.g., \`tickets similar\`)
336
- 4. **Customer 360** combines Billbee + Zendesk data in one call
337
- 5. **Semantic search** requires Qdrant and Vertex AI configured
355
+ 1. **Immer \`--json\` flag** verwenden fuer strukturierten Output
356
+ 2. **Config testen**: \`husky config test\` vor API calls
357
+ 3. **Brain nutzen**: Vor jeder Aufgabe \`husky brain recall\`
338
358
  `;
339
359
  }
340
- export function printLLMContext() {
341
- console.log(generateLLMContext());
360
+ // Role-based context generation
361
+ export function generateLLMContext(role, permissions) {
362
+ // Use provided values or try to get from config
363
+ const config = getConfig();
364
+ const effectiveRole = role || config.sessionRole || config.role || "worker";
365
+ const effectivePermissions = permissions || config.permissions || [];
366
+ let context = getHeader(effectiveRole);
367
+ // Task section - always included (all roles have task:read)
368
+ context += getTaskSection(effectivePermissions);
369
+ // Worktree section - for workers and pr_agent
370
+ if (hasPermission(effectivePermissions, "worktree:*") ||
371
+ hasPermission(effectivePermissions, "pr:create")) {
372
+ context += getWorktreeSection();
373
+ }
374
+ // PR section - for pr_agent
375
+ if (hasPermission(effectivePermissions, "pr:create") ||
376
+ hasPermission(effectivePermissions, "pr:merge")) {
377
+ context += getPRSection();
378
+ }
379
+ // Business operations - for support, purchasing, ops, workers with biz:read
380
+ if (hasPermission(effectivePermissions, "biz:*") ||
381
+ hasPermission(effectivePermissions, "biz:read") ||
382
+ hasPermission(effectivePermissions, "biz:tickets") ||
383
+ hasPermission(effectivePermissions, "biz:orders")) {
384
+ context += getBizSection(effectivePermissions);
385
+ }
386
+ // Workflows & Processes - for anyone with workflow:read or process:read
387
+ if (hasPermission(effectivePermissions, "workflow:read") ||
388
+ hasPermission(effectivePermissions, "workflow:*") ||
389
+ hasPermission(effectivePermissions, "process:read") ||
390
+ hasPermission(effectivePermissions, "process:*")) {
391
+ context += getWorkflowSection();
392
+ }
393
+ // Roadmaps - for workers, supervisors
394
+ if (hasPermission(effectivePermissions, "roadmap:read") ||
395
+ hasPermission(effectivePermissions, "roadmap:*")) {
396
+ const canWrite = hasPermission(effectivePermissions, "roadmap:*");
397
+ context += getRoadmapSection(canWrite);
398
+ }
399
+ // Projects - for workers
400
+ if (hasPermission(effectivePermissions, "project:read") ||
401
+ hasPermission(effectivePermissions, "project:*")) {
402
+ context += getProjectSection();
403
+ }
404
+ // Chat - for support, supervisor
405
+ if (hasPermission(effectivePermissions, "chat:read") ||
406
+ hasPermission(effectivePermissions, "chat:reply") ||
407
+ hasPermission(effectivePermissions, "chat:*")) {
408
+ context += getChatSection(effectivePermissions);
409
+ }
410
+ // Deploy - for e2e_agent
411
+ if (hasPermission(effectivePermissions, "deploy:sandbox") ||
412
+ hasPermission(effectivePermissions, "deploy:*")) {
413
+ context += getDeploySection();
414
+ }
415
+ // VM management - for supervisor, admin
416
+ if (hasPermission(effectivePermissions, "vm:*")) {
417
+ context += getVMSection();
418
+ }
419
+ // Worker coordination - for supervisor
420
+ if (hasPermission(effectivePermissions, "worker:*")) {
421
+ context += getWorkerSection();
422
+ context += getAgentMsgSection();
423
+ }
424
+ // Admin section
425
+ if (hasPermission(effectivePermissions, "admin:*") ||
426
+ hasPermission(effectivePermissions, "settings:*")) {
427
+ context += getAdminSection();
428
+ }
429
+ // Brain - always included
430
+ context += getBrainSection(effectiveRole);
431
+ // Tips - always included
432
+ context += getTips();
433
+ return context;
434
+ }
435
+ export async function printLLMContext() {
436
+ // Try to fetch permissions if we have a session
437
+ const config = getConfig();
438
+ let permissions = [];
439
+ let role = config.sessionRole || config.role || "worker";
440
+ if (isSessionActive() && config.apiUrl && config.apiKey) {
441
+ try {
442
+ const { getPermissions } = await import("../lib/permissions-cache.js");
443
+ const perms = await getPermissions();
444
+ permissions = perms.permissions;
445
+ role = perms.role;
446
+ }
447
+ catch {
448
+ // Use defaults if fetch fails
449
+ permissions = config.permissions || [];
450
+ }
451
+ }
452
+ else {
453
+ permissions = config.permissions || [];
454
+ }
455
+ console.log(generateLLMContext(role, permissions));
342
456
  }
343
457
  // Command export for subcommand registration
344
458
  import { Command } from "commander";
345
459
  export const llmCommand = new Command("llm")
346
- .description("Output LLM reference documentation (markdown)")
347
- .action(() => {
348
- printLLMContext();
460
+ .description("Output LLM reference documentation (role-based)")
461
+ .option("--full", "Show full documentation (all commands)")
462
+ .action(async (options) => {
463
+ if (options.full) {
464
+ // Show everything - use admin permissions
465
+ console.log(generateLLMContext("admin", ["*"]));
466
+ }
467
+ else {
468
+ await printLLMContext();
469
+ }
349
470
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@simonfestl/husky-cli",
3
- "version": "1.19.2",
3
+ "version": "1.20.0",
4
4
  "description": "CLI for Huskyv0 Task Orchestration with Claude Agent SDK",
5
5
  "type": "module",
6
6
  "bin": {