@kosuke-ai/cli 0.0.6 ā 0.0.7
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/README.md +33 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -1
- package/dist/kosuke/commands/requirements.d.ts +15 -0
- package/dist/kosuke/commands/requirements.d.ts.map +1 -0
- package/dist/kosuke/commands/requirements.js +286 -0
- package/dist/kosuke/commands/requirements.js.map +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -105,6 +105,39 @@ kosuke lint --no-pr
|
|
|
105
105
|
- Your `package.json` must have a `lint` script (e.g., `"lint": "eslint . --fix"`)
|
|
106
106
|
- The lint script should support the `--fix` flag for auto-fixing
|
|
107
107
|
|
|
108
|
+
### `kosuke requirements`
|
|
109
|
+
|
|
110
|
+
Interactive requirements gathering tool powered by Claude AI. Creates a comprehensive `docs.md` file through a conversational workflow.
|
|
111
|
+
|
|
112
|
+
**How it works:**
|
|
113
|
+
|
|
114
|
+
1. You describe your web application
|
|
115
|
+
2. Claude analyzes and extracts core functionalities
|
|
116
|
+
3. Claude asks clarification questions
|
|
117
|
+
4. You answer iteratively until requirements are clear
|
|
118
|
+
5. Claude generates a detailed `docs.md` with:
|
|
119
|
+
- Product Overview
|
|
120
|
+
- Core Functionalities
|
|
121
|
+
- Technical Architecture
|
|
122
|
+
- User Flows
|
|
123
|
+
- Database Schema
|
|
124
|
+
- API Endpoints
|
|
125
|
+
- Implementation Notes
|
|
126
|
+
|
|
127
|
+
**Example:**
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
kosuke requirements
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
**Features:**
|
|
134
|
+
|
|
135
|
+
- ⨠Fully interactive conversation workflow
|
|
136
|
+
- š° Real-time cost tracking (shows token usage)
|
|
137
|
+
- š Iterative refinement until requirements are comprehensive
|
|
138
|
+
- š Structured markdown output in `docs.md`
|
|
139
|
+
- š Optimized for web application projects
|
|
140
|
+
|
|
108
141
|
## Configuration
|
|
109
142
|
|
|
110
143
|
### `.kosukeignore`
|
package/dist/index.d.ts
CHANGED
|
@@ -5,10 +5,14 @@
|
|
|
5
5
|
* Commands:
|
|
6
6
|
* sync-rules [--force] Sync rules from kosuke-template
|
|
7
7
|
* analyse Analyze and fix code quality issues
|
|
8
|
+
* lint Fix linting errors with Claude AI
|
|
9
|
+
* requirements Interactive requirements gathering
|
|
8
10
|
*
|
|
9
11
|
* Usage:
|
|
10
12
|
* bun run kosuke sync-rules
|
|
11
13
|
* bun run kosuke analyse
|
|
14
|
+
* bun run kosuke lint
|
|
15
|
+
* bun run kosuke requirements
|
|
12
16
|
*
|
|
13
17
|
* Environment Variables:
|
|
14
18
|
* ANTHROPIC_API_KEY - Required for Claude API
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";AAEA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";AAEA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,eAAe,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -5,10 +5,14 @@
|
|
|
5
5
|
* Commands:
|
|
6
6
|
* sync-rules [--force] Sync rules from kosuke-template
|
|
7
7
|
* analyse Analyze and fix code quality issues
|
|
8
|
+
* lint Fix linting errors with Claude AI
|
|
9
|
+
* requirements Interactive requirements gathering
|
|
8
10
|
*
|
|
9
11
|
* Usage:
|
|
10
12
|
* bun run kosuke sync-rules
|
|
11
13
|
* bun run kosuke analyse
|
|
14
|
+
* bun run kosuke lint
|
|
15
|
+
* bun run kosuke requirements
|
|
12
16
|
*
|
|
13
17
|
* Environment Variables:
|
|
14
18
|
* ANTHROPIC_API_KEY - Required for Claude API
|
|
@@ -18,6 +22,7 @@ import 'dotenv/config';
|
|
|
18
22
|
import { syncRulesCommand } from './kosuke/commands/sync-rules.js';
|
|
19
23
|
import { analyseCommand } from './kosuke/commands/analyse.js';
|
|
20
24
|
import { lintCommand } from './kosuke/commands/lint.js';
|
|
25
|
+
import { requirementsCommand } from './kosuke/commands/requirements.js';
|
|
21
26
|
async function main() {
|
|
22
27
|
const args = process.argv.slice(2);
|
|
23
28
|
const command = args[0];
|
|
@@ -52,6 +57,10 @@ async function main() {
|
|
|
52
57
|
await lintCommand(options);
|
|
53
58
|
break;
|
|
54
59
|
}
|
|
60
|
+
case 'requirements': {
|
|
61
|
+
await requirementsCommand();
|
|
62
|
+
break;
|
|
63
|
+
}
|
|
55
64
|
default:
|
|
56
65
|
console.error(`ā Unknown command: ${command}\n`);
|
|
57
66
|
showHelp();
|
|
@@ -109,6 +118,13 @@ COMMANDS:
|
|
|
109
118
|
kosuke lint --dry-run
|
|
110
119
|
kosuke lint --no-pr
|
|
111
120
|
|
|
121
|
+
requirements
|
|
122
|
+
Interactive requirements gathering with Claude AI
|
|
123
|
+
Generates a comprehensive docs.md file
|
|
124
|
+
|
|
125
|
+
Examples:
|
|
126
|
+
kosuke requirements
|
|
127
|
+
|
|
112
128
|
ENVIRONMENT VARIABLES:
|
|
113
129
|
|
|
114
130
|
ANTHROPIC_API_KEY Required for Claude API access
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";AAEA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";AAEA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,eAAe,CAAC;AACvB,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OA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AAI,EAAE,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC;iBAC/B,CAAC;gBACF,MAAM,WAAW,CAAC,OAAO,CAAC,CAAC;gBAC3B,MAAM;YACR,CAAC;YAED,KAAK,cAAc,CAAC,CAAC,CAAC;gBACpB,MAAM,mBAAmB,EAAE,CAAC;gBAC5B,MAAM;YACR,CAAC;YAED;gBACE,OAAO,CAAC,KAAK,CAAC,sBAAsB,OAAO,IAAI,CAAC,CAAC;gBACjD,QAAQ,EAAE,CAAC;gBACX,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACpB,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,kBAAkB,EAAE,KAAK,CAAC,CAAC;QACzC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC;AAED,SAAS,QAAQ;IACf,OAAO,CAAC,GAAG,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6Db,CAAC,CAAC;AACH,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACrB,OAAO,CAAC,KAAK,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC;IACrC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Requirements command - Interactive requirements gathering with Claude AI
|
|
3
|
+
*
|
|
4
|
+
* Strategy: Multi-turn conversation to build comprehensive requirements
|
|
5
|
+
* - User provides product description
|
|
6
|
+
* - Claude analyzes and extracts functionalities
|
|
7
|
+
* - Claude asks clarification questions
|
|
8
|
+
* - User answers questions (iterative until clear)
|
|
9
|
+
* - Generate docs.md with complete requirements
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Main requirements command
|
|
13
|
+
*/
|
|
14
|
+
export declare function requirementsCommand(): Promise<void>;
|
|
15
|
+
//# sourceMappingURL=requirements.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"requirements.d.ts","sourceRoot":"","sources":["../../../kosuke/commands/requirements.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AA8VH;;GAEG;AACH,wBAAsB,mBAAmB,IAAI,OAAO,CAAC,IAAI,CAAC,CAazD"}
|
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Requirements command - Interactive requirements gathering with Claude AI
|
|
3
|
+
*
|
|
4
|
+
* Strategy: Multi-turn conversation to build comprehensive requirements
|
|
5
|
+
* - User provides product description
|
|
6
|
+
* - Claude analyzes and extracts functionalities
|
|
7
|
+
* - Claude asks clarification questions
|
|
8
|
+
* - User answers questions (iterative until clear)
|
|
9
|
+
* - Generate docs.md with complete requirements
|
|
10
|
+
*/
|
|
11
|
+
import { query } from '@anthropic-ai/claude-agent-sdk';
|
|
12
|
+
import * as readline from 'readline';
|
|
13
|
+
import { join } from 'path';
|
|
14
|
+
/**
|
|
15
|
+
* Calculate cost based on Claude Sonnet 4.5 pricing
|
|
16
|
+
* - $3 per million input tokens
|
|
17
|
+
* - $15 per million output tokens
|
|
18
|
+
* - $3.75 per million cache creation tokens
|
|
19
|
+
* - $0.30 per million cache read tokens
|
|
20
|
+
*/
|
|
21
|
+
function calculateCost(inputTokens, outputTokens, cacheCreationTokens = 0, cacheReadTokens = 0) {
|
|
22
|
+
const INPUT_COST_PER_MILLION = 3.0;
|
|
23
|
+
const OUTPUT_COST_PER_MILLION = 15.0;
|
|
24
|
+
const CACHE_CREATION_COST_PER_MILLION = 3.75;
|
|
25
|
+
const CACHE_READ_COST_PER_MILLION = 0.3;
|
|
26
|
+
const inputCost = (inputTokens / 1000000) * INPUT_COST_PER_MILLION;
|
|
27
|
+
const outputCost = (outputTokens / 1000000) * OUTPUT_COST_PER_MILLION;
|
|
28
|
+
const cacheCreationCost = (cacheCreationTokens / 1000000) * CACHE_CREATION_COST_PER_MILLION;
|
|
29
|
+
const cacheReadCost = (cacheReadTokens / 1000000) * CACHE_READ_COST_PER_MILLION;
|
|
30
|
+
return inputCost + outputCost + cacheCreationCost + cacheReadCost;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Format token usage for display
|
|
34
|
+
*/
|
|
35
|
+
function formatTokenUsage(inputTokens, outputTokens, cacheCreationTokens, cacheReadTokens, cost) {
|
|
36
|
+
const breakdown = [];
|
|
37
|
+
if (inputTokens > 0)
|
|
38
|
+
breakdown.push(`${inputTokens.toLocaleString()} input`);
|
|
39
|
+
if (outputTokens > 0)
|
|
40
|
+
breakdown.push(`${outputTokens.toLocaleString()} output`);
|
|
41
|
+
if (cacheCreationTokens > 0)
|
|
42
|
+
breakdown.push(`${cacheCreationTokens.toLocaleString()} cache write`);
|
|
43
|
+
if (cacheReadTokens > 0)
|
|
44
|
+
breakdown.push(`${cacheReadTokens.toLocaleString()} cache read`);
|
|
45
|
+
return `š° Cost: $${cost.toFixed(4)} (${breakdown.join(' + ')} tokens)`;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Process a single Claude interaction
|
|
49
|
+
*/
|
|
50
|
+
async function processClaudeInteraction(userInput, sessionId, isFirstRequest) {
|
|
51
|
+
const workspaceRoot = process.cwd();
|
|
52
|
+
// Modify the prompt for the first request to enforce planning workflow
|
|
53
|
+
let effectivePrompt = userInput;
|
|
54
|
+
if (isFirstRequest) {
|
|
55
|
+
effectivePrompt = `${userInput}
|
|
56
|
+
|
|
57
|
+
IMPORTANT INSTRUCTIONS FOR FIRST REQUEST:
|
|
58
|
+
This is a web application product implementation request. You MUST follow this workflow:
|
|
59
|
+
|
|
60
|
+
1. **Analyze the Request**: Understand what product needs to be built
|
|
61
|
+
2. **List Core Functionalities**: Present all features in clear bullet points
|
|
62
|
+
3. **Define Implementation Plan**: Create a detailed plan with all required components
|
|
63
|
+
4. **Ask NUMBERED Clarification Questions**: List any ambiguities or missing requirements with numbers
|
|
64
|
+
|
|
65
|
+
Format your response as:
|
|
66
|
+
---
|
|
67
|
+
## Product Analysis
|
|
68
|
+
[Brief description of what will be built]
|
|
69
|
+
|
|
70
|
+
## Core Functionalities
|
|
71
|
+
- [Functionality 1]
|
|
72
|
+
- [Functionality 2]
|
|
73
|
+
- [Functionality 3]
|
|
74
|
+
...
|
|
75
|
+
|
|
76
|
+
## Implementation Plan
|
|
77
|
+
[High-level technical approach and architecture]
|
|
78
|
+
|
|
79
|
+
## Clarification Questions
|
|
80
|
+
1. [Question 1]
|
|
81
|
+
2. [Question 2]
|
|
82
|
+
3. [Question 3]
|
|
83
|
+
...
|
|
84
|
+
|
|
85
|
+
---
|
|
86
|
+
|
|
87
|
+
WORKFLOW AFTER USER ANSWERS QUESTIONS:
|
|
88
|
+
When the user has answered all questions and requirements are clear, create a comprehensive requirements document in docs.md with:
|
|
89
|
+
- Product Overview
|
|
90
|
+
- Core Functionalities (detailed)
|
|
91
|
+
- Technical Architecture
|
|
92
|
+
- User Flows
|
|
93
|
+
- Database Schema
|
|
94
|
+
- API Endpoints
|
|
95
|
+
- Implementation Notes
|
|
96
|
+
|
|
97
|
+
IMPORTANT: This is an INTERACTIVE conversation. After showing this plan, WAIT for the user's response. The conversation continues - do NOT stop the chat loop.`;
|
|
98
|
+
}
|
|
99
|
+
const options = {
|
|
100
|
+
model: 'claude-sonnet-4-5',
|
|
101
|
+
maxTurns: 20,
|
|
102
|
+
cwd: workspaceRoot,
|
|
103
|
+
permissionMode: 'acceptEdits',
|
|
104
|
+
resume: sessionId || undefined,
|
|
105
|
+
allowedTools: ['Read', 'Write', 'Edit', 'LS', 'Grep', 'Glob', 'WebSearch'],
|
|
106
|
+
systemPrompt: {
|
|
107
|
+
type: 'preset',
|
|
108
|
+
preset: 'claude_code',
|
|
109
|
+
},
|
|
110
|
+
};
|
|
111
|
+
const responseStream = query({ prompt: effectivePrompt, options });
|
|
112
|
+
let responseText = '';
|
|
113
|
+
let newSessionId = sessionId || '';
|
|
114
|
+
let inputTokens = 0;
|
|
115
|
+
let outputTokens = 0;
|
|
116
|
+
let cacheCreationTokens = 0;
|
|
117
|
+
let cacheReadTokens = 0;
|
|
118
|
+
// Process the async generator
|
|
119
|
+
for await (const message of responseStream) {
|
|
120
|
+
if (message.type === 'user') {
|
|
121
|
+
if (!newSessionId) {
|
|
122
|
+
newSessionId = message.session_id;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
else if (message.type === 'assistant') {
|
|
126
|
+
const content = message.message.content;
|
|
127
|
+
for (const block of content) {
|
|
128
|
+
if (block.type === 'text') {
|
|
129
|
+
responseText += block.text;
|
|
130
|
+
}
|
|
131
|
+
else if (block.type === 'tool_use') {
|
|
132
|
+
// Show tool usage
|
|
133
|
+
if (block.name === 'Write' || block.name === 'Edit') {
|
|
134
|
+
const input = block.input;
|
|
135
|
+
if (input.path === 'docs.md' || input.path?.includes('docs.md')) {
|
|
136
|
+
console.log('\nāļø Generating docs.md...');
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
else if (message.type === 'result' && message.subtype === 'success') {
|
|
143
|
+
// Track token usage
|
|
144
|
+
if (message.usage) {
|
|
145
|
+
inputTokens += message.usage.input_tokens || 0;
|
|
146
|
+
outputTokens += message.usage.output_tokens || 0;
|
|
147
|
+
cacheCreationTokens += message.usage.cache_creation_input_tokens || 0;
|
|
148
|
+
cacheReadTokens += message.usage.cache_read_input_tokens || 0;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
return {
|
|
153
|
+
response: responseText,
|
|
154
|
+
sessionId: newSessionId,
|
|
155
|
+
inputTokens,
|
|
156
|
+
outputTokens,
|
|
157
|
+
cacheCreationTokens,
|
|
158
|
+
cacheReadTokens,
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Interactive requirements gathering loop
|
|
163
|
+
*/
|
|
164
|
+
async function interactiveSession() {
|
|
165
|
+
console.log(`\n${'ā'.repeat(63)}`);
|
|
166
|
+
console.log('ā Kosuke Requirements - Interactive Requirements Tool ā');
|
|
167
|
+
console.log(`${'ā'.repeat(63)}\n`);
|
|
168
|
+
console.log('š” This tool will help you create comprehensive product requirements.\n');
|
|
169
|
+
console.log("š I'll analyze your product idea, ask clarification questions,");
|
|
170
|
+
console.log(' and generate a detailed docs.md file.\n');
|
|
171
|
+
const rl = readline.createInterface({
|
|
172
|
+
input: process.stdin,
|
|
173
|
+
output: process.stdout,
|
|
174
|
+
});
|
|
175
|
+
const session = {
|
|
176
|
+
productDescription: '',
|
|
177
|
+
conversationHistory: [],
|
|
178
|
+
isFirstRequest: true,
|
|
179
|
+
};
|
|
180
|
+
let sessionId = null;
|
|
181
|
+
let totalInputTokens = 0;
|
|
182
|
+
let totalOutputTokens = 0;
|
|
183
|
+
let totalCacheCreationTokens = 0;
|
|
184
|
+
let totalCacheReadTokens = 0;
|
|
185
|
+
let totalCost = 0;
|
|
186
|
+
const askQuestion = (prompt) => {
|
|
187
|
+
return new Promise((resolve) => {
|
|
188
|
+
rl.question(prompt, (answer) => {
|
|
189
|
+
resolve(answer.trim());
|
|
190
|
+
});
|
|
191
|
+
});
|
|
192
|
+
};
|
|
193
|
+
try {
|
|
194
|
+
// Initial product description
|
|
195
|
+
console.log("š Let's start! Describe the web application you want to build:\n");
|
|
196
|
+
const productDescription = await askQuestion('You: ');
|
|
197
|
+
if (!productDescription) {
|
|
198
|
+
console.log('\nā No product description provided. Exiting.');
|
|
199
|
+
rl.close();
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
session.productDescription = productDescription;
|
|
203
|
+
session.conversationHistory.push(`User: ${productDescription}`);
|
|
204
|
+
// Main conversation loop
|
|
205
|
+
let continueConversation = true;
|
|
206
|
+
while (continueConversation) {
|
|
207
|
+
console.log('\nš¤ Claude is thinking...\n');
|
|
208
|
+
// Get Claude's response
|
|
209
|
+
const result = await processClaudeInteraction(session.isFirstRequest
|
|
210
|
+
? productDescription
|
|
211
|
+
: session.conversationHistory[session.conversationHistory.length - 1].replace('User: ', ''), sessionId, session.isFirstRequest);
|
|
212
|
+
sessionId = result.sessionId;
|
|
213
|
+
session.isFirstRequest = false;
|
|
214
|
+
// Track costs
|
|
215
|
+
totalInputTokens += result.inputTokens;
|
|
216
|
+
totalOutputTokens += result.outputTokens;
|
|
217
|
+
totalCacheCreationTokens += result.cacheCreationTokens;
|
|
218
|
+
totalCacheReadTokens += result.cacheReadTokens;
|
|
219
|
+
const batchCost = calculateCost(result.inputTokens, result.outputTokens, result.cacheCreationTokens, result.cacheReadTokens);
|
|
220
|
+
totalCost += batchCost;
|
|
221
|
+
// Display Claude's response
|
|
222
|
+
console.log('Claude:\n');
|
|
223
|
+
console.log(result.response);
|
|
224
|
+
console.log('\n' + 'ā'.repeat(60));
|
|
225
|
+
console.log(formatTokenUsage(result.inputTokens, result.outputTokens, result.cacheCreationTokens, result.cacheReadTokens, batchCost));
|
|
226
|
+
console.log('ā'.repeat(60) + '\n');
|
|
227
|
+
session.conversationHistory.push(`Claude: ${result.response}`);
|
|
228
|
+
// Check if docs.md was created
|
|
229
|
+
const docsPath = join(process.cwd(), 'docs.md');
|
|
230
|
+
try {
|
|
231
|
+
const fs = await import('fs');
|
|
232
|
+
if (fs.existsSync(docsPath)) {
|
|
233
|
+
console.log('\nā
Requirements document created: docs.md');
|
|
234
|
+
console.log('\nš Total Session Cost:');
|
|
235
|
+
console.log(formatTokenUsage(totalInputTokens, totalOutputTokens, totalCacheCreationTokens, totalCacheReadTokens, totalCost));
|
|
236
|
+
console.log('\nš Requirements gathering complete!\n');
|
|
237
|
+
continueConversation = false;
|
|
238
|
+
break;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
catch {
|
|
242
|
+
// docs.md not yet created, continue conversation
|
|
243
|
+
}
|
|
244
|
+
// Ask for user response
|
|
245
|
+
console.log('š¬ Your response (or type "exit" to quit):\n');
|
|
246
|
+
const userResponse = await askQuestion('You: ');
|
|
247
|
+
if (!userResponse) {
|
|
248
|
+
console.log('\nā ļø Empty response. Please provide an answer or type "exit".');
|
|
249
|
+
continue;
|
|
250
|
+
}
|
|
251
|
+
if (userResponse.toLowerCase() === 'exit') {
|
|
252
|
+
console.log('\nš Exiting requirements gathering.\n');
|
|
253
|
+
console.log('š Session Cost:');
|
|
254
|
+
console.log(formatTokenUsage(totalInputTokens, totalOutputTokens, totalCacheCreationTokens, totalCacheReadTokens, totalCost));
|
|
255
|
+
continueConversation = false;
|
|
256
|
+
break;
|
|
257
|
+
}
|
|
258
|
+
session.conversationHistory.push(`User: ${userResponse}`);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
catch (error) {
|
|
262
|
+
console.error('\nā Error during requirements gathering:', error);
|
|
263
|
+
throw error;
|
|
264
|
+
}
|
|
265
|
+
finally {
|
|
266
|
+
rl.close();
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* Main requirements command
|
|
271
|
+
*/
|
|
272
|
+
export async function requirementsCommand() {
|
|
273
|
+
try {
|
|
274
|
+
// Validate environment
|
|
275
|
+
if (!process.env.ANTHROPIC_API_KEY) {
|
|
276
|
+
throw new Error('ANTHROPIC_API_KEY environment variable is required');
|
|
277
|
+
}
|
|
278
|
+
// Start interactive session
|
|
279
|
+
await interactiveSession();
|
|
280
|
+
}
|
|
281
|
+
catch (error) {
|
|
282
|
+
console.error('\nā Requirements command failed:', error);
|
|
283
|
+
throw error;
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
//# sourceMappingURL=requirements.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"requirements.js","sourceRoot":"","sources":["../../../kosuke/commands/requirements.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,KAAK,EAAgB,MAAM,gC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