agentfactory-gen 0.3.0__tar.gz

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.
@@ -0,0 +1,11 @@
1
+ Metadata-Version: 2.4
2
+ Name: agentfactory-gen
3
+ Version: 0.3.0
4
+ Summary: Agent Factory — Librarian-powered agent lifecycle manager
5
+ Requires-Python: >=3.11
6
+ Requires-Dist: click>=8.1
7
+ Requires-Dist: filelock>=3.13.0
8
+ Provides-Extra: dev
9
+ Requires-Dist: pytest>=8; extra == "dev"
10
+ Requires-Dist: pytest-cov>=5; extra == "dev"
11
+ Requires-Dist: ruff>=0.4; extra == "dev"
@@ -0,0 +1,431 @@
1
+ # AgentFactory
2
+ <!-- version: 2.5.0 -->
3
+
4
+ A lightweight Python CLI (`agent-gen`) for building, packaging, and deploying AI agents as portable, framework-agnostic units.
5
+
6
+ AgentFactory provides a **Unified AI Harness** — a single `.ai/` directory that lets Claude, Codex, and Gemini work on the same project simultaneously, sharing context without conflicts.
7
+
8
+ ---
9
+
10
+ ## Workflows
11
+
12
+ ### 1. Overall Architecture
13
+
14
+ ```mermaid
15
+ graph TD
16
+ subgraph Project Root
17
+ CM[CLAUDE.md]
18
+ AM[AGENTS.md]
19
+ GM[GEMINI.md]
20
+ CO[CODEX.md]
21
+ CL[.claude]
22
+ GE[.gemini]
23
+ CD[.codex]
24
+ end
25
+
26
+ subgraph ".ai/ — Unified Harness"
27
+ AF[AgentFactory.md\nsingle source of truth]
28
+ MF[agent-manifest.json\nglobal registry]
29
+
30
+ subgraph adapters/
31
+ ACA[claude/\nsettings.json]
32
+ AGE[gemini/\nconfig.json]
33
+ ACO[codex/\nconfig.toml]
34
+ end
35
+
36
+ subgraph shared/
37
+ RU[rules/]
38
+ SK[skills/]
39
+ CMD[commands/]
40
+ AG[agents/]
41
+ MEM[memory/\nmilestones.md]
42
+ end
43
+ end
44
+
45
+ CM -->|symlink| AF
46
+ AM -->|symlink| AF
47
+ GM -->|symlink| AF
48
+ CO -->|symlink| AF
49
+ CL -->|symlink| ACA
50
+ GE -->|symlink| AGE
51
+ CD -->|symlink| ACO
52
+
53
+ ACA -->|commands →| CMD
54
+ ACA -->|skills →| SK
55
+ AGE -->|tools →| SK
56
+ ACO -->|prompts →| CMD
57
+ ```
58
+
59
+ ---
60
+
61
+ ### 2. Agent Lifecycle
62
+
63
+ ```mermaid
64
+ flowchart LR
65
+ A([Start]) --> B[agent-gen deploy name]
66
+ B --> C[Scaffold 5-dir structure\nskills commands docs\nscripts orchestration]
67
+ C --> D[Init agent-manifest.json\nvia Librarian.init]
68
+
69
+ D --> E[agent-gen describe\n--desc --plan]
70
+ E --> F[Update manifest\nmetadata]
71
+
72
+ F --> G[Develop\nadd skills commands docs]
73
+
74
+ G --> H[agent-gen audit name]
75
+ H --> I{Clean?}
76
+ I -->|broken deps\nor missing files| G
77
+ I -->|pass| J[agent-gen wrap name]
78
+
79
+ J --> K[Librarian.sync\ncrawl disk → manifest]
80
+ K --> L[Librarian.audit\nvalidate all paths]
81
+ L --> M{Audit pass?}
82
+ M -->|fail| G
83
+ M -->|pass| N[Compress → name-vX.Y.Z.zip\nPortable Unit]
84
+
85
+ N --> O[Share ZIP]
86
+ O --> P[agent-gen import zip]
87
+ P --> Q[Unpack into .ai/agents/name]
88
+ Q --> R[Audit imported bundle]
89
+ R --> S[Handshake\nregister in global manifest]
90
+ S --> T([Agent ready])
91
+
92
+ T --> U[agent-gen uninstall name]
93
+ U --> V[Remove dir\nDeregister from manifest]
94
+ ```
95
+
96
+ ---
97
+
98
+ ### 3. Remote Import Pipeline (`--from-git`)
99
+
100
+ ```mermaid
101
+ flowchart TD
102
+ A[agent-gen import\n--from-git URL] --> B{Valid URL scheme?\nhttps git@ ssh}
103
+ B -->|no| ERR1([Error: invalid URL])
104
+ B -->|yes| C[git clone --quiet URL]
105
+ C --> D{Clone success?}
106
+ D -->|no| ERR2([Error: clone failed])
107
+ D -->|yes| E[Extract context\nfrom README.md + CLAUDE.md]
108
+
109
+ E --> F[propose_retrofit\ndetect profile]
110
+ F --> G{Profile detected?}
111
+ G -->|claude / gemini / codex| H[Warn if multiple\nprofiles matched]
112
+ G -->|auto| I[Apply auto-rules]
113
+ H --> J[Librarian.migrate\nremap dirs to 5-dir standard]
114
+ I --> J
115
+
116
+ J --> K[Auto-stub\nskill-manifest.json files]
117
+ K --> L[Init agent-manifest.json\ninject description from context]
118
+ L --> M[Librarian.wrap\ncompress to ZIP]
119
+ M --> N[Unpack + Audit]
120
+ N --> O{Audit pass?}
121
+ O -->|fail| ERR3([Error: abort import])
122
+ O -->|pass| P[Register in\nglobal manifest]
123
+ P --> Q[Cleanup temp dir]
124
+ Q --> R([Import complete\nAgent ready])
125
+ ```
126
+
127
+ ---
128
+
129
+ ### 4. Librarian Intelligence Layer
130
+
131
+ ```mermaid
132
+ flowchart TD
133
+ subgraph Librarian.sync
134
+ A[Crawl agent root\nTRACKED_DIRS] --> B[Update resources\nin manifest]
135
+ B --> C[_detect_dependencies\nper resource file]
136
+ C --> D{File type?}
137
+ D -->|.py| E[AST import parser\nextract module names]
138
+ D -->|.md / other| F[Regex scan\nfor @depends-on: markers]
139
+ E --> G[Write dependencies\nmap to manifest]
140
+ F --> G
141
+ G --> H[_detect_orchestration\nfirst file in orchestration/]
142
+ H --> I[_update_skills_metadata\nparse skill-manifest.json files]
143
+ I --> J[Save manifest]
144
+ end
145
+
146
+ subgraph Librarian.audit
147
+ J --> K[validate\ncheck all resource paths exist]
148
+ K --> L[Check broken dependencies\ncross-file refs missing on disk]
149
+ L --> M[Check untracked files\non disk but not in manifest]
150
+ M --> N[Check missing\nskill-manifest.json]
151
+ N --> O[Check skill version drift\nskill-manifest vs SKILL.md frontmatter]
152
+ O --> P[_check_repo_state\nlatest tag + remote URL match]
153
+ P --> Q([Return audit report])
154
+ end
155
+ ```
156
+
157
+ ---
158
+
159
+ ### 5. Multi-CLI Harness — Adapter Wiring
160
+
161
+ ```mermaid
162
+ graph LR
163
+ subgraph ".ai/ shared"
164
+ SK[skills/]
165
+ CMD[commands/]
166
+ end
167
+
168
+ subgraph ".ai/adapters/claude/"
169
+ CS[skills →]
170
+ CC[commands →]
171
+ CSET[settings.json]
172
+ end
173
+
174
+ subgraph ".ai/adapters/gemini/"
175
+ GT[tools →]
176
+ GCFG[config.json]
177
+ end
178
+
179
+ subgraph ".ai/adapters/codex/"
180
+ CP[prompts →]
181
+ CCFG[config.toml]
182
+ end
183
+
184
+ CS -->|symlink| SK
185
+ CC -->|symlink| CMD
186
+ GT -->|symlink| SK
187
+ CP -->|symlink| CMD
188
+
189
+ CLAUDE([Claude Code]) --> CS
190
+ CLAUDE --> CC
191
+ GEMINI([Gemini CLI]) --> GT
192
+ CODEX([Codex CLI]) --> CP
193
+ ```
194
+
195
+ ---
196
+
197
+ ### 6. CI Pipeline (every push / PR)
198
+
199
+ ```mermaid
200
+ flowchart TD
201
+ A([Push or PR\nto dev / main]) --> B
202
+
203
+ subgraph ci.yml
204
+ B[Job: lint\nruff check src/] --> C{Lint pass?}
205
+ C -->|fail| STOP1([Block — fix lint errors])
206
+ C -->|pass| D
207
+
208
+ D[Job: test matrix\nPython 3.11 + 3.12\nin parallel]
209
+ D --> E[pip install -e '.[dev]']
210
+ E --> F[pytest\n--cov=agent_gen\n--cov-fail-under=80]
211
+ F --> G{Tests + Coverage\n≥ 80%?}
212
+ G -->|fail| STOP2([Block — fix tests\nor add coverage])
213
+ G -->|pass| H([Status check green\nTests + Coverage ✓])
214
+ end
215
+
216
+ H --> I{Is this a PR\nto dev?}
217
+ I -->|yes| J[Branch protection gate\nrequires green status]
218
+ J --> K([PR can be merged])
219
+ ```
220
+
221
+ ---
222
+
223
+ ### 7. CD Pipeline (on version tag)
224
+
225
+ ```mermaid
226
+ flowchart TD
227
+ A([git tag vX.Y.Z\ngit push origin vX.Y.Z]) --> B
228
+
229
+ subgraph release.yml
230
+ B[Job: build] --> C[pip install build]
231
+ C --> D[python -m build]
232
+ D --> E[Produce dist/\nwheel + sdist]
233
+ E --> F[Upload artifacts\nto Actions store]
234
+
235
+ F --> G[Job: github-release\nruns after build]
236
+ G --> H[Extract release notes\nfrom CHANGELOG.md]
237
+ H --> I[Create GitHub Release\nattach wheel + sdist]
238
+
239
+ F --> J[Job: pypi-publish\nruns after build]
240
+ J --> K[OIDC trusted publish\nno token secret needed]
241
+ K --> L([Published to PyPI\npypi.org/project/agentfactory-gen])
242
+ end
243
+
244
+ I --> M([Release visible\non GitHub Releases page])
245
+ ```
246
+
247
+ ---
248
+
249
+ ### 8. Traceability / Milestone Update Workflow
250
+
251
+ ```mermaid
252
+ flowchart TD
253
+ A([Work starts\non an issue]) --> B[Create feature branch\nfix/feat/docs/upgrade]
254
+ B --> C[Implement changes]
255
+ C --> D[Push branch\nOpen PR]
256
+ D --> E[CI runs\nlint + tests + coverage]
257
+ E --> F{CI green?}
258
+ F -->|no| C
259
+ F -->|yes| G[PR review + merge]
260
+
261
+ G --> H[Update .ai/memory/milestones.md\nStep 8.5 of git-versioning skill]
262
+ H --> I[Move issue row\nPending → Completed]
263
+ I --> J[Fill Branch / PR / Commit]
264
+ J --> K{Is this a\nrelease commit?}
265
+ K -->|yes| L[Stamp Tag column\nfor all shipped items]
266
+ K -->|no| M[Bump milestones.md\nversion marker PATCH]
267
+ L --> M
268
+ M --> N[git tag vX.Y.Z\ntriggers CD pipeline]
269
+ N --> O([GitHub Release\n+ PyPI publish])
270
+ ```
271
+
272
+ ---
273
+
274
+ ## Project Layout
275
+
276
+ ```text
277
+ project/
278
+ ├── CLAUDE.md → .ai/AgentFactory.md ← auto-loaded by Claude
279
+ ├── AGENTS.md → .ai/AgentFactory.md ← auto-loaded by Codex (same file)
280
+ ├── GEMINI.md → .ai/AgentFactory.md ← auto-loaded by Gemini (same file)
281
+ ├── CODEX.md → .ai/AgentFactory.md ← alias (same file)
282
+ ├── .claude → .ai/adapters/claude
283
+ ├── .gemini → .ai/adapters/gemini
284
+ ├── .codex → .ai/adapters/codex
285
+ └── .ai/
286
+ ├── AgentFactory.md ← single source of truth for all CLI instructions
287
+ ├── agent-manifest.json ← global agent registry
288
+ ├── adapters/ ← per-CLI config + capability symlinks
289
+ │ ├── claude/ settings.json, commands →, skills →
290
+ │ ├── gemini/ config.json, tools → skills
291
+ │ └── codex/ config.toml, prompts → commands
292
+ ├── rules/ ← enforceable project constraints
293
+ ├── commands/ ← Claude slash commands + Codex prompts (unified)
294
+ ├── skills/ ← reusable deep-context workflows + Gemini tools
295
+ ├── agents/ ← deployed agent directories
296
+ ├── memory/ ← project state + milestones traceability matrix
297
+ └── scripts/ ← harness utilities (harness-doctor.sh)
298
+ ```
299
+
300
+ Each agent under `.ai/agents/<name>/` follows the **5-Directory Standard**:
301
+ `skills/` · `commands/` · `docs/` · `scripts/` · `orchestration/`
302
+
303
+ ---
304
+
305
+ ## Installation
306
+
307
+ ```bash
308
+ pip install agentfactory-gen
309
+ ```
310
+
311
+ Or install from source (editable):
312
+
313
+ ```bash
314
+ git clone https://github.com/matheusmlopess/AgentFactory.git
315
+ cd AgentFactory
316
+ pip install -e ".[dev]"
317
+ ```
318
+
319
+ Requires Python 3.11+.
320
+
321
+ ---
322
+
323
+ ## Quick Start
324
+
325
+ ```bash
326
+ # 1. Initialise the harness in your project
327
+ agent-gen init
328
+
329
+ # 2. Deploy your first agent
330
+ agent-gen deploy my-agent
331
+
332
+ # 3. Set a description
333
+ agent-gen describe my-agent --desc "My first AgentFactory agent"
334
+
335
+ # 4. Audit integrity
336
+ agent-gen audit my-agent
337
+
338
+ # 5. Package into a Portable Unit
339
+ agent-gen wrap my-agent
340
+
341
+ # 6. Import a remote agent in one step
342
+ agent-gen import --from-git https://github.com/user/some-agent-repo
343
+ ```
344
+
345
+ ---
346
+
347
+ ## CLI Reference
348
+
349
+ ### Setup
350
+ ```bash
351
+ agent-gen init # scaffold .ai/ harness + root symlinks
352
+ agent-gen init --project-root <path> # target a different directory
353
+ ```
354
+
355
+ ### Agent Lifecycle
356
+ ```bash
357
+ agent-gen deploy <name> # scaffold a new agent
358
+ agent-gen describe <name> --desc "…" # set agent description
359
+ agent-gen describe <name> --plan <p> # set orchestration plan path
360
+ agent-gen audit <name> # check for missing files, broken deps, version drift
361
+ agent-gen wrap <name> # compress agent into a shareable ZIP (Portable Unit)
362
+ agent-gen wrap <name> --out <dir> # write ZIP to a specific directory
363
+ agent-gen import <zip> # unpack ZIP and register agent
364
+ agent-gen import --from-git <url> # clone repo, auto-retrofit, and import in one step
365
+ agent-gen uninstall <name> # remove agent cleanly
366
+ ```
367
+
368
+ ### Skills & Intelligence
369
+ ```bash
370
+ agent-gen import-skill <path> # import skill into root .ai/skills/
371
+ agent-gen import-skill <path> --to <agent> # import into a specific agent
372
+ agent-gen retrofit <path> # convert Claude/Gemini/Codex layout to AgentFactory standard
373
+ ```
374
+
375
+ ### Global flag
376
+ ```bash
377
+ agent-gen -q <command> # suppress all informational output (quiet mode)
378
+ ```
379
+
380
+ ---
381
+
382
+ ## Key Features
383
+
384
+ **`--from-git`** — Import any GitHub repo as an agent in one command:
385
+ ```bash
386
+ agent-gen import --from-git https://github.com/user/repo
387
+ ```
388
+ Reads `README.md` and `CLAUDE.md` to extract descriptions, auto-detects and applies the correct retrofit profile, creates `skill-manifest.json` stubs for sub-agents, and registers the result in `.ai/AgentFactory.md`.
389
+
390
+ **Librarian** (`src/agent_gen/librarian.py`) — core engine behind every lifecycle operation:
391
+ - Manifest integrity validation
392
+ - AST-based dependency detection (Python imports + `<!-- @depends-on: -->` annotations)
393
+ - Skill manifest auto-registration
394
+ - Audit: version drift, repo-state staleness, remote URL mismatch, path traversal protection
395
+
396
+ **Harness Doctor** (`.ai/scripts/harness-doctor.sh`) — live health check:
397
+ ```bash
398
+ bash .ai/scripts/harness-doctor.sh # full report
399
+ bash .ai/scripts/harness-doctor.sh --ci # machine-readable + snapshot JSON
400
+ ```
401
+ Exit codes: `0` clean · `1` warnings · `2` critical violations.
402
+
403
+ ---
404
+
405
+ ## CI/CD
406
+
407
+ | Trigger | Workflow | What runs |
408
+ |---|---|---|
409
+ | Push / PR to `dev` or `main` | `ci.yml` | ruff lint → pytest (3.11 + 3.12) → coverage ≥ 80% |
410
+ | `git tag v*` | `release.yml` | build wheel/sdist → GitHub Release → PyPI publish |
411
+
412
+ Branch protection on `dev` requires the **Tests + Coverage** status check to pass before any PR can merge.
413
+
414
+ See [`docs/CICD-WORKFLOW.md`](docs/CICD-WORKFLOW.md) for a full explanation of both pipelines.
415
+
416
+ ---
417
+
418
+ ## Architecture & Contributing
419
+
420
+ See `.ai/AgentFactory.md` for architecture, domain context, and project constraints.
421
+ See `docs/SPEC.md` for the technical specification (manifest schema, intelligence layer, lifecycle commands).
422
+ Contributions should follow the rules in `.ai/rules/`.
423
+
424
+ ---
425
+
426
+ ## Registered Agents
427
+ <!-- @agent-registry:start -->
428
+ - **test-agent**: Manual Description (See: `.ai/agents/test-agent/docs/CLAUDE.md`)
429
+ - **test-claude-agent**: AgentFactory-powered agent demonstrating a minimal Claude-native agent layout. (See: `.ai/agents/test-claude-agent/docs/CLAUDE.md`)
430
+ - **test-intel-agent**: AgentFactory-powered agent demonstrating intelligence-layer features: dependency detection and sk... (See: `.ai/agents/test-intel-agent/docs/CLAUDE.md`)
431
+ <!-- @agent-registry:end -->
@@ -0,0 +1,34 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "agentfactory-gen"
7
+ version = "0.3.0"
8
+ description = "Agent Factory — Librarian-powered agent lifecycle manager"
9
+ requires-python = ">=3.11"
10
+ dependencies = [
11
+ "click>=8.1",
12
+ "filelock>=3.13.0",
13
+ ]
14
+
15
+ [project.scripts]
16
+ agent-gen = "agent_gen.cli:cli"
17
+
18
+ [tool.setuptools.packages.find]
19
+ where = ["src"]
20
+ include = ["agent_gen*"]
21
+
22
+ [project.optional-dependencies]
23
+ dev = ["pytest>=8", "pytest-cov>=5", "ruff>=0.4"]
24
+
25
+ [tool.pytest.ini_options]
26
+ testpaths = ["src/tests"]
27
+
28
+ [tool.coverage.run]
29
+ source = ["agent_gen"]
30
+ branch = true
31
+
32
+ [tool.coverage.report]
33
+ fail_under = 80
34
+ show_missing = true
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1 @@
1
+ """AgentFactory — agent_gen package."""
@@ -0,0 +1,4 @@
1
+ from .cli import cli
2
+
3
+ if __name__ == "__main__":
4
+ cli()