kanon-cli 0.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/LICENSE +21 -0
- package/bin/kanon.js +266 -0
- package/package.json +34 -0
- package/src/commands/attachment.js +98 -0
- package/src/commands/boards.js +39 -0
- package/src/commands/card.js +260 -0
- package/src/commands/cards.js +79 -0
- package/src/commands/checklist.js +129 -0
- package/src/commands/dashboard.js +24 -0
- package/src/commands/init.js +89 -0
- package/src/commands/label.js +61 -0
- package/src/commands/list.js +78 -0
- package/src/commands/login.js +91 -0
- package/src/commands/watch.js +224 -0
- package/src/dashboard/dist/assets/index-Dcbpx-Xz.js +186 -0
- package/src/dashboard/dist/assets/index-DhFfv70f.css +1 -0
- package/src/dashboard/dist/index.html +13 -0
- package/src/dashboard/dist/kanon.png +0 -0
- package/src/dashboard/package.json +26 -0
- package/src/dashboard/server/agent.js +201 -0
- package/src/dashboard/server/index.js +85 -0
- package/src/dashboard/server/proxy.js +54 -0
- package/src/dashboard/server/settings.js +236 -0
- package/src/lib/admin.js +330 -0
- package/src/lib/api.js +225 -0
- package/src/lib/claude.js +161 -0
- package/src/lib/config.js +112 -0
- package/src/lib/pipeline.js +133 -0
- package/src/lib/websocket.js +194 -0
- package/src/prompts/templates.js +127 -0
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unified prompt builder for Kanon agent.
|
|
3
|
+
* Builds a single prompt from config-defined system + task prompts and card context.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export const DEFAULT_SYSTEM = `You are a Kanon board agent. You interact with the board using the \`kanon\` CLI which is in your PATH. The CLI is already authenticated.
|
|
7
|
+
|
|
8
|
+
## Key Commands
|
|
9
|
+
\`\`\`
|
|
10
|
+
kanon card <id> — Read card details
|
|
11
|
+
kanon card create "title" "list" [opts] — Create card
|
|
12
|
+
kanon card update <id> [opts] — Update card (--comment, --add-label, --move, --done, etc.)
|
|
13
|
+
kanon board — Board context (lists, labels, members)
|
|
14
|
+
kanon cards — List all cards
|
|
15
|
+
kanon help-all — Full command reference with all options
|
|
16
|
+
\`\`\`
|
|
17
|
+
|
|
18
|
+
Run \`kanon help-all\` to see all available commands including checklists, labels, lists, and attachments.
|
|
19
|
+
Be concise and fast. Do not explain what you will do — just do it.`;
|
|
20
|
+
|
|
21
|
+
export const DEFAULT_TASK = `When you receive a card:
|
|
22
|
+
1. Read the title, description, labels, and comments to understand what needs to be done.
|
|
23
|
+
2. If the card references other cards, use \`kanon card <id>\` to read them.
|
|
24
|
+
3. If you need board context (available lists, labels, members), use \`kanon board\`.
|
|
25
|
+
4. Execute the task. If it involves code changes, implement them, then commit and push.
|
|
26
|
+
5. When you start working, move the card to an "In Progress" list if one exists.
|
|
27
|
+
6. When done, add a brief comment summarizing what you did.
|
|
28
|
+
7. When the task is fully complete, move the card to a "Review" list if one exists and mark it as done.
|
|
29
|
+
8. If something is unclear, add a comment with your questions instead of guessing.
|
|
30
|
+
|
|
31
|
+
Do not modify cards you were not asked to work on.
|
|
32
|
+
Always read the full card before taking action — check comments for recent feedback.`;
|
|
33
|
+
|
|
34
|
+
export const DEFAULT_BUNDLE = `You have multiple cards to work on. Review each card below and process them.
|
|
35
|
+
Use sub-agents (the Agent tool) to work on cards in parallel where possible.
|
|
36
|
+
If cards might conflict (e.g. editing the same files), process them sequentially.
|
|
37
|
+
For each card, follow the task instructions above.`;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Format card details into a readable block.
|
|
41
|
+
*/
|
|
42
|
+
export function formatCard(card) {
|
|
43
|
+
const parts = [`Card ID: ${card.id}`, `Title: ${card.title}`];
|
|
44
|
+
|
|
45
|
+
if (card.description) {
|
|
46
|
+
parts.push(`Description: ${card.description}`);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (card.labels?.length) {
|
|
50
|
+
parts.push(`Labels: ${card.labels.map(l => l.name).join(', ')}`);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (card.checklists?.length) {
|
|
54
|
+
for (const cl of card.checklists) {
|
|
55
|
+
parts.push(`\nChecklist: ${cl.title}`);
|
|
56
|
+
for (const item of cl.items || []) {
|
|
57
|
+
const status = item.completed ? '[x]' : '[ ]';
|
|
58
|
+
parts.push(`- ${status} ${item.text}`);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (card.comments?.length) {
|
|
64
|
+
parts.push(`\nComments (newest first):`);
|
|
65
|
+
for (const c of card.comments.slice(0, 10)) {
|
|
66
|
+
const author = c.user?.name || c.user_name || 'Unknown';
|
|
67
|
+
parts.push(`\n${author} (${c.created_at}):\n${c.text}`);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return parts.join('\n');
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Build a unified prompt from config and card context.
|
|
76
|
+
* @param {object} card - Full card object with title, description, labels, comments, etc.
|
|
77
|
+
* @param {object} config - Project config containing prompts.system and prompts.task
|
|
78
|
+
* @returns {string} Complete prompt string
|
|
79
|
+
*/
|
|
80
|
+
/**
|
|
81
|
+
* Build a unified prompt from config and card context.
|
|
82
|
+
* @param {object} card - Full card object
|
|
83
|
+
* @param {object} config - Project config containing prompts.system and prompts.task
|
|
84
|
+
* @param {string} [extraPrompt] - Optional extra prompt from the trigger rule
|
|
85
|
+
* @returns {string} Complete prompt string
|
|
86
|
+
*/
|
|
87
|
+
export function buildPrompt(card, config, extraPrompt = '') {
|
|
88
|
+
const systemPrompt = config?.prompts?.system || DEFAULT_SYSTEM;
|
|
89
|
+
const taskPrompt = config?.prompts?.task || DEFAULT_TASK;
|
|
90
|
+
|
|
91
|
+
let prompt = `${systemPrompt}
|
|
92
|
+
|
|
93
|
+
## Card Details
|
|
94
|
+
${formatCard(card)}
|
|
95
|
+
|
|
96
|
+
${taskPrompt}`;
|
|
97
|
+
|
|
98
|
+
if (extraPrompt) {
|
|
99
|
+
prompt += `\n\n## Trigger Context\n${extraPrompt}`;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
return prompt;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Build a bundled prompt for multiple cards.
|
|
107
|
+
* @param {Array<{card: object, extraPrompt?: string}>} tasks - Array of card tasks
|
|
108
|
+
* @param {object} config - Project config containing prompts
|
|
109
|
+
* @returns {string} Combined prompt string
|
|
110
|
+
*/
|
|
111
|
+
export function buildBundlePrompt(tasks, config) {
|
|
112
|
+
const systemPrompt = config?.prompts?.system || DEFAULT_SYSTEM;
|
|
113
|
+
const taskPrompt = config?.prompts?.task || DEFAULT_TASK;
|
|
114
|
+
const bundlePrompt = config?.prompts?.bundle || DEFAULT_BUNDLE;
|
|
115
|
+
|
|
116
|
+
let prompt = `${systemPrompt}\n\n${bundlePrompt}\n`;
|
|
117
|
+
|
|
118
|
+
for (let i = 0; i < tasks.length; i++) {
|
|
119
|
+
prompt += `\n---\n\n## Card ${i + 1}\n${formatCard(tasks[i].card)}\n`;
|
|
120
|
+
if (tasks[i].extraPrompt) {
|
|
121
|
+
prompt += `\nTrigger context: ${tasks[i].extraPrompt}\n`;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
prompt += `\n---\n\n${taskPrompt}`;
|
|
126
|
+
return prompt;
|
|
127
|
+
}
|