Skip to content

Commit aca9302

Browse files
committed
📝 Update README with new structure info
1 parent c718b48 commit aca9302

1 file changed

Lines changed: 51 additions & 35 deletions

File tree

README.md

Lines changed: 51 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -335,71 +335,88 @@ We can place AI flows into the:
335335

336336
### Structure
337337

338-
To keep AI flows as flexible as possible, we avoid limiting the output structure by implementing a base `AITask` class that can be extended for specific task types.
338+
To keep AI flows as flexible as possible, we avoid limiting the output structure by implementing a base `AIResult` class that can be extended for specific result types.
339339

340-
The base `AITask` class provides a foundation for any AI-powered task:
340+
The base `AIResult` class provides a foundation for any AI workflow result:
341341

342342
```python
343-
class AITask(ABC):
344-
"""Base class for AI tasks that run autonomously and return results.
345-
346-
This class provides the foundation for various AI-powered tasks like:
347-
- Security audits
348-
- Code quality analysis
349-
- Gas optimization
350-
- Documentation generation
351-
- Any custom analysis
343+
class AIResult(ABC):
344+
"""Base class for AI workflow results.
345+
346+
Any result type that implements these methods can be used by the AI CLI.
347+
This allows each workflow to define its own result structure and formatting.
352348
"""
353349

350+
@classmethod
354351
@abstractmethod
355-
def get_task_type(self) -> str:
356-
"""Return the task type identifier (e.g., 'security-audit', 'code-quality')."""
352+
def from_working_dir(cls, working_dir: Path, raw_results: Dict[str, Any]) -> "AIResult":
353+
"""Create a result instance by parsing the working directory.
354+
355+
Args:
356+
working_dir: Path to the workflow's working directory
357+
raw_results: Raw results dict from workflow execution
358+
359+
Returns:
360+
An instance of the result class with parsed data
361+
"""
357362
...
358363

359364
@abstractmethod
360365
def pretty_print(self, console: "Console") -> None:
361-
"""Print results in a human-readable format to the console."""
366+
"""Print the result in a human-readable format to the console."""
362367
...
363368

364369
@abstractmethod
365370
def to_dict(self) -> Dict[str, Any]:
366-
"""Convert results to dictionary format for serialization."""
371+
"""Convert the result to a dictionary for JSON serialization."""
367372
...
368373

369374
def export_json(self, path: Path) -> None:
370-
"""Export results to JSON file.
375+
"""Export the result to a JSON file.
371376
372-
Default implementation uses to_dict(), but can be overridden.
377+
Default implementation uses to_dict(), but can be overridden
378+
for custom export formats.
373379
"""
374-
import json
375-
376380
data = self.to_dict()
377381
path.parent.mkdir(parents=True, exist_ok=True)
378382
path.write_text(json.dumps(data, indent=2))
379383
```
380384

381-
By implementing the `to_dict()` and `pretty_print()` methods, tasks can easily export results to dictionaries and display them in the console.
385+
By implementing the `from_working_dir()`, `to_dict()` and `pretty_print()` methods, results can be parsed from workflow outputs, exported to dictionaries and displayed in the console.
382386

383-
#### Example: Detection-Specific Task
387+
#### Example: Detection-Specific Result
384388

385-
Here's an example of a specialized task mimicking detectors:
389+
Here's an example of a specialized result class for detection-style outputs:
386390

387391
```python
388392

389-
class DetectionTask(AITask):
390-
"""Base class for AI tasks that produce detection-style results.
393+
class AIDetectionResult(AIResult):
394+
"""Detection result specifically for security audit workflows."""
391395

392-
This is a specialized AITask for security audits, bug detection,
393-
and similar tasks that produce a list of findings/detections.
394-
"""
395-
396-
def __init__(self, detections: List[Tuple[str, 'AIDetection']], working_dir: Path):
396+
def __init__(self, detections: List[Tuple[str, AIDetection]], working_dir: Path):
397397
self.detections = detections
398398
self.working_dir = working_dir
399399

400-
def get_task_type(self) -> str:
401-
"""Return the task type identifier."""
402-
return "detection-task"
400+
@classmethod
401+
def from_working_dir(cls, working_dir: Path, raw_results: Dict[str, Any]) -> "AIDetectionResult":
402+
"""Parse audit workflow results from the working directory.
403+
404+
Looks for the standard audit output structure and parses YAML/AsciiDoc files.
405+
"""
406+
# Create instance first
407+
instance = cls([], working_dir)
408+
# Then parse detections using instance method
409+
instance.detections = instance.parse_audit_results(working_dir)
410+
return instance
411+
412+
def parse_audit_results(self, working_dir: Path) -> List[Tuple[str, AIDetection]]:
413+
"""Parse audit workflow results into AIDetection format.
414+
415+
(Implementation details omitted for brevity)
416+
"""
417+
# Parse YAML files, AsciiDoc files, etc.
418+
# Return list of (detector_name, AIDetection) tuples
419+
...
403420

404421
def pretty_print(self, console: "Console") -> None:
405422
"""Print detections using the detection printer."""
@@ -418,7 +435,6 @@ class DetectionTask(AITask):
418435
def to_dict(self) -> Dict[str, Any]:
419436
"""Convert all detections to dictionary format."""
420437
return {
421-
"task_type": self.get_task_type(),
422438
"detections": [
423439
{
424440
"detector": detector_name,
@@ -438,7 +454,7 @@ class DetectionTask(AITask):
438454

439455
The core runner handles output by calling either `pretty_print()` or `to_dict()` based on whether the user wants console output or has specified the `--export` flag.
440456

441-
This flexible architecture allows us to define new task types (e.g., fuzzing) that can have different output formats. For example, `wake ai fuzz` could return specialized fuzzing results or simply print to the console, and export functionality can be customized or disabled for specific task types.
457+
This flexible architecture allows us to define new result types (e.g., fuzzing results, optimization reports) that can have different output formats. For example, `wake ai fuzz` could return specialized fuzzing results with its own `FuzzingResult` class, and export functionality can be customized or disabled for specific result types.
442458

443459

444460
## Todo
@@ -448,7 +464,7 @@ This flexible architecture allows us to define new task types (e.g., fuzzing) th
448464
- [ ] Enable defining AI flows in `wake_ai` folder under private repo
449465
- [ ] Reach consensus on AI framework name
450466
- ***Trace*** – simple, clean, post-hoc or live path tracking; modern and very product-ready.
451-
- ***Tasks*** - simple, could also bre well marketed, i.e. we are introducing wake tasks
467+
- ***Tasks*** - simple, could also be well marketed, i.e. we are introducing wake tasks
452468
- alternatively we could just swap `wake ai` for `wake task`, looks nice
453469
- ***Shikoro*** – "reasoning in motion"; also sounds a bit like a stylized Japanese name.
454470
- ***Michi*** – philosophical, elegant, the Way (道); perfect for a framework guiding agents.

0 commit comments

Comments
 (0)