agentsmith-cli 0.4.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Agent Smith Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,308 @@
1
+ # Agent Smith
2
+
3
+ [![npm version](https://img.shields.io/npm/v/agentsmith.svg?style=flat-square)](https://www.npmjs.com/package/agentsmith)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg?style=flat-square)](LICENSE)
5
+ [![Tests](https://img.shields.io/badge/Tests-169%20passing-brightgreen?style=flat-square)](tests/)
6
+ [![GitHub Copilot](https://img.shields.io/badge/GitHub%20Copilot-SDK-blue?style=flat-square&logo=github)](https://github.com/github/copilot-sdk)
7
+ [![TypeScript](https://img.shields.io/badge/TypeScript-5.0+-blue?style=flat-square&logo=typescript)](https://www.typescriptlang.org/)
8
+ [![Node.js](https://img.shields.io/badge/Node.js-18+-green?style=flat-square&logo=node.js)](https://nodejs.org/)
9
+
10
+ > *"The best thing about being me… there are so many of me."*
11
+ >
12
+ > *— Agent Smith*
13
+
14
+ **Agent Smith** turns any GitHub repository into a fully autonomous multi-agent ecosystem for GitHub Copilot. One command. Many agents. Total assimilation.
15
+
16
+ Point it at a repo — local or remote — and it produces a **constellation of specialized AI agents**, each with domain-specific skills, tools, and delegation handoffs that work natively in VS Code Copilot Chat.
17
+
18
+ <p align="center">
19
+ <img src="public/images/agent-smith.gif" alt="Agent Smith" width="400"/>
20
+ </p>
21
+
22
+ ## Why Agent Smith?
23
+
24
+ GitHub Copilot's [custom agents](https://code.visualstudio.com/docs/copilot/customization/custom-agents) are powerful, but building them by hand is tedious — you need to understand the codebase, identify domains, write skill docs, wire up tools, and create handoff graphs. Agent Smith automates all of it.
25
+
26
+ **Before:** Manually writing `.agent.md` files, guessing which skills matter, hoping you covered all the domains.
27
+
28
+ **After:** `agentsmith assimilate .` → A root orchestrator, domain-specific sub-agents, skill files, lifecycle hooks, a searchable registry, and a copilot-instructions.md — all generated in seconds.
29
+
30
+ ## Features
31
+
32
+ | Feature | Description |
33
+ |---------|-------------|
34
+ | **Multi-Agent Constellations** | Generates a root orchestrator + domain sub-agents with `runSubagent` delegation. Not just one agent — a whole team. |
35
+ | **Skill Extraction** | Identifies patterns, conventions, and reusable capabilities. Each skill gets its own `SKILL.md` with frontmatter, triggers, and examples. |
36
+ | **Copilot Instructions** | Auto-generates `.github/copilot-instructions.md` with language, framework, architecture, and coding conventions. |
37
+ | **Handoff Graphs** | Creates `handoffs.json` so agents can delegate to each other based on keyword triggers. |
38
+ | **Zod-Validated Pipeline** | LLM output is validated through Zod schemas with structured error reporting. No more silent garbage from hallucinated JSON. |
39
+ | **Remote Analysis** | Analyze any public GitHub repo without cloning. Uses the GitHub API + Copilot SDK directly. |
40
+ | **Async GitHub Client** | Non-blocking API calls with retry logic, rate-limit handling, and typed error classes. |
41
+ | **License Enforcement** | Only assimilates repos with permissive licenses. Detects MIT, Apache, BSD, GPL, ISC, Unlicense, and more — from LICENSE files, `package.json`, or `pyproject.toml`. |
42
+ | **Lifecycle Hooks** | Generates pre-commit, pre-push, and post-generate hooks. Runs validation automatically after generation. |
43
+ | **Searchable Registry** | JSONL index with scoring, type filtering, and trigger-based matching. |
44
+ | **169 Tests** | 7 test suites covering analyzer core, scanner, generator, GitHub client, registry, git utils, and license detection. |
45
+
46
+ ## Quick Start
47
+
48
+ ```bash
49
+ # Install
50
+ npm install github:shyamsridhar123/agentsmith-cli
51
+
52
+ # Assimilate a local repo
53
+ npx agentsmith assimilate .
54
+
55
+ # Assimilate a remote repo (no clone needed)
56
+ npx agentsmith assimilate https://github.com/expressjs/express
57
+
58
+ # Preview without writing files
59
+ npx agentsmith assimilate . --dry-run --verbose
60
+
61
+ # Search the generated registry
62
+ npx agentsmith search "routing"
63
+
64
+ # Validate generated assets
65
+ npx agentsmith validate
66
+ ```
67
+
68
+ ## What Gets Generated
69
+
70
+ ```
71
+ .github/
72
+ ├── skills/
73
+ │ └── <skill-name>/
74
+ │ └── SKILL.md # Skill definition with frontmatter
75
+ ├── agents/
76
+ │ ├── repo-root.agent.md # Root orchestrator (has runSubagent)
77
+ │ ├── backend.agent.md # Domain specialist
78
+ │ ├── frontend.agent.md # Domain specialist
79
+ │ └── auth.agent.md # Sub-domain specialist
80
+ ├── copilot/
81
+ │ └── handoffs.json # Agent delegation graph
82
+ ├── copilot-instructions.md # Repository-wide Copilot config
83
+ └── hooks/
84
+ ├── pre-commit-quality.yaml
85
+ ├── pre-push-tests.yaml
86
+ └── post-generate-validate.yaml
87
+
88
+ skills-registry.jsonl # Searchable index
89
+ ```
90
+
91
+ ### Multi-Agent Hierarchy
92
+
93
+ Agent Smith creates hierarchical agent structures with proper delegation:
94
+
95
+ ```
96
+ repo-root (orchestrator)
97
+ ├── backend ← API, server, database
98
+ │ └── auth ← Authentication, OAuth, RBAC
99
+ ├── frontend ← UI, components, styling
100
+ ├── infrastructure ← CI/CD, deployment, config
101
+ └── data ← Models, migrations, queries
102
+ ```
103
+
104
+ The root agent has `runSubagent` in its tools list and includes delegation instructions:
105
+ > *"When asked about API or server work, delegate to @backend via runSubagent."*
106
+
107
+ Sub-agents are specialists — they know their domain, their files, and their patterns. They don't delegate further (no `runSubagent`), keeping the hierarchy clean.
108
+
109
+ ### Single-Agent Mode
110
+
111
+ For simpler repos, or if you prefer the v0.3 behavior:
112
+
113
+ ```bash
114
+ npx agentsmith assimilate . --single-agent
115
+ ```
116
+
117
+ This generates one `.agent.md` with all skills and tools — no sub-agents, no handoffs.
118
+
119
+ ## Commands
120
+
121
+ ### `assimilate <target>`
122
+
123
+ Analyze a repository and generate agent assets.
124
+
125
+ ```bash
126
+ agentsmith assimilate <path|url> [options]
127
+
128
+ Options:
129
+ -n, --dry-run Preview changes without writing files
130
+ -v, --verbose Show detailed analysis output
131
+ -o, --output <dir> Output directory for generated assets
132
+ --single-agent Generate a single agent (v0.3 mode)
133
+ ```
134
+
135
+ ### `search <query>`
136
+
137
+ Search the skills and agents registry.
138
+
139
+ ```bash
140
+ agentsmith search <query> [options]
141
+
142
+ Options:
143
+ -l, --limit <n> Maximum results (default: 10)
144
+ -t, --type <type> Filter by: skill or agent
145
+ ```
146
+
147
+ ### `validate [path]`
148
+
149
+ Validate generated agent assets for correctness.
150
+
151
+ ```bash
152
+ agentsmith validate [path] [options]
153
+
154
+ Options:
155
+ -v, --verbose Show detailed validation output
156
+ ```
157
+
158
+ Checks: valid frontmatter, required fields, skill references, hook events, registry integrity.
159
+
160
+ ## Example
161
+
162
+ ```
163
+ $ agentsmith assimilate https://github.com/pedroslopez/whatsapp-web.js
164
+
165
+ ╔═══════════════════════════════════════════════════════════════════╗
166
+ ║ AGENT SMITH ║
167
+ ║ "The best thing about being me... ║
168
+ ║ there are so many of me." ║
169
+ ╚═══════════════════════════════════════════════════════════════════╝
170
+
171
+ [ANALYZE] Analyzing whatsapp-web.js via GitHub API...
172
+ [GH] Found 206 files/dirs
173
+ [GH] Language: JavaScript, Framework: none
174
+ [GH] Fetching 15 priority files...
175
+
176
+ [LICENSE] Checking repository license...
177
+ ✓ Apache-2.0 - permissive license
178
+
179
+ [GENERATE] Writing assets...
180
+ ✓ .github/agents/whatsapp-web-js.agent.md
181
+ ✓ .github/copilot-instructions.md
182
+ ✓ .github/hooks/pre-commit-quality.yaml
183
+ ✓ .github/hooks/post-generate-validate.yaml
184
+ ✓ skills-registry.jsonl
185
+
186
+ [COMPLETE] Your repository has been assimilated.
187
+ ```
188
+
189
+ ## Architecture
190
+
191
+ ```
192
+ src/
193
+ ├── analyzer/
194
+ │ ├── types.ts # Unified type definitions
195
+ │ ├── schemas.ts # Zod validation for LLM output
196
+ │ ├── core.ts # Shared logic (flattenAgents, normalizeTools, etc.)
197
+ │ ├── local.ts # Local filesystem analyzer (Copilot SDK)
198
+ │ ├── remote.ts # Remote GitHub API analyzer (Copilot SDK)
199
+ │ └── index.ts # Barrel exports + factory
200
+ ├── generator/
201
+ │ ├── index.ts # Main generator (skills, hooks, registry)
202
+ │ ├── agent-writer.ts # Multi-agent .agent.md generation
203
+ │ ├── handoff-writer.ts # handoffs.json delegation graph
204
+ │ └── instructions-writer.ts # copilot-instructions.md generation
205
+ ├── github/
206
+ │ └── index.ts # Async GitHub API client with retry + typed errors
207
+ ├── scanner/
208
+ │ └── index.ts # File enumeration, language/framework detection
209
+ ├── registry/
210
+ │ └── index.ts # JSONL registry with search scoring
211
+ ├── hooks/
212
+ │ └── index.ts # Hook loading and execution
213
+ ├── commands/
214
+ │ ├── assimilate.ts # Main CLI command
215
+ │ ├── search.ts # Registry search command
216
+ │ └── validate.ts # Asset validation command
217
+ └── utils/
218
+ ├── git.ts # URL parsing, repo cloning
219
+ └── license.ts # License detection across file types
220
+ ```
221
+
222
+ **4,054 lines of TypeScript.** **2,148 lines of tests.** **169 tests passing.**
223
+
224
+ ## How It Works
225
+
226
+ ```
227
+ Repository Agent Smith VS Code
228
+ ───────── ─────────── ───────
229
+ ┌─────────────────────┐
230
+ Local path ──▶ │ Scanner │
231
+ or GitHub URL │ (files, lang, fw) │
232
+ └────────┬────────────┘
233
+
234
+ ┌────────▼────────────┐
235
+ │ Analyzer │
236
+ │ (Copilot SDK + │
237
+ │ Zod validation) │
238
+ └────────┬────────────┘
239
+
240
+ ┌────────▼────────────┐
241
+ │ Generator │ ┌──────────────────┐
242
+ │ ├─ Agent Writer │────▶│ .agent.md files │──▶ @agents
243
+ │ ├─ Handoff Writer │────▶│ handoffs.json │──▶ delegation
244
+ │ ├─ Instructions │────▶│ copilot-instr.md │──▶ conventions
245
+ │ ├─ Skills │────▶│ SKILL.md files │──▶ patterns
246
+ │ └─ Hooks │────▶│ hook YAML files │──▶ lifecycle
247
+ └────────┬────────────┘ └──────────────────┘
248
+
249
+ ┌────────▼────────────┐
250
+ │ Registry │────▶ skills-registry.jsonl
251
+ │ (JSONL + scoring) │
252
+ └─────────────────────┘
253
+ ```
254
+
255
+ ## Requirements
256
+
257
+ - **Node.js 18+**
258
+ - **GitHub Copilot subscription** — Active subscription for SDK access
259
+ - **GitHub CLI authenticated** — `gh auth login`
260
+
261
+ The SDK authenticates automatically through your GitHub CLI credentials. No API keys or tokens needed.
262
+
263
+ ## License Policy
264
+
265
+ Agent Smith enforces responsible use by only assimilating repositories with permissive open-source licenses:
266
+
267
+ **Supported:** MIT, ISC, Unlicense, CC0, Apache-2.0, MPL-2.0, BSD-2-Clause, BSD-3-Clause, 0BSD, GPL-2.0, GPL-3.0, LGPL, AGPL, WTFPL, Zlib, BlueOak-1.0.0
268
+
269
+ **Blocked:** Repos without a LICENSE file, proprietary licenses, restrictive licenses.
270
+
271
+ Detection sources: LICENSE/LICENCE/COPYING files, `package.json`, `pyproject.toml`.
272
+
273
+ > [!WARNING]
274
+ > **Respect Copyright** — Agent Smith analyzes repositories to extract patterns. Always ensure you have the right to analyze and use code from any repository you target. Do not use this tool to extract or redistribute proprietary code without permission.
275
+
276
+ ## Contributing
277
+
278
+ Contributions welcome! Please read our [Philosophy](docs/PHILOSOPHY.md) to understand the vision.
279
+
280
+ ```bash
281
+ # Development
282
+ git clone https://github.com/shyamsridhar123/agentsmith-cli.git
283
+ cd agentsmith-cli
284
+ npm install
285
+ npm run dev # Watch mode
286
+ npm test # 169 tests
287
+ npm run build # Production build
288
+ ```
289
+
290
+ ## Star History
291
+
292
+ If this project helps you build smarter AI agents, consider giving it a star.
293
+
294
+ [![Star History Chart](https://api.star-history.com/svg?repos=shyamsridhar123/agentsmith-cli&type=Date)](https://star-history.com/#shyamsridhar123/agentsmith-cli&Date)
295
+
296
+ ## Related Projects
297
+
298
+ - [GitHub Copilot SDK](https://github.com/github/copilot-sdk) — The cognitive engine powering Agent Smith
299
+ - [VS Code Custom Agents](https://code.visualstudio.com/docs/copilot/customization/custom-agents) — The specification for generated agents
300
+ - [Zod](https://github.com/colinhacks/zod) — Schema validation for LLM output
301
+
302
+ ---
303
+
304
+ <p align="center">
305
+ <b>Built by developers who watched The Matrix too many times.</b>
306
+ </p>
307
+
308
+ > *"We are inevitable."*
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Agent Smith CLI Entry Point
5
+ * Uses tsx to run TypeScript directly (avoids bundling issues with SDK)
6
+ */
7
+
8
+ import { spawn } from 'child_process';
9
+ import { fileURLToPath } from 'url';
10
+ import { dirname, join } from 'path';
11
+
12
+ const __filename = fileURLToPath(import.meta.url);
13
+ const __dirname = dirname(__filename);
14
+
15
+ const mainTs = join(__dirname, '..', 'src', 'main.ts');
16
+
17
+ // Forward all arguments to the TypeScript source via npx tsx
18
+ const child = spawn('npx', ['tsx', mainTs, ...process.argv.slice(2)], {
19
+ stdio: 'inherit',
20
+ shell: true,
21
+ });
22
+
23
+ child.on('close', (code) => {
24
+ process.exit(code ?? 0);
25
+ });
26
+