Skip to content

Commit 8aaa767

Browse files
authored
Lliam Enhancement Stack 02 - Add directory and domain (#176)
* Add FS utility. * Add Lliam domain
1 parent 6217718 commit 8aaa767

File tree

4 files changed

+147
-0
lines changed

4 files changed

+147
-0
lines changed
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# Ailly Prompt Workflow
2+
3+
This project automates the process of generating, running, parsing, and applying [Ailly](https://www.npmjs.com/package/@ailly/cli) prompt outputs to an AWS DocGen project. It combines all steps into one streamlined command using a single Python script.
4+
5+
---
6+
7+
## 📦 Overview
8+
9+
This tool:
10+
1. **Generates** Ailly prompts from DocGen snippets.
11+
2. **Runs** Ailly CLI to get enhanced metadata.
12+
3. **Parses** Ailly responses into structured JSON.
13+
4. **Updates** your DocGen examples with the new metadata.
14+
15+
All of this is done with one command.
16+
17+
---
18+
19+
## ✅ Prerequisites
20+
21+
- Python 3.8+
22+
- Node.js and npm (for `npx`)
23+
- A DocGen project directory
24+
25+
---
26+
27+
## 🚀 Usage
28+
29+
From your project root, run:
30+
31+
```bash
32+
python -m aws_doc_sdk_examples_tools.agent.bin.main \
33+
/path/to/your/docgen/project \
34+
--system-prompts path/to/system_prompt.txt
35+
```
36+
37+
### 🔧 Arguments
38+
39+
- `iam_tributary_root`: Path to the root directory of your IAM policy tributary
40+
- `--system-prompts`: List of system prompt files or strings to include in the Ailly configuration
41+
- `--skip-generation`: Skip the prompt generation and Ailly execution steps (useful for reprocessing existing outputs)
42+
43+
Run `python -m aws_doc_sdk_examples_tools.agent.bin.main update --help` for more info.
44+
45+
---
46+
47+
## 🗂 What This Does
48+
49+
Under the hood, this script:
50+
51+
1. Creates a directory `.ailly_iam_policy` containing:
52+
- One Markdown file per snippet.
53+
- A `.aillyrc` configuration file.
54+
55+
2. Runs `npx @ailly/cli` to generate `.ailly.md` outputs.
56+
57+
3. Parses the Ailly `.ailly.md` files into a single `iam_updates.json` file.
58+
59+
4. Updates each matching `Example` in the DocGen instance with:
60+
- `title`
61+
- `title_abbrev`
62+
- `synopsis`
63+
64+
---
65+
66+
## 💡 Example
67+
68+
```bash
69+
python -m aws_doc_sdk_examples_tools.agent.bin.main \
70+
~/projects/AWSIAMPolicyExampleReservoir \
71+
--system-prompts prompts/system_prompt.txt
72+
```
73+
74+
This will:
75+
- Write prompts and config to `.ailly_iam_policy/`
76+
- Run Ailly and capture results
77+
- Parse and save output as `.ailly_iam_policy/iam_updates.json`
78+
- Apply updates to your DocGen examples
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
from dataclasses import dataclass
2+
from pathlib import Path
3+
from typing import List
4+
5+
6+
class Command:
7+
pass
8+
9+
10+
@dataclass
11+
class CreatePrompts(Command):
12+
doc_gen_root: str
13+
system_prompts: List[str]
14+
out_dir: str
15+
16+
17+
@dataclass
18+
class RunAilly(Command):
19+
batches: List[str]
20+
21+
22+
@dataclass
23+
class UpdateReservoir(Command):
24+
root: Path
25+
batches: List[str]
26+
packages: List[str]
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
from typing import List
2+
3+
from aws_doc_sdk_examples_tools.doc_gen import Example, Snippet
4+
5+
6+
class Prompt:
7+
def __init__(self, id: str, content: str):
8+
self.id = id
9+
self.content = content
10+
11+
12+
class Policies:
13+
def __init__(self, examples: List[Example], snippets: List[Snippet]):
14+
self.examples = examples
15+
self.snippets = snippets
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import yaml
2+
from typing import List
3+
4+
from aws_doc_sdk_examples_tools.lliam.domain.model import Prompt
5+
6+
7+
def build_ailly_config(system_prompts: List[Prompt]) -> Prompt:
8+
"""Create the .aillyrc configuration file."""
9+
fence = "---"
10+
options = {
11+
"isolated": "true",
12+
"overwrite": "true",
13+
# MCP assistance did not produce noticeably different results, but it was
14+
# slowing things down by 10x. Disabled for now.
15+
# "mcp": {
16+
# "awslabs.aws-documentation-mcp-server": {
17+
# "type": "stdio",
18+
# "command": "uvx",
19+
# "args": ["awslabs.aws-documentation-mcp-server@latest"],
20+
# }
21+
# },
22+
}
23+
options_block = yaml.dump(options).strip()
24+
prompt_strs = [p.content for p in system_prompts]
25+
prompts_block = "\n".join(prompt_strs)
26+
27+
content = f"{fence}\n{options_block}\n{fence}\n{prompts_block}"
28+
return Prompt(".aillyrc", content)

0 commit comments

Comments
 (0)