ai-devkit 0.15.0 → 0.16.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/cli.js +3 -1
- package/dist/cli.js.map +1 -1
- package/dist/commands/agent.d.ts.map +1 -1
- package/dist/commands/agent.js +43 -17
- package/dist/commands/agent.js.map +1 -1
- package/dist/lib/Config.d.ts +1 -0
- package/dist/lib/Config.d.ts.map +1 -1
- package/dist/lib/Config.js +14 -2
- package/dist/lib/Config.js.map +1 -1
- package/dist/lib/SkillManager.d.ts.map +1 -1
- package/dist/lib/SkillManager.js +4 -2
- package/dist/lib/SkillManager.js.map +1 -1
- package/dist/lib/TemplateManager.d.ts.map +1 -1
- package/dist/lib/TemplateManager.js +1 -12
- package/dist/lib/TemplateManager.js.map +1 -1
- package/dist/templates/commands/capture-knowledge.md +7 -5
- package/dist/templates/commands/check-implementation.md +7 -4
- package/dist/templates/commands/code-review.md +7 -4
- package/dist/templates/commands/debug.md +7 -4
- package/dist/templates/commands/execute-plan.md +7 -4
- package/dist/templates/commands/new-requirement.md +7 -6
- package/dist/templates/commands/remember.md +6 -4
- package/dist/templates/commands/review-design.md +13 -10
- package/dist/templates/commands/review-requirements.md +11 -8
- package/dist/templates/commands/simplify-implementation.md +6 -3
- package/dist/templates/commands/update-planning.md +6 -3
- package/dist/templates/commands/writing-test.md +8 -5
- package/dist/templates/templates/commands/capture-knowledge.md +7 -5
- package/dist/templates/templates/commands/check-implementation.md +7 -4
- package/dist/templates/templates/commands/code-review.md +7 -4
- package/dist/templates/templates/commands/debug.md +7 -4
- package/dist/templates/templates/commands/execute-plan.md +7 -4
- package/dist/templates/templates/commands/new-requirement.md +7 -6
- package/dist/templates/templates/commands/remember.md +6 -4
- package/dist/templates/templates/commands/review-design.md +13 -10
- package/dist/templates/templates/commands/review-requirements.md +11 -8
- package/dist/templates/templates/commands/simplify-implementation.md +6 -3
- package/dist/templates/templates/commands/update-planning.md +6 -3
- package/dist/templates/templates/commands/writing-test.md +8 -5
- package/dist/util/process.d.ts +1 -1
- package/dist/util/process.d.ts.map +1 -1
- package/package.json +2 -1
- package/templates/commands/capture-knowledge.md +7 -5
- package/templates/commands/check-implementation.md +7 -4
- package/templates/commands/code-review.md +7 -4
- package/templates/commands/debug.md +7 -4
- package/templates/commands/execute-plan.md +7 -4
- package/templates/commands/new-requirement.md +7 -6
- package/templates/commands/remember.md +6 -4
- package/templates/commands/review-design.md +13 -10
- package/templates/commands/review-requirements.md +11 -8
- package/templates/commands/simplify-implementation.md +6 -3
- package/templates/commands/update-planning.md +6 -3
- package/templates/commands/writing-test.md +8 -5
- package/dist/lib/AgentManager.d.ts +0 -104
- package/dist/lib/AgentManager.d.ts.map +0 -1
- package/dist/lib/AgentManager.js +0 -185
- package/dist/lib/AgentManager.js.map +0 -1
- package/dist/lib/TerminalFocusManager.d.ts +0 -22
- package/dist/lib/TerminalFocusManager.d.ts.map +0 -1
- package/dist/lib/TerminalFocusManager.js +0 -195
- package/dist/lib/TerminalFocusManager.js.map +0 -1
- package/dist/lib/adapters/AgentAdapter.d.ts +0 -92
- package/dist/lib/adapters/AgentAdapter.d.ts.map +0 -1
- package/dist/lib/adapters/AgentAdapter.js +0 -29
- package/dist/lib/adapters/AgentAdapter.js.map +0 -1
- package/dist/lib/adapters/ClaudeCodeAdapter.d.ts +0 -66
- package/dist/lib/adapters/ClaudeCodeAdapter.d.ts.map +0 -1
- package/dist/lib/adapters/ClaudeCodeAdapter.js +0 -306
- package/dist/lib/adapters/ClaudeCodeAdapter.js.map +0 -1
- package/dist/templates/env/base.md +0 -101
- package/dist/templates/templates/env/base.md +0 -101
- package/templates/env/base.md +0 -101
|
@@ -5,14 +5,15 @@ description: Scaffold feature documentation from requirements through planning.
|
|
|
5
5
|
Guide me through adding a new feature, from requirements documentation to implementation readiness.
|
|
6
6
|
|
|
7
7
|
1. **Capture Requirement** — If not already provided, ask for: feature name (kebab-case, e.g., `user-authentication`), what problem it solves and who will use it, and key user stories.
|
|
8
|
-
2. **
|
|
8
|
+
2. **Use Memory for Context** — Before asking repetitive clarification questions, search memory for related decisions or conventions via `npx ai-devkit@latest memory search --query "<feature/topic>"` and reuse relevant context.
|
|
9
|
+
3. **Create Feature Documentation Structure** — Copy each template's content (preserving YAML frontmatter and section headings) into feature-specific files:
|
|
9
10
|
- `docs/ai/requirements/README.md` → `docs/ai/requirements/feature-{name}.md`
|
|
10
11
|
- `docs/ai/design/README.md` → `docs/ai/design/feature-{name}.md`
|
|
11
12
|
- `docs/ai/planning/README.md` → `docs/ai/planning/feature-{name}.md`
|
|
12
13
|
- `docs/ai/implementation/README.md` → `docs/ai/implementation/feature-{name}.md`
|
|
13
14
|
- `docs/ai/testing/README.md` → `docs/ai/testing/feature-{name}.md`
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
4. **Requirements Phase** — Fill out `docs/ai/requirements/feature-{name}.md`: problem statement, goals/non-goals, user stories, success criteria, constraints, open questions.
|
|
16
|
+
5. **Design Phase** — Fill out `docs/ai/design/feature-{name}.md`: architecture changes, data models, API/interfaces, components, design decisions, security and performance considerations.
|
|
17
|
+
6. **Planning Phase** — Fill out `docs/ai/planning/feature-{name}.md`: task breakdown with subtasks, dependencies, effort estimates, implementation order, risks.
|
|
18
|
+
7. **Store Reusable Knowledge** — When important conventions or decisions are finalized, store them via `npx ai-devkit@latest memory store --title "<title>" --content "<knowledge>" --tags "<tags>"`.
|
|
19
|
+
8. **Next Command Guidance** — Run `/review-requirements` first, then `/review-design`. If both pass, continue with `/execute-plan`.
|
|
@@ -2,9 +2,11 @@
|
|
|
2
2
|
description: Store reusable guidance in the knowledge memory service.
|
|
3
3
|
---
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Help me store it in the knowledge memory service.
|
|
6
6
|
|
|
7
7
|
1. **Capture Knowledge** — If not already provided, ask for: a short explicit title (5-12 words), detailed content (markdown, examples encouraged), optional tags (keywords like "api", "testing"), and optional scope (`global`, `project:<name>`, `repo:<name>`). If vague, ask follow-ups to make it specific and actionable.
|
|
8
|
-
2. **
|
|
9
|
-
3. **
|
|
10
|
-
4. **
|
|
8
|
+
2. **Search Before Store** — Check for existing similar entries first with `npx ai-devkit@latest memory search --query "<topic>"` to avoid duplicates.
|
|
9
|
+
3. **Validate Quality** — Ensure it is specific and reusable (not generic advice). Avoid storing secrets or sensitive data.
|
|
10
|
+
4. **Store** — Call `memory.storeKnowledge` with title, content, tags, scope. If MCP tools are unavailable, use `npx ai-devkit@latest memory store` instead.
|
|
11
|
+
5. **Confirm** — Summarize what was saved and offer to retrieve related memory entries when helpful.
|
|
12
|
+
6. **Next Command Guidance** — Continue with the current lifecycle phase command (`/execute-plan`, `/check-implementation`, `/writing-test`, etc.) as needed.
|
|
@@ -2,14 +2,17 @@
|
|
|
2
2
|
description: Review feature design for completeness.
|
|
3
3
|
---
|
|
4
4
|
|
|
5
|
-
Review the design documentation in docs/ai/design/feature-{name}.md (and the project-level README if relevant).
|
|
5
|
+
Review the design documentation in `docs/ai/design/feature-{name}.md` (and the project-level README if relevant).
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
-
|
|
10
|
-
-
|
|
11
|
-
-
|
|
12
|
-
-
|
|
13
|
-
-
|
|
14
|
-
|
|
15
|
-
|
|
7
|
+
1. **Use Memory for Context** — Search memory for prior architecture constraints/patterns: `npx ai-devkit@latest memory search --query "<feature design architecture>"`.
|
|
8
|
+
2. Summarize:
|
|
9
|
+
- Architecture overview (ensure mermaid diagram is present and accurate)
|
|
10
|
+
- Key components and their responsibilities
|
|
11
|
+
- Technology choices and rationale
|
|
12
|
+
- Data models and relationships
|
|
13
|
+
- API/interface contracts (inputs, outputs, auth)
|
|
14
|
+
- Major design decisions and trade-offs
|
|
15
|
+
- Non-functional requirements that must be preserved
|
|
16
|
+
3. Highlight inconsistencies, missing sections, or diagrams that need updates.
|
|
17
|
+
4. **Store Reusable Knowledge** — Persist approved design patterns/constraints with `npx ai-devkit@latest memory store ...` when they will help future work.
|
|
18
|
+
5. **Next Command Guidance** — If requirements gaps are found, return to `/review-requirements`; if design is sound, continue to `/execute-plan`.
|
|
@@ -2,12 +2,15 @@
|
|
|
2
2
|
description: Review feature requirements for completeness.
|
|
3
3
|
---
|
|
4
4
|
|
|
5
|
-
Review `docs/ai/requirements/feature-{name}.md` and the project-level template `docs/ai/requirements/README.md` to ensure structure and content alignment.
|
|
5
|
+
Review `docs/ai/requirements/feature-{name}.md` and the project-level template `docs/ai/requirements/README.md` to ensure structure and content alignment.
|
|
6
6
|
|
|
7
|
-
-
|
|
8
|
-
|
|
9
|
-
-
|
|
10
|
-
-
|
|
11
|
-
-
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
1. **Use Memory for Context** — Search memory for related requirements/domain decisions before starting: `npx ai-devkit@latest memory search --query "<feature requirements>"`.
|
|
8
|
+
2. Summarize:
|
|
9
|
+
- Core problem statement and affected users
|
|
10
|
+
- Goals, non-goals, and success criteria
|
|
11
|
+
- Primary user stories & critical flows
|
|
12
|
+
- Constraints, assumptions, open questions
|
|
13
|
+
- Any missing sections or deviations from the template
|
|
14
|
+
3. Identify gaps or contradictions and suggest clarifications.
|
|
15
|
+
4. **Store Reusable Knowledge** — If new reusable requirement conventions are agreed, store them with `npx ai-devkit@latest memory store ...`.
|
|
16
|
+
5. **Next Command Guidance** — If fundamentals are missing, go back to `/new-requirement`; otherwise continue to `/review-design`.
|
|
@@ -5,6 +5,9 @@ description: Simplify existing code to reduce complexity.
|
|
|
5
5
|
Help me simplify an existing implementation while maintaining or improving its functionality.
|
|
6
6
|
|
|
7
7
|
1. **Gather Context** — If not already provided, ask for: target file(s) or component(s) to simplify, current pain points (hard to understand, maintain, or extend?), performance or scalability concerns, constraints (backward compatibility, API stability, deadlines), and relevant design docs or requirements.
|
|
8
|
-
2. **
|
|
9
|
-
3. **
|
|
10
|
-
4. **
|
|
8
|
+
2. **Use Memory for Context** — Search memory for established patterns and prior refactors in this area: `npx ai-devkit@latest memory search --query "<component simplification pattern>"`.
|
|
9
|
+
3. **Analyze Current Complexity** — For each target: identify complexity sources (deep nesting, duplication, unclear abstractions, tight coupling, over-engineering, magic values), assess cognitive load for future maintainers, and identify scalability blockers (single points of failure, sync-where-async-needed, missing caching, inefficient algorithms).
|
|
10
|
+
4. **Propose Simplifications** — Prioritize readability over brevity; apply the 30-second test: can a new team member understand each change quickly? For each issue, suggest concrete improvements (extract, consolidate, flatten, decouple, remove dead code, replace with built-ins). Provide before/after snippets.
|
|
11
|
+
5. **Prioritize & Plan** — Rank by impact vs risk: (1) high impact, low risk — do first, (2) high impact, higher risk — plan carefully, (3) low impact, low risk — quick wins if time permits, (4) low impact, high risk — skip or defer. For each change specify risk level, testing requirements, and effort. Produce a prioritized action plan with recommended execution order.
|
|
12
|
+
6. **Store Reusable Knowledge** — Save reusable simplification patterns and trade-offs via `npx ai-devkit@latest memory store ...`.
|
|
13
|
+
7. **Next Command Guidance** — After implementation, run `/check-implementation` and `/writing-test`.
|
|
@@ -5,6 +5,9 @@ description: Update planning docs to reflect implementation progress.
|
|
|
5
5
|
Help me reconcile current implementation progress with the planning documentation.
|
|
6
6
|
|
|
7
7
|
1. **Gather Context** — If not already provided, ask for: feature/branch name and brief status, tasks completed since last update, new tasks discovered, current blockers or risks, and planning doc path (default `docs/ai/planning/feature-{name}.md`).
|
|
8
|
-
2. **
|
|
9
|
-
3. **
|
|
10
|
-
4. **
|
|
8
|
+
2. **Use Memory for Context** — Search memory for prior decisions that affect priorities/scope: `npx ai-devkit@latest memory search --query "<feature planning updates>"`.
|
|
9
|
+
3. **Review & Reconcile** — Summarize existing milestones, task breakdowns, and dependencies from the planning doc. For each planned task: mark status (done / in progress / blocked / not started), note scope changes, record blockers, identify skipped or added tasks.
|
|
10
|
+
4. **Produce Updated Task List** — Generate an updated checklist grouped by: Done, In Progress, Blocked, Newly Discovered Work — with short notes per task.
|
|
11
|
+
5. **Store Reusable Knowledge** — If new planning conventions or risk-handling rules emerge, store them with `npx ai-devkit@latest memory store ...`.
|
|
12
|
+
6. **Next Steps & Summary** — Suggest the next 2-3 actionable tasks and prepare a summary paragraph for the planning doc.
|
|
13
|
+
7. **Next Command Guidance** — Return to `/execute-plan` for remaining work. When all implementation tasks are complete, run `/check-implementation`.
|
|
@@ -5,8 +5,11 @@ description: Add tests for a new feature.
|
|
|
5
5
|
Review `docs/ai/testing/feature-{name}.md` and ensure it mirrors the base template before writing tests.
|
|
6
6
|
|
|
7
7
|
1. **Gather Context** — If not already provided, ask for: feature name/branch, summary of changes (link to design & requirements docs), target environment, existing test suites, and any flaky/slow tests to avoid.
|
|
8
|
-
2. **
|
|
9
|
-
3. **
|
|
10
|
-
4. **
|
|
11
|
-
5. **
|
|
12
|
-
6. **
|
|
8
|
+
2. **Use Memory for Context** — Search memory for existing testing patterns and prior edge cases: `npx ai-devkit@latest memory search --query "<feature testing strategy>"`.
|
|
9
|
+
3. **Analyze Testing Template** — Identify required sections from `docs/ai/testing/feature-{name}.md`. Confirm success criteria and edge cases from requirements & design docs. Note available mocks/stubs/fixtures.
|
|
10
|
+
4. **Unit Tests (aim for 100% coverage)** — For each module/function: list behavior scenarios (happy path, edge cases, error handling), generate test cases with assertions using existing utilities/mocks, and highlight missing branches preventing full coverage.
|
|
11
|
+
5. **Integration Tests** — Identify critical cross-component flows. Define setup/teardown steps and test cases for interaction boundaries, data contracts, and failure modes.
|
|
12
|
+
6. **Coverage Strategy** — Recommend coverage tooling commands. Call out files/functions still needing coverage and suggest additional tests if <100%.
|
|
13
|
+
7. **Store Reusable Knowledge** — Save reusable testing patterns or tricky fixtures with `npx ai-devkit@latest memory store ...`.
|
|
14
|
+
8. **Update Documentation** — Summarize tests added or still missing. Update `docs/ai/testing/feature-{name}.md` with links to test files and results. Flag deferred tests as follow-up tasks.
|
|
15
|
+
9. **Next Command Guidance** — If tests expose design issues, return to `/review-design`; otherwise continue to `/code-review`.
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Agent Manager
|
|
3
|
-
*
|
|
4
|
-
* Orchestrates agent detection across multiple adapter types.
|
|
5
|
-
* Manages adapter registration and aggregates results from all adapters.
|
|
6
|
-
*/
|
|
7
|
-
import type { AgentAdapter, AgentInfo } from './adapters/AgentAdapter';
|
|
8
|
-
/**
|
|
9
|
-
* Agent Manager Class
|
|
10
|
-
*
|
|
11
|
-
* Central manager for detecting AI agents across different types.
|
|
12
|
-
* Supports multiple adapters (Claude Code, Gemini CLI, etc.)
|
|
13
|
-
*
|
|
14
|
-
* @example
|
|
15
|
-
* ```typescript
|
|
16
|
-
* const manager = new AgentManager();
|
|
17
|
-
* manager.registerAdapter(new ClaudeCodeAdapter());
|
|
18
|
-
*
|
|
19
|
-
* const agents = await manager.listAgents();
|
|
20
|
-
* console.log(`Found ${agents.length} agents`);
|
|
21
|
-
* ```
|
|
22
|
-
*/
|
|
23
|
-
export declare class AgentManager {
|
|
24
|
-
private adapters;
|
|
25
|
-
/**
|
|
26
|
-
* Register an adapter for a specific agent type
|
|
27
|
-
*
|
|
28
|
-
* @param adapter Agent adapter to register
|
|
29
|
-
* @throws Error if an adapter for this type is already registered
|
|
30
|
-
*
|
|
31
|
-
* @example
|
|
32
|
-
* ```typescript
|
|
33
|
-
* manager.registerAdapter(new ClaudeCodeAdapter());
|
|
34
|
-
* ```
|
|
35
|
-
*/
|
|
36
|
-
registerAdapter(adapter: AgentAdapter): void;
|
|
37
|
-
/**
|
|
38
|
-
* Unregister an adapter by type
|
|
39
|
-
*
|
|
40
|
-
* @param type Agent type to unregister
|
|
41
|
-
* @returns True if adapter was removed, false if not found
|
|
42
|
-
*/
|
|
43
|
-
unregisterAdapter(type: string): boolean;
|
|
44
|
-
/**
|
|
45
|
-
* Get all registered adapters
|
|
46
|
-
*
|
|
47
|
-
* @returns Array of registered adapters
|
|
48
|
-
*/
|
|
49
|
-
getAdapters(): AgentAdapter[];
|
|
50
|
-
/**
|
|
51
|
-
* Check if an adapter is registered for a specific type
|
|
52
|
-
*
|
|
53
|
-
* @param type Agent type to check
|
|
54
|
-
* @returns True if adapter is registered
|
|
55
|
-
*/
|
|
56
|
-
hasAdapter(type: string): boolean;
|
|
57
|
-
/**
|
|
58
|
-
* List all running AI agents detected by registered adapters
|
|
59
|
-
*
|
|
60
|
-
* Queries all registered adapters and aggregates results.
|
|
61
|
-
* Handles errors gracefully - if one adapter fails, others still run.
|
|
62
|
-
*
|
|
63
|
-
* @returns Array of detected agents from all adapters
|
|
64
|
-
*
|
|
65
|
-
* @example
|
|
66
|
-
* ```typescript
|
|
67
|
-
* const agents = await manager.listAgents();
|
|
68
|
-
*
|
|
69
|
-
* agents.forEach(agent => {
|
|
70
|
-
* console.log(`${agent.name}: ${agent.status}`);
|
|
71
|
-
* });
|
|
72
|
-
* ```
|
|
73
|
-
*/
|
|
74
|
-
listAgents(): Promise<AgentInfo[]>;
|
|
75
|
-
/**
|
|
76
|
-
* Sort agents by status priority
|
|
77
|
-
*
|
|
78
|
-
* Priority order: waiting > running > idle > unknown
|
|
79
|
-
* This ensures agents that need attention appear first.
|
|
80
|
-
*
|
|
81
|
-
* @param agents Array of agents to sort
|
|
82
|
-
* @returns Sorted array of agents
|
|
83
|
-
*/
|
|
84
|
-
private sortAgentsByStatus;
|
|
85
|
-
/**
|
|
86
|
-
* Get count of registered adapters
|
|
87
|
-
*
|
|
88
|
-
* @returns Number of registered adapters
|
|
89
|
-
*/
|
|
90
|
-
getAdapterCount(): number;
|
|
91
|
-
/**
|
|
92
|
-
* Clear all registered adapters
|
|
93
|
-
*/
|
|
94
|
-
clear(): void;
|
|
95
|
-
/**
|
|
96
|
-
* Resolve an agent by name (exact or partial match)
|
|
97
|
-
*
|
|
98
|
-
* @param input Name to search for
|
|
99
|
-
* @param agents List of agents to search within
|
|
100
|
-
* @returns Matched agent (unique), array of agents (ambiguous), or null (none)
|
|
101
|
-
*/
|
|
102
|
-
resolveAgent(input: string, agents: AgentInfo[]): AgentInfo | AgentInfo[] | null;
|
|
103
|
-
}
|
|
104
|
-
//# sourceMappingURL=AgentManager.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AgentManager.d.ts","sourceRoot":"","sources":["../../src/lib/AgentManager.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAGvE;;;;;;;;;;;;;;GAcG;AACH,qBAAa,YAAY;IACrB,OAAO,CAAC,QAAQ,CAAwC;IAExD;;;;;;;;;;OAUG;IACH,eAAe,CAAC,OAAO,EAAE,YAAY,GAAG,IAAI;IAU5C;;;;;OAKG;IACH,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAIxC;;;;OAIG;IACH,WAAW,IAAI,YAAY,EAAE;IAI7B;;;;;OAKG;IACH,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAIjC;;;;;;;;;;;;;;;;OAgBG;IACG,UAAU,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC;IAsCxC;;;;;;;;OAQG;IACH,OAAO,CAAC,kBAAkB;IAe1B;;;;OAIG;IACH,eAAe,IAAI,MAAM;IAIzB;;OAEG;IACH,KAAK,IAAI,IAAI;IAIb;;;;;;OAMG;IACH,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG,SAAS,GAAG,SAAS,EAAE,GAAG,IAAI;CAiBnF"}
|
package/dist/lib/AgentManager.js
DELETED
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Agent Manager
|
|
4
|
-
*
|
|
5
|
-
* Orchestrates agent detection across multiple adapter types.
|
|
6
|
-
* Manages adapter registration and aggregates results from all adapters.
|
|
7
|
-
*/
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.AgentManager = void 0;
|
|
10
|
-
const AgentAdapter_1 = require("./adapters/AgentAdapter");
|
|
11
|
-
/**
|
|
12
|
-
* Agent Manager Class
|
|
13
|
-
*
|
|
14
|
-
* Central manager for detecting AI agents across different types.
|
|
15
|
-
* Supports multiple adapters (Claude Code, Gemini CLI, etc.)
|
|
16
|
-
*
|
|
17
|
-
* @example
|
|
18
|
-
* ```typescript
|
|
19
|
-
* const manager = new AgentManager();
|
|
20
|
-
* manager.registerAdapter(new ClaudeCodeAdapter());
|
|
21
|
-
*
|
|
22
|
-
* const agents = await manager.listAgents();
|
|
23
|
-
* console.log(`Found ${agents.length} agents`);
|
|
24
|
-
* ```
|
|
25
|
-
*/
|
|
26
|
-
class AgentManager {
|
|
27
|
-
constructor() {
|
|
28
|
-
this.adapters = new Map();
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Register an adapter for a specific agent type
|
|
32
|
-
*
|
|
33
|
-
* @param adapter Agent adapter to register
|
|
34
|
-
* @throws Error if an adapter for this type is already registered
|
|
35
|
-
*
|
|
36
|
-
* @example
|
|
37
|
-
* ```typescript
|
|
38
|
-
* manager.registerAdapter(new ClaudeCodeAdapter());
|
|
39
|
-
* ```
|
|
40
|
-
*/
|
|
41
|
-
registerAdapter(adapter) {
|
|
42
|
-
const adapterKey = adapter.type;
|
|
43
|
-
if (this.adapters.has(adapterKey)) {
|
|
44
|
-
throw new Error(`Adapter for type "${adapterKey}" is already registered`);
|
|
45
|
-
}
|
|
46
|
-
this.adapters.set(adapterKey, adapter);
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Unregister an adapter by type
|
|
50
|
-
*
|
|
51
|
-
* @param type Agent type to unregister
|
|
52
|
-
* @returns True if adapter was removed, false if not found
|
|
53
|
-
*/
|
|
54
|
-
unregisterAdapter(type) {
|
|
55
|
-
return this.adapters.delete(type);
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Get all registered adapters
|
|
59
|
-
*
|
|
60
|
-
* @returns Array of registered adapters
|
|
61
|
-
*/
|
|
62
|
-
getAdapters() {
|
|
63
|
-
return Array.from(this.adapters.values());
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Check if an adapter is registered for a specific type
|
|
67
|
-
*
|
|
68
|
-
* @param type Agent type to check
|
|
69
|
-
* @returns True if adapter is registered
|
|
70
|
-
*/
|
|
71
|
-
hasAdapter(type) {
|
|
72
|
-
return this.adapters.has(type);
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* List all running AI agents detected by registered adapters
|
|
76
|
-
*
|
|
77
|
-
* Queries all registered adapters and aggregates results.
|
|
78
|
-
* Handles errors gracefully - if one adapter fails, others still run.
|
|
79
|
-
*
|
|
80
|
-
* @returns Array of detected agents from all adapters
|
|
81
|
-
*
|
|
82
|
-
* @example
|
|
83
|
-
* ```typescript
|
|
84
|
-
* const agents = await manager.listAgents();
|
|
85
|
-
*
|
|
86
|
-
* agents.forEach(agent => {
|
|
87
|
-
* console.log(`${agent.name}: ${agent.status}`);
|
|
88
|
-
* });
|
|
89
|
-
* ```
|
|
90
|
-
*/
|
|
91
|
-
async listAgents() {
|
|
92
|
-
const allAgents = [];
|
|
93
|
-
const errors = [];
|
|
94
|
-
// Query all adapters in parallel
|
|
95
|
-
const adapterPromises = Array.from(this.adapters.values()).map(async (adapter) => {
|
|
96
|
-
try {
|
|
97
|
-
const agents = await adapter.detectAgents();
|
|
98
|
-
return { type: adapter.type, agents, error: null };
|
|
99
|
-
}
|
|
100
|
-
catch (error) {
|
|
101
|
-
// Capture error but don't throw - allow other adapters to continue
|
|
102
|
-
const err = error instanceof Error ? error : new Error(String(error));
|
|
103
|
-
errors.push({ type: adapter.type, error: err });
|
|
104
|
-
return { type: adapter.type, agents: [], error: err };
|
|
105
|
-
}
|
|
106
|
-
});
|
|
107
|
-
const results = await Promise.all(adapterPromises);
|
|
108
|
-
// Aggregate all successful results
|
|
109
|
-
for (const result of results) {
|
|
110
|
-
if (result.error === null) {
|
|
111
|
-
allAgents.push(...result.agents);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
// Log errors if any (but don't throw - partial results are useful)
|
|
115
|
-
if (errors.length > 0) {
|
|
116
|
-
console.error(`Warning: ${errors.length} adapter(s) failed:`);
|
|
117
|
-
errors.forEach(({ type, error }) => {
|
|
118
|
-
console.error(` - ${type}: ${error.message}`);
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
// Sort by status priority (waiting first, then running, then idle)
|
|
122
|
-
return this.sortAgentsByStatus(allAgents);
|
|
123
|
-
}
|
|
124
|
-
/**
|
|
125
|
-
* Sort agents by status priority
|
|
126
|
-
*
|
|
127
|
-
* Priority order: waiting > running > idle > unknown
|
|
128
|
-
* This ensures agents that need attention appear first.
|
|
129
|
-
*
|
|
130
|
-
* @param agents Array of agents to sort
|
|
131
|
-
* @returns Sorted array of agents
|
|
132
|
-
*/
|
|
133
|
-
sortAgentsByStatus(agents) {
|
|
134
|
-
const statusPriority = {
|
|
135
|
-
[AgentAdapter_1.AgentStatus.WAITING]: 0,
|
|
136
|
-
[AgentAdapter_1.AgentStatus.RUNNING]: 1,
|
|
137
|
-
[AgentAdapter_1.AgentStatus.IDLE]: 2,
|
|
138
|
-
[AgentAdapter_1.AgentStatus.UNKNOWN]: 3,
|
|
139
|
-
};
|
|
140
|
-
return agents.sort((a, b) => {
|
|
141
|
-
const priorityA = statusPriority[a.status] ?? 999;
|
|
142
|
-
const priorityB = statusPriority[b.status] ?? 999;
|
|
143
|
-
return priorityA - priorityB;
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
/**
|
|
147
|
-
* Get count of registered adapters
|
|
148
|
-
*
|
|
149
|
-
* @returns Number of registered adapters
|
|
150
|
-
*/
|
|
151
|
-
getAdapterCount() {
|
|
152
|
-
return this.adapters.size;
|
|
153
|
-
}
|
|
154
|
-
/**
|
|
155
|
-
* Clear all registered adapters
|
|
156
|
-
*/
|
|
157
|
-
clear() {
|
|
158
|
-
this.adapters.clear();
|
|
159
|
-
}
|
|
160
|
-
/**
|
|
161
|
-
* Resolve an agent by name (exact or partial match)
|
|
162
|
-
*
|
|
163
|
-
* @param input Name to search for
|
|
164
|
-
* @param agents List of agents to search within
|
|
165
|
-
* @returns Matched agent (unique), array of agents (ambiguous), or null (none)
|
|
166
|
-
*/
|
|
167
|
-
resolveAgent(input, agents) {
|
|
168
|
-
if (!input || agents.length === 0)
|
|
169
|
-
return null;
|
|
170
|
-
const lowerInput = input.toLowerCase();
|
|
171
|
-
// 1. Exact match (case-insensitive)
|
|
172
|
-
const exactMatch = agents.find(a => a.name.toLowerCase() === lowerInput);
|
|
173
|
-
if (exactMatch)
|
|
174
|
-
return exactMatch;
|
|
175
|
-
// 2. Partial match (prefix or contains)
|
|
176
|
-
const matches = agents.filter(a => a.name.toLowerCase().includes(lowerInput));
|
|
177
|
-
if (matches.length === 1)
|
|
178
|
-
return matches[0];
|
|
179
|
-
if (matches.length > 1)
|
|
180
|
-
return matches;
|
|
181
|
-
return null;
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
exports.AgentManager = AgentManager;
|
|
185
|
-
//# sourceMappingURL=AgentManager.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AgentManager.js","sourceRoot":"","sources":["../../src/lib/AgentManager.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAGH,0DAAsD;AAEtD;;;;;;;;;;;;;;GAcG;AACH,MAAa,YAAY;IAAzB;QACY,aAAQ,GAA8B,IAAI,GAAG,EAAE,CAAC;IA2K5D,CAAC;IAzKG;;;;;;;;;;OAUG;IACH,eAAe,CAAC,OAAqB;QACjC,MAAM,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;QAEhC,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,CAAC;YAChC,MAAM,IAAI,KAAK,CAAC,qBAAqB,UAAU,yBAAyB,CAAC,CAAC;QAC9E,CAAC;QAED,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,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-
}
|
|
6
|
-
export declare class TerminalFocusManager {
|
|
7
|
-
/**
|
|
8
|
-
* Find the terminal location (emulator info) for a given process ID
|
|
9
|
-
*/
|
|
10
|
-
findTerminal(pid: number): Promise<TerminalLocation | null>;
|
|
11
|
-
/**
|
|
12
|
-
* Focus the terminal identified by the location
|
|
13
|
-
*/
|
|
14
|
-
focusTerminal(location: TerminalLocation): Promise<boolean>;
|
|
15
|
-
private findTmuxPane;
|
|
16
|
-
private findITerm2Session;
|
|
17
|
-
private findTerminalAppWindow;
|
|
18
|
-
private focusTmuxPane;
|
|
19
|
-
private focusITerm2Session;
|
|
20
|
-
private focusTerminalAppWindow;
|
|
21
|
-
}
|
|
22
|
-
//# sourceMappingURL=TerminalFocusManager.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TerminalFocusManager.d.ts","sourceRoot":"","sources":["../../src/lib/TerminalFocusManager.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,gBAAgB;IAC7B,IAAI,EAAE,MAAM,GAAG,QAAQ,GAAG,cAAc,GAAG,SAAS,CAAC;IACrD,UAAU,EAAE,MAAM,CAAC;IACnB,GAAG,EAAE,MAAM,CAAC;CACf;AAED,qBAAa,oBAAoB;IAC7B;;OAEG;IACG,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC;IA8BjE;;OAEG;IACG,aAAa,CAAC,QAAQ,EAAE,gBAAgB,GAAG,OAAO,CAAC,OAAO,CAAC;YAiBnD,YAAY;YAyBZ,iBAAiB;YAkCjB,qBAAqB;YAgCrB,aAAa;YASb,kBAAkB;YAoBlB,sBAAsB;CAkBvC"}
|