attune-ai 2.1.1__py3-none-any.whl → 2.1.3__py3-none-any.whl
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.
- attune/socratic_router.py +761 -0
- attune/vscode_bridge.py +7 -4
- {attune_ai-2.1.1.dist-info → attune_ai-2.1.3.dist-info}/METADATA +97 -251
- {attune_ai-2.1.1.dist-info → attune_ai-2.1.3.dist-info}/RECORD +9 -8
- {attune_ai-2.1.1.dist-info → attune_ai-2.1.3.dist-info}/WHEEL +0 -0
- {attune_ai-2.1.1.dist-info → attune_ai-2.1.3.dist-info}/entry_points.txt +0 -0
- {attune_ai-2.1.1.dist-info → attune_ai-2.1.3.dist-info}/licenses/LICENSE +0 -0
- {attune_ai-2.1.1.dist-info → attune_ai-2.1.3.dist-info}/licenses/LICENSE_CHANGE_ANNOUNCEMENT.md +0 -0
- {attune_ai-2.1.1.dist-info → attune_ai-2.1.3.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,761 @@
|
|
|
1
|
+
"""Socratic Router - Intent-based workflow discovery.
|
|
2
|
+
|
|
3
|
+
Routes user's natural language goals to AskUserQuestion options.
|
|
4
|
+
Used by the /attune command for Socratic discovery flow.
|
|
5
|
+
|
|
6
|
+
Two modes:
|
|
7
|
+
1. Quick routing: Simple intent classification → AskUserQuestion options → skill invocation
|
|
8
|
+
2. Deep discovery: Full SocraticWorkflowBuilder session for complex agent generation
|
|
9
|
+
|
|
10
|
+
Flow (Quick):
|
|
11
|
+
1. User runs /attune
|
|
12
|
+
2. Claude asks "What are you trying to accomplish?"
|
|
13
|
+
3. User responds naturally
|
|
14
|
+
4. classify_intent() detects category
|
|
15
|
+
5. AskUserQuestion presents 2-4 relevant options
|
|
16
|
+
6. User selects → routes to skill
|
|
17
|
+
|
|
18
|
+
Flow (Deep):
|
|
19
|
+
1. User needs complex workflow generation
|
|
20
|
+
2. SocraticWorkflowBuilder creates multi-round Q&A session
|
|
21
|
+
3. form_to_ask_user_question() converts Forms to AskUserQuestion
|
|
22
|
+
4. Generates custom agent workflow
|
|
23
|
+
|
|
24
|
+
Copyright 2025 Smart-AI-Memory
|
|
25
|
+
Licensed under Fair Source License 0.9
|
|
26
|
+
"""
|
|
27
|
+
|
|
28
|
+
from __future__ import annotations
|
|
29
|
+
|
|
30
|
+
from dataclasses import dataclass
|
|
31
|
+
from enum import Enum
|
|
32
|
+
from typing import TYPE_CHECKING, Any
|
|
33
|
+
|
|
34
|
+
if TYPE_CHECKING:
|
|
35
|
+
from attune.socratic import Form, SocraticSession
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
class IntentCategory(Enum):
|
|
39
|
+
"""High-level categories of user intent."""
|
|
40
|
+
|
|
41
|
+
FIX = "fix" # Debug, fix bugs, resolve errors
|
|
42
|
+
IMPROVE = "improve" # Refactor, optimize, clean up
|
|
43
|
+
VALIDATE = "validate" # Test, review, audit
|
|
44
|
+
SHIP = "ship" # Commit, PR, release
|
|
45
|
+
UNDERSTAND = "understand" # Explain, document, explore
|
|
46
|
+
UNKNOWN = "unknown" # Needs clarification
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
@dataclass
|
|
50
|
+
class WorkflowOption:
|
|
51
|
+
"""A workflow option for AskUserQuestion.
|
|
52
|
+
|
|
53
|
+
Attributes:
|
|
54
|
+
label: Short label for the option (1-5 words)
|
|
55
|
+
description: What this option does
|
|
56
|
+
skill: The skill to invoke
|
|
57
|
+
args: Arguments for the skill
|
|
58
|
+
"""
|
|
59
|
+
|
|
60
|
+
label: str
|
|
61
|
+
description: str
|
|
62
|
+
skill: str
|
|
63
|
+
args: str = ""
|
|
64
|
+
|
|
65
|
+
def to_ask_user_option(self) -> dict[str, str]:
|
|
66
|
+
"""Convert to AskUserQuestion option format."""
|
|
67
|
+
return {"label": self.label, "description": self.description}
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
@dataclass
|
|
71
|
+
class IntentClassification:
|
|
72
|
+
"""Result of classifying user intent.
|
|
73
|
+
|
|
74
|
+
Attributes:
|
|
75
|
+
category: Primary intent category
|
|
76
|
+
confidence: Confidence score (0-1)
|
|
77
|
+
keywords_matched: Keywords that triggered this classification
|
|
78
|
+
suggested_question: Question to ask via AskUserQuestion
|
|
79
|
+
options: Workflow options to present
|
|
80
|
+
"""
|
|
81
|
+
|
|
82
|
+
category: IntentCategory
|
|
83
|
+
confidence: float
|
|
84
|
+
keywords_matched: list[str]
|
|
85
|
+
suggested_question: str
|
|
86
|
+
options: list[WorkflowOption]
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
# Intent detection patterns
|
|
90
|
+
INTENT_PATTERNS: dict[IntentCategory, dict[str, Any]] = {
|
|
91
|
+
IntentCategory.FIX: {
|
|
92
|
+
"keywords": [
|
|
93
|
+
"fix",
|
|
94
|
+
"bug",
|
|
95
|
+
"error",
|
|
96
|
+
"broken",
|
|
97
|
+
"crash",
|
|
98
|
+
"fail",
|
|
99
|
+
"issue",
|
|
100
|
+
"problem",
|
|
101
|
+
"debug",
|
|
102
|
+
"wrong",
|
|
103
|
+
"doesn't work",
|
|
104
|
+
"not working",
|
|
105
|
+
"exception",
|
|
106
|
+
"traceback",
|
|
107
|
+
],
|
|
108
|
+
"question": "What kind of issue are you dealing with?",
|
|
109
|
+
"options": [
|
|
110
|
+
WorkflowOption(
|
|
111
|
+
label="Debug an error",
|
|
112
|
+
description="Investigate exceptions, trace execution, find root cause",
|
|
113
|
+
skill="dev",
|
|
114
|
+
args="debug",
|
|
115
|
+
),
|
|
116
|
+
WorkflowOption(
|
|
117
|
+
label="Fix failing tests",
|
|
118
|
+
description="Analyze test failures and fix the underlying code",
|
|
119
|
+
skill="testing",
|
|
120
|
+
args="run",
|
|
121
|
+
),
|
|
122
|
+
WorkflowOption(
|
|
123
|
+
label="Review for bugs",
|
|
124
|
+
description="Code review focused on finding potential bugs",
|
|
125
|
+
skill="dev",
|
|
126
|
+
args="review",
|
|
127
|
+
),
|
|
128
|
+
WorkflowOption(
|
|
129
|
+
label="Something else",
|
|
130
|
+
description="Describe your specific issue",
|
|
131
|
+
skill="attune",
|
|
132
|
+
args="",
|
|
133
|
+
),
|
|
134
|
+
],
|
|
135
|
+
},
|
|
136
|
+
IntentCategory.IMPROVE: {
|
|
137
|
+
"keywords": [
|
|
138
|
+
"refactor",
|
|
139
|
+
"improve",
|
|
140
|
+
"clean",
|
|
141
|
+
"optimize",
|
|
142
|
+
"simplify",
|
|
143
|
+
"better",
|
|
144
|
+
"performance",
|
|
145
|
+
"speed",
|
|
146
|
+
"faster",
|
|
147
|
+
"memory",
|
|
148
|
+
"too long",
|
|
149
|
+
"complex",
|
|
150
|
+
"messy",
|
|
151
|
+
"ugly",
|
|
152
|
+
],
|
|
153
|
+
"question": "What would you like to improve?",
|
|
154
|
+
"options": [
|
|
155
|
+
WorkflowOption(
|
|
156
|
+
label="Refactor code",
|
|
157
|
+
description="Improve structure, extract functions, simplify logic",
|
|
158
|
+
skill="dev",
|
|
159
|
+
args="refactor",
|
|
160
|
+
),
|
|
161
|
+
WorkflowOption(
|
|
162
|
+
label="Optimize performance",
|
|
163
|
+
description="Find bottlenecks, improve speed and memory usage",
|
|
164
|
+
skill="workflows",
|
|
165
|
+
args="run perf-audit",
|
|
166
|
+
),
|
|
167
|
+
WorkflowOption(
|
|
168
|
+
label="Code review",
|
|
169
|
+
description="Get feedback on code quality and patterns",
|
|
170
|
+
skill="dev",
|
|
171
|
+
args="review",
|
|
172
|
+
),
|
|
173
|
+
WorkflowOption(
|
|
174
|
+
label="Something else",
|
|
175
|
+
description="Describe what you want to improve",
|
|
176
|
+
skill="attune",
|
|
177
|
+
args="",
|
|
178
|
+
),
|
|
179
|
+
],
|
|
180
|
+
},
|
|
181
|
+
IntentCategory.VALIDATE: {
|
|
182
|
+
"keywords": [
|
|
183
|
+
"test",
|
|
184
|
+
"coverage",
|
|
185
|
+
"security",
|
|
186
|
+
"audit",
|
|
187
|
+
"check",
|
|
188
|
+
"verify",
|
|
189
|
+
"validate",
|
|
190
|
+
"review",
|
|
191
|
+
"safe",
|
|
192
|
+
"secure",
|
|
193
|
+
"vulnerability",
|
|
194
|
+
],
|
|
195
|
+
"question": "What would you like to validate?",
|
|
196
|
+
"options": [
|
|
197
|
+
WorkflowOption(
|
|
198
|
+
label="Run tests",
|
|
199
|
+
description="Execute test suite and see results",
|
|
200
|
+
skill="testing",
|
|
201
|
+
args="run",
|
|
202
|
+
),
|
|
203
|
+
WorkflowOption(
|
|
204
|
+
label="Check coverage",
|
|
205
|
+
description="Analyze test coverage and identify gaps",
|
|
206
|
+
skill="testing",
|
|
207
|
+
args="coverage",
|
|
208
|
+
),
|
|
209
|
+
WorkflowOption(
|
|
210
|
+
label="Security audit",
|
|
211
|
+
description="Scan for vulnerabilities and security issues",
|
|
212
|
+
skill="workflows",
|
|
213
|
+
args="run security-audit",
|
|
214
|
+
),
|
|
215
|
+
WorkflowOption(
|
|
216
|
+
label="Code review",
|
|
217
|
+
description="Quality and pattern analysis",
|
|
218
|
+
skill="dev",
|
|
219
|
+
args="review",
|
|
220
|
+
),
|
|
221
|
+
],
|
|
222
|
+
},
|
|
223
|
+
IntentCategory.SHIP: {
|
|
224
|
+
"keywords": [
|
|
225
|
+
"commit",
|
|
226
|
+
"push",
|
|
227
|
+
"pr",
|
|
228
|
+
"pull request",
|
|
229
|
+
"merge",
|
|
230
|
+
"release",
|
|
231
|
+
"deploy",
|
|
232
|
+
"ship",
|
|
233
|
+
"publish",
|
|
234
|
+
"done",
|
|
235
|
+
"ready",
|
|
236
|
+
"finished",
|
|
237
|
+
],
|
|
238
|
+
"question": "What stage are you at?",
|
|
239
|
+
"options": [
|
|
240
|
+
WorkflowOption(
|
|
241
|
+
label="Create commit",
|
|
242
|
+
description="Stage changes and create a commit with message",
|
|
243
|
+
skill="dev",
|
|
244
|
+
args="commit",
|
|
245
|
+
),
|
|
246
|
+
WorkflowOption(
|
|
247
|
+
label="Create PR",
|
|
248
|
+
description="Push branch and create pull request",
|
|
249
|
+
skill="dev",
|
|
250
|
+
args="pr",
|
|
251
|
+
),
|
|
252
|
+
WorkflowOption(
|
|
253
|
+
label="Prepare release",
|
|
254
|
+
description="Version bump, changelog, security checks",
|
|
255
|
+
skill="release",
|
|
256
|
+
args="prep",
|
|
257
|
+
),
|
|
258
|
+
WorkflowOption(
|
|
259
|
+
label="Just push",
|
|
260
|
+
description="Push current commits to remote",
|
|
261
|
+
skill="dev",
|
|
262
|
+
args="push",
|
|
263
|
+
),
|
|
264
|
+
],
|
|
265
|
+
},
|
|
266
|
+
IntentCategory.UNDERSTAND: {
|
|
267
|
+
"keywords": [
|
|
268
|
+
"explain",
|
|
269
|
+
"understand",
|
|
270
|
+
"how",
|
|
271
|
+
"what",
|
|
272
|
+
"why",
|
|
273
|
+
"document",
|
|
274
|
+
"docs",
|
|
275
|
+
"readme",
|
|
276
|
+
"learn",
|
|
277
|
+
"show",
|
|
278
|
+
"describe",
|
|
279
|
+
"overview",
|
|
280
|
+
],
|
|
281
|
+
"question": "What would you like to understand?",
|
|
282
|
+
"options": [
|
|
283
|
+
WorkflowOption(
|
|
284
|
+
label="Explain code",
|
|
285
|
+
description="Understand how specific code works",
|
|
286
|
+
skill="docs",
|
|
287
|
+
args="explain",
|
|
288
|
+
),
|
|
289
|
+
WorkflowOption(
|
|
290
|
+
label="Project overview",
|
|
291
|
+
description="High-level architecture and structure",
|
|
292
|
+
skill="docs",
|
|
293
|
+
args="overview",
|
|
294
|
+
),
|
|
295
|
+
WorkflowOption(
|
|
296
|
+
label="Generate docs",
|
|
297
|
+
description="Create or update documentation",
|
|
298
|
+
skill="docs",
|
|
299
|
+
args="generate",
|
|
300
|
+
),
|
|
301
|
+
WorkflowOption(
|
|
302
|
+
label="Something specific",
|
|
303
|
+
description="Ask about a specific part of the codebase",
|
|
304
|
+
skill="attune",
|
|
305
|
+
args="",
|
|
306
|
+
),
|
|
307
|
+
],
|
|
308
|
+
},
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
|
|
312
|
+
def classify_intent(user_response: str) -> IntentClassification:
|
|
313
|
+
"""Classify user's natural language response into intent category.
|
|
314
|
+
|
|
315
|
+
Args:
|
|
316
|
+
user_response: User's answer to "What are you trying to accomplish?"
|
|
317
|
+
|
|
318
|
+
Returns:
|
|
319
|
+
IntentClassification with category, options, and metadata
|
|
320
|
+
"""
|
|
321
|
+
response_lower = user_response.lower()
|
|
322
|
+
|
|
323
|
+
best_category = IntentCategory.UNKNOWN
|
|
324
|
+
best_score = 0
|
|
325
|
+
matched_keywords: list[str] = []
|
|
326
|
+
|
|
327
|
+
# Score each category based on keyword matches
|
|
328
|
+
for category, pattern in INTENT_PATTERNS.items():
|
|
329
|
+
keywords = pattern["keywords"]
|
|
330
|
+
score = 0
|
|
331
|
+
matches = []
|
|
332
|
+
|
|
333
|
+
for keyword in keywords:
|
|
334
|
+
if keyword in response_lower:
|
|
335
|
+
score += 1
|
|
336
|
+
matches.append(keyword)
|
|
337
|
+
|
|
338
|
+
if score > best_score:
|
|
339
|
+
best_score = score
|
|
340
|
+
best_category = category
|
|
341
|
+
matched_keywords = matches
|
|
342
|
+
|
|
343
|
+
# Calculate confidence
|
|
344
|
+
if best_score == 0:
|
|
345
|
+
confidence = 0.0
|
|
346
|
+
elif best_score >= 3:
|
|
347
|
+
confidence = 0.95
|
|
348
|
+
elif best_score >= 2:
|
|
349
|
+
confidence = 0.8
|
|
350
|
+
else:
|
|
351
|
+
confidence = 0.6
|
|
352
|
+
|
|
353
|
+
# Get options for the category
|
|
354
|
+
if best_category in INTENT_PATTERNS:
|
|
355
|
+
pattern = INTENT_PATTERNS[best_category]
|
|
356
|
+
return IntentClassification(
|
|
357
|
+
category=best_category,
|
|
358
|
+
confidence=confidence,
|
|
359
|
+
keywords_matched=matched_keywords,
|
|
360
|
+
suggested_question=pattern["question"],
|
|
361
|
+
options=pattern["options"],
|
|
362
|
+
)
|
|
363
|
+
|
|
364
|
+
# Unknown intent - ask for clarification
|
|
365
|
+
return IntentClassification(
|
|
366
|
+
category=IntentCategory.UNKNOWN,
|
|
367
|
+
confidence=0.0,
|
|
368
|
+
keywords_matched=[],
|
|
369
|
+
suggested_question="Could you tell me more about what you're trying to do?",
|
|
370
|
+
options=[
|
|
371
|
+
WorkflowOption(
|
|
372
|
+
label="Fix something",
|
|
373
|
+
description="Debug errors, fix bugs, resolve issues",
|
|
374
|
+
skill="dev",
|
|
375
|
+
args="debug",
|
|
376
|
+
),
|
|
377
|
+
WorkflowOption(
|
|
378
|
+
label="Improve code",
|
|
379
|
+
description="Refactor, optimize, clean up",
|
|
380
|
+
skill="dev",
|
|
381
|
+
args="refactor",
|
|
382
|
+
),
|
|
383
|
+
WorkflowOption(
|
|
384
|
+
label="Validate work",
|
|
385
|
+
description="Test, review, audit for security",
|
|
386
|
+
skill="testing",
|
|
387
|
+
args="run",
|
|
388
|
+
),
|
|
389
|
+
WorkflowOption(
|
|
390
|
+
label="Ship changes",
|
|
391
|
+
description="Commit, create PR, release",
|
|
392
|
+
skill="dev",
|
|
393
|
+
args="commit",
|
|
394
|
+
),
|
|
395
|
+
],
|
|
396
|
+
)
|
|
397
|
+
|
|
398
|
+
|
|
399
|
+
def get_ask_user_question_format(classification: IntentClassification) -> dict[str, Any]:
|
|
400
|
+
"""Convert classification to AskUserQuestion tool format.
|
|
401
|
+
|
|
402
|
+
Args:
|
|
403
|
+
classification: Result from classify_intent()
|
|
404
|
+
|
|
405
|
+
Returns:
|
|
406
|
+
Dict ready to pass to AskUserQuestion tool
|
|
407
|
+
"""
|
|
408
|
+
return {
|
|
409
|
+
"questions": [
|
|
410
|
+
{
|
|
411
|
+
"question": classification.suggested_question,
|
|
412
|
+
"header": classification.category.value.title(),
|
|
413
|
+
"options": [opt.to_ask_user_option() for opt in classification.options],
|
|
414
|
+
"multiSelect": False,
|
|
415
|
+
}
|
|
416
|
+
]
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
|
|
420
|
+
def get_skill_for_selection(
|
|
421
|
+
classification: IntentClassification, selected_label: str
|
|
422
|
+
) -> tuple[str, str]:
|
|
423
|
+
"""Get skill and args for user's selection.
|
|
424
|
+
|
|
425
|
+
Args:
|
|
426
|
+
classification: The classification that was shown to user
|
|
427
|
+
selected_label: The label the user selected
|
|
428
|
+
|
|
429
|
+
Returns:
|
|
430
|
+
Tuple of (skill, args) to invoke
|
|
431
|
+
"""
|
|
432
|
+
for option in classification.options:
|
|
433
|
+
if option.label == selected_label:
|
|
434
|
+
return option.skill, option.args
|
|
435
|
+
|
|
436
|
+
# Fallback to first option if not found
|
|
437
|
+
if classification.options:
|
|
438
|
+
return classification.options[0].skill, classification.options[0].args
|
|
439
|
+
|
|
440
|
+
return "attune", ""
|
|
441
|
+
|
|
442
|
+
|
|
443
|
+
# Convenience function for the /attune command
|
|
444
|
+
def process_socratic_response(user_response: str) -> dict[str, Any]:
|
|
445
|
+
"""Process user's response to Socratic question.
|
|
446
|
+
|
|
447
|
+
This is the main entry point for the /attune command after
|
|
448
|
+
asking "What are you trying to accomplish?"
|
|
449
|
+
|
|
450
|
+
Args:
|
|
451
|
+
user_response: User's natural language response
|
|
452
|
+
|
|
453
|
+
Returns:
|
|
454
|
+
Dict with:
|
|
455
|
+
- classification: IntentClassification object
|
|
456
|
+
- ask_user_format: Ready-to-use AskUserQuestion format
|
|
457
|
+
- confidence: How confident we are in the classification
|
|
458
|
+
"""
|
|
459
|
+
classification = classify_intent(user_response)
|
|
460
|
+
|
|
461
|
+
return {
|
|
462
|
+
"classification": classification,
|
|
463
|
+
"ask_user_format": get_ask_user_question_format(classification),
|
|
464
|
+
"confidence": classification.confidence,
|
|
465
|
+
"category": classification.category.value,
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
|
|
469
|
+
# =============================================================================
|
|
470
|
+
# DEEP DISCOVERY - SocraticWorkflowBuilder Integration
|
|
471
|
+
# =============================================================================
|
|
472
|
+
|
|
473
|
+
|
|
474
|
+
def form_to_ask_user_question(form: Form) -> dict[str, Any]:
|
|
475
|
+
"""Convert a SocraticWorkflowBuilder Form to AskUserQuestion format.
|
|
476
|
+
|
|
477
|
+
This bridges the Socratic system's Form objects with Claude Code's
|
|
478
|
+
AskUserQuestion tool.
|
|
479
|
+
|
|
480
|
+
Args:
|
|
481
|
+
form: Form from SocraticWorkflowBuilder.get_next_questions()
|
|
482
|
+
|
|
483
|
+
Returns:
|
|
484
|
+
Dict ready to pass to AskUserQuestion tool
|
|
485
|
+
|
|
486
|
+
Example:
|
|
487
|
+
>>> from attune.socratic import SocraticWorkflowBuilder
|
|
488
|
+
>>> builder = SocraticWorkflowBuilder()
|
|
489
|
+
>>> session = builder.start_session("automate code reviews")
|
|
490
|
+
>>> form = builder.get_next_questions(session)
|
|
491
|
+
>>> ask_user_format = form_to_ask_user_question(form)
|
|
492
|
+
"""
|
|
493
|
+
from attune.socratic.forms import FieldType
|
|
494
|
+
|
|
495
|
+
questions = []
|
|
496
|
+
|
|
497
|
+
for field in form.fields:
|
|
498
|
+
# Convert field to question format
|
|
499
|
+
question_data = {
|
|
500
|
+
"question": field.label,
|
|
501
|
+
"header": field.category.title() if field.category else "Question",
|
|
502
|
+
"multiSelect": field.field_type == FieldType.MULTI_SELECT,
|
|
503
|
+
"options": [],
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
# Convert options
|
|
507
|
+
if field.options:
|
|
508
|
+
for opt in field.options[:4]: # AskUserQuestion max 4 options
|
|
509
|
+
option_data = {"label": opt.value, "description": opt.description or opt.label}
|
|
510
|
+
if opt.recommended:
|
|
511
|
+
option_data["label"] += " (Recommended)"
|
|
512
|
+
question_data["options"].append(option_data)
|
|
513
|
+
else:
|
|
514
|
+
# Text field - provide generic options
|
|
515
|
+
question_data["options"] = [
|
|
516
|
+
{"label": "Continue", "description": "Proceed with current settings"},
|
|
517
|
+
{"label": "Customize", "description": "I want to specify details"},
|
|
518
|
+
]
|
|
519
|
+
|
|
520
|
+
questions.append(question_data)
|
|
521
|
+
|
|
522
|
+
# Limit to 4 questions per AskUserQuestion call
|
|
523
|
+
return {"questions": questions[:4]}
|
|
524
|
+
|
|
525
|
+
|
|
526
|
+
def should_use_deep_discovery(user_response: str, classification: IntentClassification) -> bool:
|
|
527
|
+
"""Determine if we should use full SocraticWorkflowBuilder.
|
|
528
|
+
|
|
529
|
+
Use deep discovery when:
|
|
530
|
+
- Low confidence classification
|
|
531
|
+
- User wants to create custom agents/workflows
|
|
532
|
+
- Complex multi-step requirements
|
|
533
|
+
|
|
534
|
+
Args:
|
|
535
|
+
user_response: User's natural language response
|
|
536
|
+
classification: Result from classify_intent()
|
|
537
|
+
|
|
538
|
+
Returns:
|
|
539
|
+
True if should use SocraticWorkflowBuilder, False for quick routing
|
|
540
|
+
"""
|
|
541
|
+
# Low confidence - need more clarification
|
|
542
|
+
if classification.confidence < 0.5:
|
|
543
|
+
return True
|
|
544
|
+
|
|
545
|
+
# Explicit agent/workflow creation keywords
|
|
546
|
+
deep_keywords = [
|
|
547
|
+
"create agent",
|
|
548
|
+
"custom workflow",
|
|
549
|
+
"build workflow",
|
|
550
|
+
"automate",
|
|
551
|
+
"automation",
|
|
552
|
+
"generate agents",
|
|
553
|
+
"multi-step",
|
|
554
|
+
"pipeline",
|
|
555
|
+
]
|
|
556
|
+
|
|
557
|
+
response_lower = user_response.lower()
|
|
558
|
+
for keyword in deep_keywords:
|
|
559
|
+
if keyword in response_lower:
|
|
560
|
+
return True
|
|
561
|
+
|
|
562
|
+
return False
|
|
563
|
+
|
|
564
|
+
|
|
565
|
+
def start_deep_discovery(goal: str) -> tuple[SocraticSession, dict[str, Any]]:
|
|
566
|
+
"""Start a full SocraticWorkflowBuilder session.
|
|
567
|
+
|
|
568
|
+
Args:
|
|
569
|
+
goal: User's goal statement
|
|
570
|
+
|
|
571
|
+
Returns:
|
|
572
|
+
Tuple of (session, ask_user_format)
|
|
573
|
+
|
|
574
|
+
Example:
|
|
575
|
+
>>> session, questions = start_deep_discovery("automate security reviews")
|
|
576
|
+
>>> # Use questions with AskUserQuestion tool
|
|
577
|
+
>>> # Then call continue_deep_discovery(session, answers)
|
|
578
|
+
"""
|
|
579
|
+
from attune.socratic import SocraticWorkflowBuilder
|
|
580
|
+
|
|
581
|
+
builder = SocraticWorkflowBuilder()
|
|
582
|
+
session = builder.start_session(goal)
|
|
583
|
+
form = builder.get_next_questions(session)
|
|
584
|
+
|
|
585
|
+
if form:
|
|
586
|
+
ask_user_format = form_to_ask_user_question(form)
|
|
587
|
+
else:
|
|
588
|
+
# Session ready to generate
|
|
589
|
+
ask_user_format = {
|
|
590
|
+
"questions": [
|
|
591
|
+
{
|
|
592
|
+
"question": "Ready to generate your workflow. Proceed?",
|
|
593
|
+
"header": "Generate",
|
|
594
|
+
"options": [
|
|
595
|
+
{"label": "Generate", "description": "Create the workflow now"},
|
|
596
|
+
{"label": "Add details", "description": "I want to specify more"},
|
|
597
|
+
],
|
|
598
|
+
"multiSelect": False,
|
|
599
|
+
}
|
|
600
|
+
]
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
return session, ask_user_format
|
|
604
|
+
|
|
605
|
+
|
|
606
|
+
def continue_deep_discovery(
|
|
607
|
+
session: SocraticSession, answers: dict[str, Any]
|
|
608
|
+
) -> tuple[SocraticSession, dict[str, Any] | None]:
|
|
609
|
+
"""Continue a SocraticWorkflowBuilder session with answers.
|
|
610
|
+
|
|
611
|
+
Args:
|
|
612
|
+
session: Active session from start_deep_discovery
|
|
613
|
+
answers: User's answers to previous questions
|
|
614
|
+
|
|
615
|
+
Returns:
|
|
616
|
+
Tuple of (updated_session, next_questions_or_None)
|
|
617
|
+
"""
|
|
618
|
+
from attune.socratic import SocraticWorkflowBuilder
|
|
619
|
+
|
|
620
|
+
builder = SocraticWorkflowBuilder()
|
|
621
|
+
builder._sessions[session.session_id] = session
|
|
622
|
+
|
|
623
|
+
session = builder.submit_answers(session, answers)
|
|
624
|
+
|
|
625
|
+
if builder.is_ready_to_generate(session):
|
|
626
|
+
return session, None
|
|
627
|
+
|
|
628
|
+
form = builder.get_next_questions(session)
|
|
629
|
+
if form:
|
|
630
|
+
return session, form_to_ask_user_question(form)
|
|
631
|
+
|
|
632
|
+
return session, None
|
|
633
|
+
|
|
634
|
+
|
|
635
|
+
# =============================================================================
|
|
636
|
+
# UNIFIED ENTRY POINT
|
|
637
|
+
# =============================================================================
|
|
638
|
+
|
|
639
|
+
|
|
640
|
+
class AttuneRouter:
|
|
641
|
+
"""Unified router for /attune command.
|
|
642
|
+
|
|
643
|
+
Handles both quick routing and deep discovery modes.
|
|
644
|
+
|
|
645
|
+
Example (Claude Code /attune command):
|
|
646
|
+
>>> router = AttuneRouter()
|
|
647
|
+
>>>
|
|
648
|
+
>>> # User says: "I need to fix a bug"
|
|
649
|
+
>>> result = router.process("I need to fix a bug")
|
|
650
|
+
>>>
|
|
651
|
+
>>> if result["mode"] == "quick":
|
|
652
|
+
>>> # Use AskUserQuestion with result["ask_user_format"]
|
|
653
|
+
>>> # Then call router.route_selection(result, user_selection)
|
|
654
|
+
>>>
|
|
655
|
+
>>> elif result["mode"] == "deep":
|
|
656
|
+
>>> # Multi-round discovery session
|
|
657
|
+
>>> # Use AskUserQuestion, then router.continue_session(...)
|
|
658
|
+
"""
|
|
659
|
+
|
|
660
|
+
def __init__(self):
|
|
661
|
+
"""Initialize the router."""
|
|
662
|
+
self._sessions: dict[str, SocraticSession] = {}
|
|
663
|
+
|
|
664
|
+
def process(self, user_response: str) -> dict[str, Any]:
|
|
665
|
+
"""Process user's response and determine routing mode.
|
|
666
|
+
|
|
667
|
+
Args:
|
|
668
|
+
user_response: User's answer to "What are you trying to accomplish?"
|
|
669
|
+
|
|
670
|
+
Returns:
|
|
671
|
+
Dict with:
|
|
672
|
+
- mode: "quick" or "deep"
|
|
673
|
+
- ask_user_format: Ready for AskUserQuestion tool
|
|
674
|
+
- classification: (quick mode) IntentClassification
|
|
675
|
+
- session: (deep mode) SocraticSession
|
|
676
|
+
"""
|
|
677
|
+
classification = classify_intent(user_response)
|
|
678
|
+
|
|
679
|
+
if should_use_deep_discovery(user_response, classification):
|
|
680
|
+
session, ask_user_format = start_deep_discovery(user_response)
|
|
681
|
+
self._sessions[session.session_id] = session
|
|
682
|
+
|
|
683
|
+
return {
|
|
684
|
+
"mode": "deep",
|
|
685
|
+
"session_id": session.session_id,
|
|
686
|
+
"ask_user_format": ask_user_format,
|
|
687
|
+
"classification": classification,
|
|
688
|
+
}
|
|
689
|
+
else:
|
|
690
|
+
return {
|
|
691
|
+
"mode": "quick",
|
|
692
|
+
"ask_user_format": get_ask_user_question_format(classification),
|
|
693
|
+
"classification": classification,
|
|
694
|
+
"category": classification.category.value,
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
def route_selection(
|
|
698
|
+
self, process_result: dict[str, Any], selected_label: str
|
|
699
|
+
) -> dict[str, Any]:
|
|
700
|
+
"""Route user's selection to skill invocation.
|
|
701
|
+
|
|
702
|
+
Args:
|
|
703
|
+
process_result: Result from process()
|
|
704
|
+
selected_label: Label user selected in AskUserQuestion
|
|
705
|
+
|
|
706
|
+
Returns:
|
|
707
|
+
Dict with skill and args to invoke
|
|
708
|
+
"""
|
|
709
|
+
classification = process_result.get("classification")
|
|
710
|
+
|
|
711
|
+
if classification:
|
|
712
|
+
skill, args = get_skill_for_selection(classification, selected_label)
|
|
713
|
+
else:
|
|
714
|
+
skill, args = "attune", ""
|
|
715
|
+
|
|
716
|
+
return {
|
|
717
|
+
"skill": skill,
|
|
718
|
+
"args": args,
|
|
719
|
+
"instruction": f"Use Skill tool with skill='{skill}'"
|
|
720
|
+
+ (f", args='{args}'" if args else ""),
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
def continue_session(
|
|
724
|
+
self, session_id: str, answers: dict[str, Any]
|
|
725
|
+
) -> dict[str, Any]:
|
|
726
|
+
"""Continue a deep discovery session.
|
|
727
|
+
|
|
728
|
+
Args:
|
|
729
|
+
session_id: Session ID from process() result
|
|
730
|
+
answers: User's answers to questions
|
|
731
|
+
|
|
732
|
+
Returns:
|
|
733
|
+
Dict with next questions or generated workflow
|
|
734
|
+
"""
|
|
735
|
+
session = self._sessions.get(session_id)
|
|
736
|
+
if not session:
|
|
737
|
+
return {"error": "Session not found"}
|
|
738
|
+
|
|
739
|
+
session, next_questions = continue_deep_discovery(session, answers)
|
|
740
|
+
self._sessions[session_id] = session
|
|
741
|
+
|
|
742
|
+
if next_questions:
|
|
743
|
+
return {
|
|
744
|
+
"mode": "deep",
|
|
745
|
+
"session_id": session_id,
|
|
746
|
+
"ask_user_format": next_questions,
|
|
747
|
+
}
|
|
748
|
+
else:
|
|
749
|
+
# Ready to generate
|
|
750
|
+
from attune.socratic import SocraticWorkflowBuilder
|
|
751
|
+
|
|
752
|
+
builder = SocraticWorkflowBuilder()
|
|
753
|
+
builder._sessions[session_id] = session
|
|
754
|
+
workflow = builder.generate_workflow(session)
|
|
755
|
+
|
|
756
|
+
return {
|
|
757
|
+
"mode": "complete",
|
|
758
|
+
"session_id": session_id,
|
|
759
|
+
"workflow": workflow,
|
|
760
|
+
"summary": builder.get_session_summary(session),
|
|
761
|
+
}
|
attune/vscode_bridge.py
CHANGED
|
@@ -43,10 +43,13 @@ class CodeReviewResult:
|
|
|
43
43
|
|
|
44
44
|
|
|
45
45
|
def get_empathy_dir() -> Path:
|
|
46
|
-
"""Get the .
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
46
|
+
"""Get the .attune directory, creating if needed.
|
|
47
|
+
|
|
48
|
+
Note: Function retains 'empathy' name for backward compatibility.
|
|
49
|
+
"""
|
|
50
|
+
attune_dir = Path(".attune")
|
|
51
|
+
attune_dir.mkdir(exist_ok=True)
|
|
52
|
+
return attune_dir
|
|
50
53
|
|
|
51
54
|
|
|
52
55
|
def write_code_review_results(
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: attune-ai
|
|
3
|
-
Version: 2.1.
|
|
3
|
+
Version: 2.1.3
|
|
4
4
|
Summary: AI collaboration framework with real LLM agent execution, AskUserQuestion tool integration, Socratic agent generation, progressive tier escalation (70-85% cost savings), meta-orchestration, dynamic agent composition (10 patterns including Anthropic-inspired), intelligent caching (85% hit rate), semantic workflow discovery, visual workflow editor, MCP integration for Claude Code, and multi-agent orchestration.
|
|
5
5
|
Author-email: Patrick Roebuck <admin@smartaimemory.com>
|
|
6
6
|
Maintainer-email: Smart-AI-Memory <admin@smartaimemory.com>
|
|
@@ -421,11 +421,11 @@ Requires-Dist: aiohttp<4.0.0,>=3.10.0; extra == "all"
|
|
|
421
421
|
Requires-Dist: filelock<4.0.0,>=3.16.0; extra == "all"
|
|
422
422
|
Dynamic: license-file
|
|
423
423
|
|
|
424
|
-
#
|
|
424
|
+
# Attune AI
|
|
425
425
|
|
|
426
|
-
**AI-powered developer workflows with
|
|
426
|
+
**AI-powered developer workflows with cost optimization and intelligent routing.**
|
|
427
427
|
|
|
428
|
-
Run code review, debugging, testing, and release workflows from Claude Code.
|
|
428
|
+
Run code review, debugging, testing, and release workflows from your terminal or Claude Code. Smart tier routing saves 34-86% on LLM costs.
|
|
429
429
|
|
|
430
430
|
[](https://pypi.org/project/attune-ai/)
|
|
431
431
|
[-brightgreen)](https://github.com/Smart-AI-Memory/attune-ai/actions)
|
|
@@ -438,26 +438,38 @@ pip install attune-ai[developer]
|
|
|
438
438
|
|
|
439
439
|
---
|
|
440
440
|
|
|
441
|
-
##
|
|
441
|
+
## Key Features
|
|
442
442
|
|
|
443
|
-
|
|
443
|
+
### Claude-Native Architecture
|
|
444
444
|
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
445
|
+
Attune AI is built exclusively for Anthropic/Claude, unlocking features impossible with multi-provider abstraction:
|
|
446
|
+
|
|
447
|
+
- **Prompt Caching** - 90% cost reduction on repeated prompts
|
|
448
|
+
- **Flexible Context** - 200K via subscription, up to 1M via API for large codebases
|
|
449
|
+
- **Extended Thinking** - Access Claude's internal reasoning process
|
|
450
|
+
- **Advanced Tool Use** - Optimized for agentic workflows
|
|
451
|
+
|
|
452
|
+
### Multi-Agent Orchestration
|
|
453
|
+
|
|
454
|
+
Full support for custom agents and Anthropic LLM agents:
|
|
450
455
|
|
|
451
|
-
**
|
|
456
|
+
- **Agent Coordination Dashboard** - Real-time monitoring with 6 coordination patterns
|
|
457
|
+
- **Custom Agents** - Build specialized agents for your workflow needs
|
|
458
|
+
- **Inter-Agent Communication** - Heartbeats, signals, events, and approval gates
|
|
452
459
|
|
|
453
|
-
|
|
454
|
-
- ✅ **Validate work** → Tests, coverage, security audit
|
|
455
|
-
- 🚀 **Ship changes** → Commit, PR, release
|
|
456
|
-
- 📚 **Understand** → Explain code, generate docs
|
|
460
|
+
### Intelligent Cost Optimization
|
|
457
461
|
|
|
458
|
-
|
|
462
|
+
- **$0 in Claude Code** - Workflows run as skills through Claude's Task tool
|
|
463
|
+
- **Smart Tier Routing** - Automatically selects the right model for each task
|
|
464
|
+
- **Authentication Strategy** - Routes between subscription and API based on codebase size
|
|
459
465
|
|
|
460
|
-
|
|
466
|
+
### Socratic Workflows
|
|
467
|
+
|
|
468
|
+
Workflows guide you through discovery instead of requiring upfront configuration:
|
|
469
|
+
|
|
470
|
+
- **Interactive Discovery** - Asks targeted questions to understand your needs
|
|
471
|
+
- **Context Gathering** - Collects relevant code, errors, and constraints
|
|
472
|
+
- **Dynamic Agent Creation** - Assembles the right team based on your answers
|
|
461
473
|
|
|
462
474
|
---
|
|
463
475
|
|
|
@@ -475,74 +487,31 @@ pip install attune-ai[developer]
|
|
|
475
487
|
# Auto-detect API keys
|
|
476
488
|
python -m attune.models.cli provider
|
|
477
489
|
|
|
478
|
-
# Or
|
|
479
|
-
python -m attune.models.
|
|
490
|
+
# Or configure authentication strategy
|
|
491
|
+
python -m attune.models.auth_cli setup
|
|
480
492
|
```
|
|
481
493
|
|
|
482
|
-
### 3. Use
|
|
483
|
-
|
|
484
|
-
**In Claude Code:**
|
|
494
|
+
### 3. Use in Claude Code
|
|
485
495
|
|
|
486
496
|
```bash
|
|
487
497
|
/dev # Developer tools (debug, commit, PR, review)
|
|
488
|
-
/testing # Run tests, coverage, benchmarks
|
|
498
|
+
/testing # Run tests, coverage analysis, benchmarks
|
|
489
499
|
/workflows # Automated analysis (security, bugs, perf)
|
|
490
|
-
/plan # Planning, TDD, code review
|
|
500
|
+
/plan # Planning, TDD, code review, refactoring
|
|
491
501
|
/docs # Documentation generation
|
|
492
502
|
/release # Release preparation
|
|
493
503
|
|
|
494
504
|
# Natural language support:
|
|
495
505
|
/workflows "find security issues"
|
|
496
506
|
/plan "review my code"
|
|
497
|
-
|
|
498
|
-
# Direct tool access via MCP (v5.1.1+):
|
|
499
|
-
# Claude Code automatically discovers Empathy tools through the MCP server
|
|
500
|
-
# Just describe what you need in natural language:
|
|
501
|
-
"Run a security audit on src/" → Invokes security_audit tool
|
|
502
|
-
"Generate tests for config.py" → Invokes test_generation tool
|
|
503
|
-
"Check my auth configuration" → Invokes auth_status tool
|
|
504
|
-
"Analyze performance bottlenecks" → Invokes performance_audit tool
|
|
505
507
|
```
|
|
506
508
|
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
Empathy Framework now includes a Model Context Protocol (MCP) server that exposes all workflows as native Claude Code tools:
|
|
510
|
-
|
|
511
|
-
- **10 Tools Available:** security_audit, bug_predict, code_review, test_generation, performance_audit, release_prep, auth_status, auth_recommend, telemetry_stats, dashboard_status
|
|
512
|
-
- **Automatic Discovery:** No manual configuration needed - Claude Code finds tools via `.claude/mcp.json`
|
|
513
|
-
- **Natural Language Access:** Describe your need and Claude invokes the appropriate tool
|
|
514
|
-
- **Verification Hooks:** Automatic validation of Python/JSON files and workflow outputs
|
|
515
|
-
|
|
516
|
-
To verify MCP integration:
|
|
509
|
+
### 4. Use via CLI
|
|
517
510
|
|
|
518
511
|
```bash
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
# Restart Claude Code to load the MCP server
|
|
523
|
-
# Tools will appear in Claude's tool list automatically
|
|
524
|
-
```
|
|
525
|
-
|
|
526
|
-
See [.claude/MCP_TEST_RESULTS.md](.claude/MCP_TEST_RESULTS.md) for full integration details.
|
|
527
|
-
|
|
528
|
-
**CLI:**
|
|
529
|
-
|
|
530
|
-
```bash
|
|
531
|
-
empathy workflow run security-audit --path ./src
|
|
532
|
-
empathy workflow run test-coverage --target 90
|
|
533
|
-
empathy telemetry show # View cost savings
|
|
534
|
-
```
|
|
535
|
-
|
|
536
|
-
**Python:**
|
|
537
|
-
|
|
538
|
-
```python
|
|
539
|
-
from attune import EmpathyOS
|
|
540
|
-
|
|
541
|
-
async with EmpathyOS() as empathy:
|
|
542
|
-
result = await empathy.level_2_guided(
|
|
543
|
-
"Review this code for security issues"
|
|
544
|
-
)
|
|
545
|
-
print(result["response"])
|
|
512
|
+
attune workflow run security-audit --path ./src
|
|
513
|
+
attune workflow run test-coverage --target 90
|
|
514
|
+
attune telemetry show # View cost savings
|
|
546
515
|
```
|
|
547
516
|
|
|
548
517
|
---
|
|
@@ -559,67 +528,14 @@ Workflows are organized into hubs for easy discovery:
|
|
|
559
528
|
| **Release** | `/release` | Release prep, security scan, publishing |
|
|
560
529
|
| **Workflows** | `/workflows` | Automated analysis (security, bugs, perf) |
|
|
561
530
|
| **Plan** | `/plan` | Planning, TDD, code review, refactoring |
|
|
562
|
-
| **Utilities** | `/utilities` | Project init, dependencies, profiling |
|
|
563
|
-
| **Learning** | `/learning` | Pattern learning and session evaluation |
|
|
564
|
-
| **Context** | `/context` | State management and memory |
|
|
565
531
|
| **Agent** | `/agent` | Create and manage custom agents |
|
|
566
532
|
|
|
567
|
-
**Natural Language
|
|
533
|
+
**Natural Language Routing:**
|
|
568
534
|
|
|
569
535
|
```bash
|
|
570
|
-
# Use plain English - intelligent routing matches your intent
|
|
571
536
|
/workflows "find security vulnerabilities" # → security-audit
|
|
572
537
|
/workflows "check code performance" # → perf-audit
|
|
573
|
-
/workflows "predict bugs" # → bug-predict
|
|
574
538
|
/plan "review my code" # → code-review
|
|
575
|
-
/plan "help me plan this feature" # → planning
|
|
576
|
-
|
|
577
|
-
# Or use traditional workflow names
|
|
578
|
-
/workflows security-audit
|
|
579
|
-
/plan code-review
|
|
580
|
-
```
|
|
581
|
-
|
|
582
|
-
**Interactive menus:**
|
|
583
|
-
|
|
584
|
-
```bash
|
|
585
|
-
/dev # Show interactive menu
|
|
586
|
-
/dev "debug auth error" # Jump directly to debugging
|
|
587
|
-
/testing "run coverage" # Run coverage analysis
|
|
588
|
-
/release # Start release preparation
|
|
589
|
-
```
|
|
590
|
-
|
|
591
|
-
---
|
|
592
|
-
|
|
593
|
-
## Socratic Method
|
|
594
|
-
|
|
595
|
-
Workflows guide you through discovery instead of requiring upfront configuration:
|
|
596
|
-
|
|
597
|
-
```text
|
|
598
|
-
You: /dev
|
|
599
|
-
|
|
600
|
-
Claude: What development task do you need?
|
|
601
|
-
1. Debug issue
|
|
602
|
-
2. Create commit
|
|
603
|
-
3. PR workflow
|
|
604
|
-
4. Quality check
|
|
605
|
-
|
|
606
|
-
You: 1
|
|
607
|
-
|
|
608
|
-
Claude: What error or unexpected behavior are you seeing?
|
|
609
|
-
```
|
|
610
|
-
|
|
611
|
-
**How it works:**
|
|
612
|
-
|
|
613
|
-
1. **Discovery** - Workflow asks targeted questions to understand your needs
|
|
614
|
-
2. **Context gathering** - Collects relevant code, errors, and constraints
|
|
615
|
-
3. **Dynamic agent creation** - Assembles the right team based on your answers
|
|
616
|
-
4. **Execution** - Runs with appropriate tier selection
|
|
617
|
-
|
|
618
|
-
**Create custom agents with Socratic guidance:**
|
|
619
|
-
|
|
620
|
-
```bash
|
|
621
|
-
/agent create # Guided agent creation
|
|
622
|
-
/agent team # Build multi-agent teams interactively
|
|
623
539
|
```
|
|
624
540
|
|
|
625
541
|
---
|
|
@@ -634,120 +550,93 @@ When using Claude Code, workflows run as skills through the Task tool - **no API
|
|
|
634
550
|
/dev # $0 - uses your Claude subscription
|
|
635
551
|
/testing # $0
|
|
636
552
|
/release # $0
|
|
637
|
-
/agent create # $0
|
|
638
553
|
```
|
|
639
554
|
|
|
640
555
|
### API Mode (CI/CD, Automation)
|
|
641
556
|
|
|
642
557
|
For programmatic use, smart tier routing saves 34-86%:
|
|
643
558
|
|
|
644
|
-
| Tier | Model
|
|
645
|
-
| ------- |
|
|
646
|
-
| CHEAP | Haiku
|
|
647
|
-
| CAPABLE | Sonnet
|
|
648
|
-
| PREMIUM | Opus
|
|
559
|
+
| Tier | Model | Use Case | Cost |
|
|
560
|
+
| ------- | ------------- | ---------------------------- | ------- |
|
|
561
|
+
| CHEAP | Haiku | Formatting, simple tasks | ~$0.005 |
|
|
562
|
+
| CAPABLE | Sonnet | Bug fixes, code review | ~$0.08 |
|
|
563
|
+
| PREMIUM | Opus | Architecture, complex design | ~$0.45 |
|
|
649
564
|
|
|
650
565
|
```bash
|
|
651
566
|
# Track API usage and savings
|
|
652
|
-
|
|
567
|
+
attune telemetry savings --days 30
|
|
653
568
|
```
|
|
654
569
|
|
|
655
570
|
---
|
|
656
571
|
|
|
657
|
-
##
|
|
658
|
-
|
|
659
|
-
### Multi-Agent Workflows
|
|
660
|
-
|
|
661
|
-
```bash
|
|
662
|
-
# 4 parallel agents check release readiness
|
|
663
|
-
empathy orchestrate release-prep
|
|
664
|
-
|
|
665
|
-
# Sequential coverage improvement
|
|
666
|
-
empathy orchestrate test-coverage --target 90
|
|
667
|
-
```
|
|
572
|
+
## MCP Server Integration
|
|
668
573
|
|
|
669
|
-
|
|
574
|
+
Attune AI includes a Model Context Protocol (MCP) server that exposes all workflows as native Claude Code tools:
|
|
670
575
|
|
|
671
|
-
|
|
576
|
+
- **10 Tools Available** - security_audit, bug_predict, code_review, test_generation, performance_audit, release_prep, and more
|
|
577
|
+
- **Automatic Discovery** - Claude Code finds tools via `.claude/mcp.json`
|
|
578
|
+
- **Natural Language Access** - Describe your need and Claude invokes the appropriate tool
|
|
672
579
|
|
|
673
|
-
```
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
workflow = SecurityAuditWorkflow(enable_cache=True)
|
|
677
|
-
result = await workflow.execute(target_path="./src")
|
|
678
|
-
print(f"Cache hit rate: {result.cost_report.cache_hit_rate:.1f}%")
|
|
580
|
+
```bash
|
|
581
|
+
# Verify MCP integration
|
|
582
|
+
echo '{"method":"tools/list","params":{}}' | PYTHONPATH=./src python -m attune.mcp.server
|
|
679
583
|
```
|
|
680
584
|
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
Workflows learn from outcomes and improve over time:
|
|
585
|
+
---
|
|
684
586
|
|
|
685
|
-
|
|
686
|
-
from attune.orchestration.config_store import ConfigurationStore
|
|
587
|
+
## Agent Coordination Dashboard
|
|
687
588
|
|
|
688
|
-
|
|
689
|
-
best = store.get_best_for_task("release_prep")
|
|
690
|
-
print(f"Success rate: {best.success_rate:.1%}")
|
|
691
|
-
```
|
|
589
|
+
Real-time monitoring with 6 coordination patterns:
|
|
692
590
|
|
|
693
|
-
|
|
591
|
+
- Agent heartbeats and status tracking
|
|
592
|
+
- Inter-agent coordination signals
|
|
593
|
+
- Event streaming across agent workflows
|
|
594
|
+
- Approval gates for human-in-the-loop
|
|
595
|
+
- Quality feedback and performance metrics
|
|
596
|
+
- Demo mode with test data generation
|
|
694
597
|
|
|
695
|
-
```
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
GeminiProvider, # Gemini
|
|
700
|
-
LocalProvider, # Ollama, LM Studio
|
|
701
|
-
)
|
|
598
|
+
```bash
|
|
599
|
+
# Launch dashboard (requires Redis)
|
|
600
|
+
python examples/dashboard_demo.py
|
|
601
|
+
# Open http://localhost:8000
|
|
702
602
|
```
|
|
703
603
|
|
|
704
604
|
---
|
|
705
605
|
|
|
706
|
-
##
|
|
606
|
+
## Authentication Strategy
|
|
607
|
+
|
|
608
|
+
Intelligent routing between Claude subscription and Anthropic API:
|
|
707
609
|
|
|
708
610
|
```bash
|
|
709
|
-
#
|
|
710
|
-
python -m attune.models.
|
|
711
|
-
python -m attune.models.cli provider --set hybrid
|
|
611
|
+
# Interactive setup
|
|
612
|
+
python -m attune.models.auth_cli setup
|
|
712
613
|
|
|
713
|
-
#
|
|
714
|
-
|
|
715
|
-
empathy workflow run <workflow-name>
|
|
614
|
+
# View current configuration
|
|
615
|
+
python -m attune.models.auth_cli status
|
|
716
616
|
|
|
717
|
-
#
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
empathy telemetry export --format csv
|
|
617
|
+
# Get recommendation for a file
|
|
618
|
+
python -m attune.models.auth_cli recommend src/module.py
|
|
619
|
+
```
|
|
721
620
|
|
|
722
|
-
|
|
723
|
-
empathy orchestrate release-prep
|
|
724
|
-
empathy orchestrate test-coverage --target 90
|
|
621
|
+
**Automatic routing:**
|
|
725
622
|
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
empathy meta-workflow run release-prep --real
|
|
729
|
-
```
|
|
623
|
+
- Small/medium modules (<2000 LOC) → Claude subscription (free)
|
|
624
|
+
- Large modules (>2000 LOC) → Anthropic API (pay for what you need)
|
|
730
625
|
|
|
731
626
|
---
|
|
732
627
|
|
|
733
|
-
##
|
|
628
|
+
## Installation Options
|
|
734
629
|
|
|
735
630
|
```bash
|
|
736
631
|
# Individual developers (recommended)
|
|
737
632
|
pip install attune-ai[developer]
|
|
738
633
|
|
|
739
|
-
# All LLM providers
|
|
740
|
-
pip install attune-ai[llm]
|
|
741
|
-
|
|
742
634
|
# With caching (semantic similarity)
|
|
743
635
|
pip install attune-ai[cache]
|
|
744
636
|
|
|
745
637
|
# Enterprise (auth, rate limiting)
|
|
746
638
|
pip install attune-ai[enterprise]
|
|
747
639
|
|
|
748
|
-
# Healthcare (HIPAA compliance)
|
|
749
|
-
pip install attune-ai[healthcare]
|
|
750
|
-
|
|
751
640
|
# Development
|
|
752
641
|
git clone https://github.com/Smart-AI-Memory/attune-ai.git
|
|
753
642
|
cd attune-ai && pip install -e .[dev]
|
|
@@ -758,74 +647,38 @@ cd attune-ai && pip install -e .[dev]
|
|
|
758
647
|
## Environment Setup
|
|
759
648
|
|
|
760
649
|
```bash
|
|
761
|
-
#
|
|
650
|
+
# Required: Anthropic API key
|
|
762
651
|
export ANTHROPIC_API_KEY="sk-ant-..."
|
|
763
|
-
export OPENAI_API_KEY="sk-..."
|
|
764
|
-
export GOOGLE_API_KEY="..."
|
|
765
652
|
|
|
766
|
-
# Optional
|
|
653
|
+
# Optional: Redis for Agent Dashboard and memory
|
|
767
654
|
export REDIS_URL="redis://localhost:6379"
|
|
768
655
|
```
|
|
769
656
|
|
|
770
657
|
---
|
|
771
658
|
|
|
772
|
-
## VSCode Extension
|
|
773
|
-
|
|
774
|
-
Install the Empathy VSCode extension for:
|
|
775
|
-
|
|
776
|
-
- **Dashboard** - Health score, costs, patterns
|
|
777
|
-
- **One-Click Workflows** - Run from command palette
|
|
778
|
-
- **Memory Panel** - Manage Redis and patterns
|
|
779
|
-
- **Cost Tracking** - Real-time savings display
|
|
780
|
-
|
|
781
|
-
---
|
|
782
|
-
|
|
783
|
-
## Documentation
|
|
784
|
-
|
|
785
|
-
- [Quick Start Guide](docs/quickstart.md)
|
|
786
|
-
- [CLI Reference](docs/cli-reference.md)
|
|
787
|
-
- [Testing Guide](docs/testing-guide.md)
|
|
788
|
-
- [Keyboard Shortcuts](docs/keyboard-shortcuts.md)
|
|
789
|
-
- [Full Documentation](https://smartaimemory.com/framework-docs/)
|
|
790
|
-
|
|
791
|
-
---
|
|
792
|
-
|
|
793
659
|
## Security
|
|
794
660
|
|
|
795
661
|
- Path traversal protection on all file operations
|
|
796
662
|
- JWT authentication with rate limiting
|
|
797
663
|
- PII scrubbing in telemetry
|
|
798
664
|
- HIPAA/GDPR compliance options
|
|
799
|
-
-
|
|
800
|
-
|
|
801
|
-
See [SECURITY.md](SECURITY.md) for vulnerability reporting.
|
|
802
|
-
|
|
803
|
-
### Security Scanning
|
|
804
|
-
|
|
805
|
-
**Automated security scanning in CI/CD** - 82% accuracy, blocks critical issues:
|
|
665
|
+
- Automated security scanning with 82% accuracy
|
|
806
666
|
|
|
807
667
|
```bash
|
|
808
|
-
# Run security audit
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
# Scan specific directory
|
|
812
|
-
empathy workflow run security-audit --input '{"path":"./src"}'
|
|
668
|
+
# Run security audit
|
|
669
|
+
attune workflow run security-audit --path ./src
|
|
813
670
|
```
|
|
814
671
|
|
|
815
|
-
|
|
672
|
+
See [SECURITY.md](SECURITY.md) for vulnerability reporting.
|
|
816
673
|
|
|
817
|
-
|
|
818
|
-
- **[CI/CD Integration Guide](docs/CI_SECURITY_SCANNING.md)** - Complete setup and troubleshooting (DevOps, developers)
|
|
819
|
-
- **[Scanner Architecture](docs/SECURITY_SCANNER_ARCHITECTURE.md)** - Technical implementation details (engineers, architects)
|
|
820
|
-
- **[Remediation Process](docs/SECURITY_REMEDIATION_PROCESS.md)** - 3-phase methodology for improving scanners (security teams, leadership)
|
|
821
|
-
- **[API Reference](docs/api-reference/security-scanner.md)** - Complete API documentation (developers extending scanner)
|
|
674
|
+
---
|
|
822
675
|
|
|
823
|
-
|
|
676
|
+
## Documentation
|
|
824
677
|
|
|
825
|
-
-
|
|
826
|
-
-
|
|
827
|
-
-
|
|
828
|
-
-
|
|
678
|
+
- [Quick Start Guide](docs/quickstart.md)
|
|
679
|
+
- [CLI Reference](docs/cli-reference.md)
|
|
680
|
+
- [Authentication Strategy Guide](docs/AUTH_STRATEGY_GUIDE.md)
|
|
681
|
+
- [Full Documentation](https://smartaimemory.com/framework-docs/)
|
|
829
682
|
|
|
830
683
|
---
|
|
831
684
|
|
|
@@ -837,27 +690,20 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
|
|
|
837
690
|
|
|
838
691
|
## License
|
|
839
692
|
|
|
840
|
-
**Apache License 2.0** - Free and open source
|
|
693
|
+
**Apache License 2.0** - Free and open source. Use it, modify it, build commercial products with it. [Details →](LICENSE)
|
|
841
694
|
|
|
842
695
|
---
|
|
843
696
|
|
|
844
697
|
## Acknowledgements
|
|
845
698
|
|
|
846
|
-
This project stands on the shoulders of giants. We are deeply grateful to the open source community and all the amazing projects that make this framework possible.
|
|
847
|
-
|
|
848
|
-
**[View Full Acknowledgements →](ACKNOWLEDGEMENTS.md)**
|
|
849
|
-
|
|
850
699
|
Special thanks to:
|
|
851
700
|
|
|
852
701
|
- **[Anthropic](https://www.anthropic.com/)** - For Claude AI and the Model Context Protocol
|
|
853
|
-
- **[LangChain](https://github.com/langchain-ai/langchain)** - Agent framework powering our
|
|
702
|
+
- **[LangChain](https://github.com/langchain-ai/langchain)** - Agent framework powering our orchestration
|
|
854
703
|
- **[FastAPI](https://github.com/tiangolo/fastapi)** - Modern Python web framework
|
|
855
|
-
- **[pytest](https://github.com/pytest-dev/pytest)** - Testing framework making quality assurance effortless
|
|
856
|
-
|
|
857
|
-
And to all 50+ open source projects we depend on. [See the complete list →](ACKNOWLEDGEMENTS.md)
|
|
858
704
|
|
|
859
|
-
|
|
705
|
+
[View Full Acknowledgements →](ACKNOWLEDGEMENTS.md)
|
|
860
706
|
|
|
861
707
|
---
|
|
862
708
|
|
|
863
|
-
**Built by [Smart AI Memory](https://smartaimemory.com)** · [Docs](https://smartaimemory.com/framework-docs/) · [
|
|
709
|
+
**Built by [Smart AI Memory](https://smartaimemory.com)** · [Docs](https://smartaimemory.com/framework-docs/) · [Issues](https://github.com/Smart-AI-Memory/attune-ai/issues)
|
|
@@ -23,11 +23,12 @@ attune/persistence.py,sha256=wsEJtHdjpEfIQ3-O5PaxAGiZXacON0Pft4gqt7Ui3z8,17714
|
|
|
23
23
|
attune/platform_utils.py,sha256=NsvAOOA2QgdWLd_44AY1UdQLYuclaOC7SPK-koFyi1A,7384
|
|
24
24
|
attune/redis_config.py,sha256=jDpnKXxBoAo6Cy2oBX9imbRtsUAyPKOIH6jvSlWdcbU,9742
|
|
25
25
|
attune/redis_memory.py,sha256=MYhW_M41AoWhxxh8YggWUHxZaUoQZ7XxqeBB2qDqyww,23347
|
|
26
|
+
attune/socratic_router.py,sha256=sHEPYDC88n6OaGBtnC7JquyctldBp3tSCQdrphV0BHo,23601
|
|
26
27
|
attune/templates.py,sha256=EbZmiHqS_jFZg_-lScK0fUUnw7_KpE5J3ZFTWXEKx-Q,17187
|
|
27
28
|
attune/tier_recommender.py,sha256=rBuAgGkNlX9wWcJ1QFi0ASGuZSR9RGl6PEBElxcAzMk,14297
|
|
28
29
|
attune/tools.py,sha256=YCfHTm9Es6wwh7oESt4q0mDz7AV8ecvMAB_1_0516r4,6225
|
|
29
30
|
attune/trust_building.py,sha256=z2ZsQWK5QjX6d7pxFWrFD54J1keUguTog6YztZJVPKI,19180
|
|
30
|
-
attune/vscode_bridge.py,sha256=
|
|
31
|
+
attune/vscode_bridge.py,sha256=XBKF6-YiQIRvyOtkp-4kmBrWhs5Uflo7TLUBj4ejPLU,5034
|
|
31
32
|
attune/workflow_commands.py,sha256=9Gdy3iI6LA9y7NtYBieNS3-rbOrrLRavhlbl_2yWVgU,25465
|
|
32
33
|
attune/adaptive/__init__.py,sha256=9LRWvrkitzasuGAqANEpKQMvrj5pPNtulSxz49E-Ke4,338
|
|
33
34
|
attune/adaptive/task_complexity.py,sha256=XhQgubrTxqV2V6CBD4kKZ_0kPCjchzg94HaUFIY6Q3c,3783
|
|
@@ -346,8 +347,8 @@ attune/workflows/test_gen/data_models.py,sha256=wXfef60ptiG6AvygayTxWqlL5FVOss19
|
|
|
346
347
|
attune/workflows/test_gen/report_formatter.py,sha256=RaxbDp6-9iQRfJmVwrrIReVkOkrnb668NgHrNaS-SPY,10705
|
|
347
348
|
attune/workflows/test_gen/test_templates.py,sha256=4ywqGYYaSoZxOU6Y1_E-27KEgMI5-v2a1ndia406E9c,13180
|
|
348
349
|
attune/workflows/test_gen/workflow.py,sha256=U0dhAcCKmlltPIvCSXUeFzt_Q4TodQI4tXtR6cz19MQ,25729
|
|
349
|
-
attune_ai-2.1.
|
|
350
|
-
attune_ai-2.1.
|
|
350
|
+
attune_ai-2.1.3.dist-info/licenses/LICENSE,sha256=kqe3EeGatNB79lUTHxjLnxDe7VJr0iYetThOr4_Fx7A,11348
|
|
351
|
+
attune_ai-2.1.3.dist-info/licenses/LICENSE_CHANGE_ANNOUNCEMENT.md,sha256=JH9yAQGv_lQej5YlztI_kawbVQ2H8uVLhPGlrWnR_34,3844
|
|
351
352
|
attune_healthcare/__init__.py,sha256=4NioL1_86UXzkd-QNkQZUSZ8rKTQGSP0TC9VXP32kQs,295
|
|
352
353
|
attune_healthcare/monitors/__init__.py,sha256=Udp8qfZR504QAq5_eQjvtIaE7v06Yguc7nuF40KllQc,196
|
|
353
354
|
attune_healthcare/monitors/clinical_protocol_monitor.py,sha256=MWE5t8tW9HWZn_SNo-inx8-0nhdTNGhbcB8ZeDWyXa0,11648
|
|
@@ -449,8 +450,8 @@ workflow_scaffolding/__init__.py,sha256=UpX5vjjjPjIaAKyIV1D4GxJzLUZy5DzdzgSkePYM
|
|
|
449
450
|
workflow_scaffolding/__main__.py,sha256=0qspuNoadTDqyskXTlT8Sahqau-XIxN35NHTSGVW6z4,236
|
|
450
451
|
workflow_scaffolding/cli.py,sha256=RUVqU9SeAgm7YkM0YNd-quh8u6BNzmX8xM2y9K_p68Y,6759
|
|
451
452
|
workflow_scaffolding/generator.py,sha256=2WC02A10lzF2NQgOn66ksV17Oe72kKlU2qCQs39LIlw,8861
|
|
452
|
-
attune_ai-2.1.
|
|
453
|
-
attune_ai-2.1.
|
|
454
|
-
attune_ai-2.1.
|
|
455
|
-
attune_ai-2.1.
|
|
456
|
-
attune_ai-2.1.
|
|
453
|
+
attune_ai-2.1.3.dist-info/METADATA,sha256=sCt_8yu13CtsXc3fhY4aqyBNZgiWLVO8GtQ4yF-rXM0,33764
|
|
454
|
+
attune_ai-2.1.3.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
|
|
455
|
+
attune_ai-2.1.3.dist-info/entry_points.txt,sha256=GVlb04zFlpkaPtaL7X3JCZI8R0AEOZRsZjJ-wIDQvdo,1458
|
|
456
|
+
attune_ai-2.1.3.dist-info/top_level.txt,sha256=iLyjKpuOzWtwmIOZqzeBh8_SVztY2vFvhHcyo1WPtTY,73
|
|
457
|
+
attune_ai-2.1.3.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{attune_ai-2.1.1.dist-info → attune_ai-2.1.3.dist-info}/licenses/LICENSE_CHANGE_ANNOUNCEMENT.md
RENAMED
|
File without changes
|
|
File without changes
|