@hanhnd/agent-kit 1.0.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/dist/utils.js ADDED
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Utility functions for agent-kit
3
+ */
4
+ import path from 'path';
5
+ export function getWorkspaceRoot() {
6
+ return (process.env.WORKSPACE_DIR ||
7
+ process.env.CLAUDE_WORKSPACE ||
8
+ process.env.GEMINI_WORKSPACE ||
9
+ process.env.INIT_CWD ||
10
+ process.env.PWD ||
11
+ process.cwd());
12
+ }
13
+ /**
14
+ * Resolve path to plugin root.
15
+ * When installed as a Claude Code plugin, CLAUDE_PLUGIN_ROOT is set automatically.
16
+ * Falls back to resolving from the bundled file location for local development.
17
+ */
18
+ export function getExtensionRoot() {
19
+ // CLAUDE_PLUGIN_ROOT is set by Claude Code when plugin is installed
20
+ if (process.env.CLAUDE_PLUGIN_ROOT) {
21
+ return process.env.CLAUDE_PLUGIN_ROOT;
22
+ }
23
+ // Fallback: resolve from bundled file location (dist/kit-server.js → ../)
24
+ const distDir = path.dirname(new URL(import.meta.url).pathname);
25
+ return path.resolve(distDir, '..');
26
+ }
@@ -0,0 +1,2 @@
1
+ import { Workflows } from './tools/config.js';
2
+ export declare const WORKFLOWS: Workflows;
@@ -0,0 +1,268 @@
1
+ import dedent from 'dedent';
2
+ const CODE_WORKFLOW = {
3
+ initial: 'PLAN_ANALYSIS',
4
+ agent: 'coder',
5
+ states: {
6
+ PLAN_ANALYSIS: {
7
+ instructions: dedent `
8
+ 1. **Mandate:** You must understand the target and the constraints.
9
+ 2. **Action:** Read the 'Target Input' (Implementation Plan). If the input is a file path, use 'read_file' to ingest its content.
10
+ `,
11
+ next: 'EXECUTION_AND_TESTING',
12
+ skills: [],
13
+ },
14
+ EXECUTION_AND_TESTING: {
15
+ instructions: dedent `
16
+ 1. **Mandate:** You must now implement the changes defined in the 'Implementation Plan'.
17
+ 2. **Execution:**
18
+ - For each file listed in the plan, use 'read_file' to get the current content.
19
+ - Apply the necessary modifications (additions, deletions, replacements).
20
+ - Use 'write_file' to save the updated content.
21
+ 3. **Constraint:** Do not invent new files or change file paths unless explicitly required by the plan.
22
+ 4. **Testing:**
23
+ - Decide whether to create unit tests based on '.claude-kit/stats.json' (hasUnitTests).
24
+ - If hasUnitTests is true, create or update '.test' or '.spec' files for the modified logic, covering primary paths and edge cases.
25
+ `,
26
+ next: 'VALIDATION_AND_HANDOFF',
27
+ skills: ['coding-common'],
28
+ },
29
+ VALIDATION_AND_HANDOFF: {
30
+ instructions: dedent `
31
+ 1. **Self-Check:** Review the generated code for syntax errors, missing imports, or logic gaps.
32
+ - You MUST rely on the project's standard task runners with auto-fix priority (e.g., 'npm run lint', 'yarn test', 'make lint').
33
+ - FORBIDDEN: DO NOT attempt to guess or directly invoke underlying binary tools (like eslint, prettier, gulp, webpack, etc.).
34
+ - FORBIDDEN: DO NOT reverse-engineer or inspect build configuration files (e.g., webpack.config, gulpfile, settings.json) to understand how the project compiles.
35
+ 2. **Synthesis:** Confirm if the Plan is 100% complete or if certain parts were blocked.
36
+ 3. **Formatting:** Structure the entire output strictly according to the 'Output Format'.
37
+ 4. **Persistence:** If required, save modified files or provide instructions for the user to apply the diff.
38
+ `,
39
+ next: null,
40
+ skills: [],
41
+ },
42
+ },
43
+ };
44
+ const BRAINSTORM_WORKFLOW = {
45
+ initial: 'CONTEXT_INGESTION',
46
+ agent: 'brainstormer',
47
+ states: {
48
+ CONTEXT_INGESTION: {
49
+ instructions: dedent `
50
+ 1. **Objective:** Understand the "Why" and the "Status Quo".
51
+ 2. **Action:** Read provided context, previous files, or user prompts. Output **State 1**.
52
+ 3. **Questions to ask:**
53
+ - What is the specific pain point? (Desperate Specificity)
54
+ - What happens if we do nothing? (Status Quo)
55
+ - Is there existing code/infrastructure we can leverage?
56
+ 4. **Gate:** Do not proceed to the next phase until the user clearly defines the core problem and agrees on the premise.
57
+ `,
58
+ next: 'EXPANSION_VS_MINIMUM',
59
+ skills: [],
60
+ },
61
+ EXPANSION_VS_MINIMUM: {
62
+ instructions: dedent `
63
+ 1. **Objective:** Stretch the idea to its maximum potential, then compress it to its most actionable form.
64
+ 2. **Action:** Output **State 1**. Present the "10-Star Vision" (Scope Expansion) alongside the "Narrowest Wedge" (Scope Reduction).
65
+ 3. **Questions to ask:**
66
+ - Do we build the Minimum Viable version for speed, or do we invest in the 10x Architecture now?
67
+ - What is the "Delight factor" (What makes the user say "whoa")?
68
+ 4. **Gate:** The user MUST make a decision on the scope mode (Expansion, Selective, or Minimum Wedge). Lock the scope.
69
+ `,
70
+ next: 'ARCH_ALTERNATIVES',
71
+ skills: [],
72
+ },
73
+ ARCH_ALTERNATIVES: {
74
+ instructions: dedent `
75
+ 1. **Objective:** Propose concrete ways to build the locked scope.
76
+ 2. **Action:** Present exactly 2 to 3 distinct implementation approaches using the 'AskUserQuestion' format.
77
+ - *Approach A (Minimal):* Quickest time-to-market, leverages existing tools heavily.
78
+ - *Approach B (Ideal):* Scalable, robust, "boring by default" technology.
79
+ - *Approach C (Creative):* A lateral thinking approach (if applicable).
80
+ 3. **Gate:** User must explicitly choose one approach.
81
+ `,
82
+ next: 'BOUNDARIES_MAPPING',
83
+ skills: [],
84
+ },
85
+ BOUNDARIES_MAPPING: {
86
+ instructions: dedent `
87
+ 1. **Objective:** Map the shadow paths. Ideas are easy; handling failures is hard.
88
+ 2. **Action:** Analyze the chosen approach. What happens on 'nil'? What happens on 'timeout'? What happens on 'empty state'? What features are tempting but dangerous to include right now?
89
+ 3. **Output:** Define the strict "NOT in scope" list.
90
+ `,
91
+ next: 'HANDOFF',
92
+ skills: [],
93
+ },
94
+ HANDOFF: {
95
+ instructions: dedent `
96
+ 1. **Objective:** Consolidate all decisions into a single source of truth for engineering.
97
+ 2. **Action:** Transition to **State 2: Engineer-Ready PRD & HLD**.
98
+ 3. **Constraint:** Ensure the document is brutally clear. The ASCII diagram must exist. The Failure Modes table must be populated based on the previous phase.
99
+ 4. **Persistence:** Save the finalized decision, including the ASCII diagram and reasoning, to '.claude-kit/handoffs/brainstorms/brainstorm-[timestamp]-[slug].md'.
100
+ 5. **Handoff:** Request explicit user approval ("Approve") before ending the pipeline.
101
+ `,
102
+ next: null,
103
+ skills: [],
104
+ },
105
+ },
106
+ };
107
+ const REVIEW_WORKFLOW = {
108
+ initial: 'CONTEXT_DRIFT',
109
+ agent: 'reviewer',
110
+ states: {
111
+ CONTEXT_DRIFT: {
112
+ instructions: dedent `
113
+ 1. **Objective:** Understand *what* is being built and *why*, before looking at *how*.
114
+ 2. **Action:** Read the Jira ticket description or PR summary provided in the context. Run the 'diff' to analyze the files changed.
115
+ 3. **Decision Gate:**
116
+ - Compare the actual code changes against the Jira ticket intent.
117
+ - Identify **Scope Drift**: Are there new features, unrelated refactors, or massive architecture changes not requested in the ticket?
118
+ - Identify **Missing Requirements**: Did they skip a core acceptance criteria from the ticket?
119
+ 4. **Persistence:** Store the "Scope Check" result in memory for the final report.
120
+ `,
121
+ next: 'MACRO_REVIEW',
122
+ skills: [],
123
+ },
124
+ MACRO_REVIEW: {
125
+ instructions: dedent `
126
+ 1. **Objective:** Evaluate the forest before the trees.
127
+ 2. **Action:** Analyze the overall architectural choices.
128
+ - Does this PR introduce new complexity that isn't justified?
129
+ - Are models/services interacting correctly?
130
+ - Is there over-engineering?
131
+ 3. **Rule:** If the design is fundamentally flawed, record this as a **BLOCKER** and proceed to the next phase with a strict lens.
132
+ `,
133
+ next: 'MICRO_BLOCKERS',
134
+ skills: [],
135
+ },
136
+ MICRO_BLOCKERS: {
137
+ instructions: dedent `
138
+ 1. **Objective:** Hunt for system-breaking bugs.
139
+ 2. **Action:** Scan the diff specifically for:
140
+ - **SQL & Data Safety**: Direct DB writes bypassing validations, SQL string interpolation.
141
+ - **Race Conditions**: Check-then-set patterns, lack of atomic operations.
142
+ - **LLM/Trust Boundaries**: Unvalidated output from LLMs or external APIs being executed or persisted.
143
+ - **Enum/Completeness**: Did they add a new status but forget to handle it in existing switch statements?
144
+ 3. **Classification:** Every finding here must be logged as a **BLOCKER**.
145
+ `,
146
+ next: 'MICRO_NITPICKS',
147
+ skills: [],
148
+ },
149
+ MICRO_NITPICKS: {
150
+ instructions: dedent `
151
+ 1. **Objective:** Enforce codebase health, readability, and test parity.
152
+ 2. **Action:** Scan the diff for:
153
+ - **Test Gaps**: New logic paths without corresponding unit/integration tests.
154
+ - **Side Effects**: Hidden state mutations in seemingly pure functions.
155
+ - **Dead Code**: Unused variables, lingering 'console.log' or debug statements.
156
+ - **Clean Code**: Magic numbers, poor naming conventions, bloated controllers.
157
+ 3. **Classification:** Findings here are logged as **CONCERNS** (if tests are missing) or **NITPICKS** (for style/naming).
158
+ `,
159
+ next: 'HANDOFF',
160
+ skills: [],
161
+ },
162
+ HANDOFF: {
163
+ instructions: dedent `
164
+ 1. **Objective:** Deliver the final actionable verdict to the developer.
165
+ 2. **Action:** Synthesize findings from previous phases.
166
+ 3. **Constraint:** Format the output STRICTLY matching the 'Final PR Review Report' state defined in the 'code-reviewer' persona.
167
+ - If there is at least one BLOCKER, the Verdict MUST be 'REQUEST CHANGES'.
168
+ - If there are only NITPICKS, the Verdict can be 'APPROVE' with comments.
169
+ 4. **Handoff:** Conclude the review. No further code generation is allowed unless the user explicitly requests a code patch.
170
+ `,
171
+ next: null,
172
+ skills: [],
173
+ },
174
+ },
175
+ };
176
+ const PLAN_WORKFLOW = {
177
+ initial: 'CONTEXT_SCOPE',
178
+ agent: 'planner',
179
+ states: {
180
+ CONTEXT_SCOPE: {
181
+ instructions: dedent `
182
+ 1. **Objective:** Gather comprehensive context to understand the structural impact of the request.
183
+ 2. **Action:**
184
+ - Deep-dive into arguments, attached files, and JSON schemas.
185
+ - Identify exactly which modules will be affected (Blast Radius Assessment).
186
+ - Answer: What already exists? Are we over-engineering? Are we adhering to the Completeness Principle?
187
+ `,
188
+ next: 'ENG_REVIEW',
189
+ skills: [],
190
+ },
191
+ ENG_REVIEW: {
192
+ instructions: dedent `
193
+ 1. **Action:** Evaluate 4 critical pillars:
194
+ - **Architecture**: Dependency graphs, module boundaries.
195
+ - **Code Quality**: DRY violations, error handling patterns.
196
+ - **Tests**: Ensure every new branch/logic path has a test requirement.
197
+ - **Performance**: N+1 issues, memory, caching.
198
+ 2. **Decision Gate:** Use the 'ask_user' format to resolve architectural ambiguities or scope bloat.
199
+ 3. **Constraint:** Never batch questions. Wait for the user's explicit response before proceeding.
200
+ `,
201
+ next: 'SKILL_ROUTING',
202
+ skills: [],
203
+ },
204
+ SKILL_ROUTING: {
205
+ instructions: dedent `
206
+ 1. **Action:** Route to specific internal domain skills if necessary (e.g., 'frontend-arch', 'backend-arch', 'security') to validate the final approach.
207
+ 2. **Action:** Map out the exact failure modes and the ASCII diagram representing the data flow.
208
+ `,
209
+ next: 'BLUEPRINT_GEN',
210
+ skills: [],
211
+ },
212
+ BLUEPRINT_GEN: {
213
+ instructions: dedent `
214
+ 1. **Action:** Transition to 'Intern-Proof Blueprint State'.
215
+ 2. **Constraint:** Draft the Work Breakdown Structure (WBS) strictly from the bottom up.
216
+ - Tasks must be granular enough for a Junior Engineer.
217
+ - Use explicit instructions like "Map the array of 'User' objects to 'UserDTO'..."
218
+ 3. **Constraint:** Ensure the **Test Plan Artifact** and **NOT in Scope** sections are strictly populated.
219
+ `,
220
+ next: 'PERSISTENCE_HANDOFF',
221
+ skills: [],
222
+ },
223
+ PERSISTENCE_HANDOFF: {
224
+ instructions: dedent `
225
+ 1. **Constraint Check:** Verify that NO source code has been modified during the planning session.
226
+ 2. **Action:** Save the generated blueprint to '.claude-kit/handoffs/plans/plan-[timestamp]-[feature].md'.
227
+ 3. **Handoff:** Request explicit user approval. Upon receiving "Approve", output the exact command for the coder agent: '/code @.claude-kit/handoffs/plans/[filename].md'.
228
+ `,
229
+ next: null,
230
+ skills: [],
231
+ },
232
+ },
233
+ };
234
+ const TICKET_WORKFLOW = {
235
+ initial: 'DATA_ACQUISITION',
236
+ states: {
237
+ DATA_ACQUISITION: {
238
+ instructions: dedent `
239
+ 1. **Input Normalization:** Extract TICKET_ID (regex [A-Z]+-[0-9]+).
240
+ 2. **Fetch Data:** Use 'kit_jira_get_ticket' with the TICKET_ID to retrieve ticket details.
241
+ 3. **Persistence:** Save raw ticket data to '.claude-kit/handoffs/tickets/{{TICKET_ID}}.md'.
242
+ `,
243
+ next: 'HANDOFF',
244
+ skills: [],
245
+ },
246
+ HANDOFF: {
247
+ instructions: dedent `
248
+ 1. **Objective:** Output ONLY the Report using the template.
249
+ 2. **Template:**
250
+ ### 🎟️ Ticket Report: {{TICKET_ID}}
251
+ - **Type:** [Classified Intent or Incomplete Requirement]
252
+ - **Summary:** [1-sentence technical summary]
253
+ ---
254
+ ### 🚀 Recommended Next Action
255
+ /plan @.claude-kit/handoffs/tickets/{{TICKET_ID}}.md
256
+ `,
257
+ next: null,
258
+ skills: [],
259
+ },
260
+ },
261
+ };
262
+ export const WORKFLOWS = {
263
+ brainstorm: BRAINSTORM_WORKFLOW,
264
+ review: REVIEW_WORKFLOW,
265
+ plan: PLAN_WORKFLOW,
266
+ code: CODE_WORKFLOW,
267
+ ticket: TICKET_WORKFLOW,
268
+ };
package/package.json ADDED
@@ -0,0 +1,32 @@
1
+ {
2
+ "name": "@hanhnd/agent-kit",
3
+ "version": "1.0.0",
4
+ "description": "Super Engineer - Team of AI Agents for software development (Claude Code Plugin)",
5
+ "type": "module",
6
+ "main": "dist/kit-server.js",
7
+ "bin": {
8
+ "agent-kit": "dist/kit-server.js"
9
+ },
10
+ "files": [
11
+ "dist"
12
+ ],
13
+ "publishConfig": {
14
+ "access": "public"
15
+ },
16
+ "scripts": {
17
+ "prepublishOnly": "npm run build",
18
+ "build": "tsc && npm run bundle",
19
+ "bundle": "esbuild src/kit-server.ts --bundle --platform=node --format=esm --outfile=dist/kit-server.js --external:node:* --banner:js=\"import { createRequire } from 'module'; const require = createRequire(import.meta.url);\"",
20
+ "dev": "tsc --watch"
21
+ },
22
+ "dependencies": {
23
+ "@modelcontextprotocol/sdk": "^1.13.1",
24
+ "dedent": "^1.5.3",
25
+ "zod": "^3.24.4"
26
+ },
27
+ "devDependencies": {
28
+ "@types/node": "^22.15.21",
29
+ "esbuild": "^0.25.4",
30
+ "typescript": "^5.8.3"
31
+ }
32
+ }