ai-devkit 0.14.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.
Files changed (95) hide show
  1. package/README.md +6 -0
  2. package/dist/cli.js +10 -1
  3. package/dist/cli.js.map +1 -1
  4. package/dist/commands/agent.d.ts.map +1 -1
  5. package/dist/commands/agent.js +43 -17
  6. package/dist/commands/agent.js.map +1 -1
  7. package/dist/commands/install.d.ts +7 -0
  8. package/dist/commands/install.d.ts.map +1 -0
  9. package/dist/commands/install.js +74 -0
  10. package/dist/commands/install.js.map +1 -0
  11. package/dist/commands/phase.js +1 -1
  12. package/dist/commands/phase.js.map +1 -1
  13. package/dist/lib/Config.d.ts +3 -1
  14. package/dist/lib/Config.d.ts.map +1 -1
  15. package/dist/lib/Config.js +39 -6
  16. package/dist/lib/Config.js.map +1 -1
  17. package/dist/lib/SkillManager.d.ts.map +1 -1
  18. package/dist/lib/SkillManager.js +8 -2
  19. package/dist/lib/SkillManager.js.map +1 -1
  20. package/dist/lib/TemplateManager.d.ts.map +1 -1
  21. package/dist/lib/TemplateManager.js +1 -12
  22. package/dist/lib/TemplateManager.js.map +1 -1
  23. package/dist/services/config/config.service.d.ts +6 -0
  24. package/dist/services/config/config.service.d.ts.map +1 -0
  25. package/dist/services/config/config.service.js +55 -0
  26. package/dist/services/config/config.service.js.map +1 -0
  27. package/dist/services/install/install.service.d.ts +19 -0
  28. package/dist/services/install/install.service.d.ts.map +1 -0
  29. package/dist/services/install/install.service.js +125 -0
  30. package/dist/services/install/install.service.js.map +1 -0
  31. package/dist/templates/commands/capture-knowledge.md +7 -5
  32. package/dist/templates/commands/check-implementation.md +7 -4
  33. package/dist/templates/commands/code-review.md +7 -4
  34. package/dist/templates/commands/debug.md +7 -4
  35. package/dist/templates/commands/execute-plan.md +7 -4
  36. package/dist/templates/commands/new-requirement.md +7 -6
  37. package/dist/templates/commands/remember.md +6 -4
  38. package/dist/templates/commands/review-design.md +13 -10
  39. package/dist/templates/commands/review-requirements.md +11 -8
  40. package/dist/templates/commands/simplify-implementation.md +6 -3
  41. package/dist/templates/commands/update-planning.md +6 -3
  42. package/dist/templates/commands/writing-test.md +8 -5
  43. package/dist/templates/templates/commands/capture-knowledge.md +7 -5
  44. package/dist/templates/templates/commands/check-implementation.md +7 -4
  45. package/dist/templates/templates/commands/code-review.md +7 -4
  46. package/dist/templates/templates/commands/debug.md +7 -4
  47. package/dist/templates/templates/commands/execute-plan.md +7 -4
  48. package/dist/templates/templates/commands/new-requirement.md +7 -6
  49. package/dist/templates/templates/commands/remember.md +6 -4
  50. package/dist/templates/templates/commands/review-design.md +13 -10
  51. package/dist/templates/templates/commands/review-requirements.md +11 -8
  52. package/dist/templates/templates/commands/simplify-implementation.md +6 -3
  53. package/dist/templates/templates/commands/update-planning.md +6 -3
  54. package/dist/templates/templates/commands/writing-test.md +8 -5
  55. package/dist/types.d.ts +6 -1
  56. package/dist/types.d.ts.map +1 -1
  57. package/dist/types.js.map +1 -1
  58. package/dist/util/config.d.ts +8 -0
  59. package/dist/util/config.d.ts.map +1 -0
  60. package/dist/util/config.js +100 -0
  61. package/dist/util/config.js.map +1 -0
  62. package/dist/util/process.d.ts +1 -1
  63. package/dist/util/process.d.ts.map +1 -1
  64. package/package.json +5 -3
  65. package/templates/commands/capture-knowledge.md +7 -5
  66. package/templates/commands/check-implementation.md +7 -4
  67. package/templates/commands/code-review.md +7 -4
  68. package/templates/commands/debug.md +7 -4
  69. package/templates/commands/execute-plan.md +7 -4
  70. package/templates/commands/new-requirement.md +7 -6
  71. package/templates/commands/remember.md +6 -4
  72. package/templates/commands/review-design.md +13 -10
  73. package/templates/commands/review-requirements.md +11 -8
  74. package/templates/commands/simplify-implementation.md +6 -3
  75. package/templates/commands/update-planning.md +6 -3
  76. package/templates/commands/writing-test.md +8 -5
  77. package/dist/lib/AgentManager.d.ts +0 -104
  78. package/dist/lib/AgentManager.d.ts.map +0 -1
  79. package/dist/lib/AgentManager.js +0 -185
  80. package/dist/lib/AgentManager.js.map +0 -1
  81. package/dist/lib/TerminalFocusManager.d.ts +0 -22
  82. package/dist/lib/TerminalFocusManager.d.ts.map +0 -1
  83. package/dist/lib/TerminalFocusManager.js +0 -195
  84. package/dist/lib/TerminalFocusManager.js.map +0 -1
  85. package/dist/lib/adapters/AgentAdapter.d.ts +0 -92
  86. package/dist/lib/adapters/AgentAdapter.d.ts.map +0 -1
  87. package/dist/lib/adapters/AgentAdapter.js +0 -29
  88. package/dist/lib/adapters/AgentAdapter.js.map +0 -1
  89. package/dist/lib/adapters/ClaudeCodeAdapter.d.ts +0 -66
  90. package/dist/lib/adapters/ClaudeCodeAdapter.d.ts.map +0 -1
  91. package/dist/lib/adapters/ClaudeCodeAdapter.js +0 -306
  92. package/dist/lib/adapters/ClaudeCodeAdapter.js.map +0 -1
  93. package/dist/templates/env/base.md +0 -101
  94. package/dist/templates/templates/env/base.md +0 -101
  95. package/templates/env/base.md +0 -101
@@ -2,9 +2,11 @@
2
2
  description: Store reusable guidance in the knowledge memory service.
3
3
  ---
4
4
 
5
- When I say "remember this" or want to save a reusable rule, help me store it in the knowledge memory service.
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. **Validate Quality** — Ensure it is specific and reusable (not generic advice). Avoid storing secrets or sensitive data.
9
- 3. **Store** — Call `memory.storeKnowledge` with title, content, tags, scope. If MCP tools are unavailable, use `npx ai-devkit@latest memory store` instead.
10
- 4. **Confirm** — Summarize what was saved and offer to store more knowledge if needed.
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). Summarize:
5
+ Review the design documentation in `docs/ai/design/feature-{name}.md` (and the project-level README if relevant).
6
6
 
7
- - Architecture overview (ensure mermaid diagram is present and accurate)
8
- - Key components and their responsibilities
9
- - Technology choices and rationale
10
- - Data models and relationships
11
- - API/interface contracts (inputs, outputs, auth)
12
- - Major design decisions and trade-offs
13
- - Non-functional requirements that must be preserved
14
-
15
- Highlight any inconsistencies, missing sections, or diagrams that need updates.
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. Summarize:
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
- - Core problem statement and affected users
8
- - Goals, non-goals, and success criteria
9
- - Primary user stories & critical flows
10
- - Constraints, assumptions, open questions
11
- - Any missing sections or deviations from the template
12
-
13
- Identify gaps or contradictions and suggest clarifications.
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. **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).
9
- 3. **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.
10
- 4. **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.
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. **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.
9
- 3. **Produce Updated Task List** — Generate an updated checklist grouped by: Done, In Progress, Blocked, Newly Discovered Work with short notes per task.
10
- 4. **Next Steps & Summary** — Suggest the next 2-3 actionable tasks and highlight risky areas. Prepare a summary paragraph for the planning doc covering: current state, major risks/blockers, upcoming focus, and any scope/timeline changes.
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. **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.
9
- 3. **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.
10
- 4. **Integration Tests** — Identify critical cross-component flows. Define setup/teardown steps and test cases for interaction boundaries, data contracts, and failure modes.
11
- 5. **Coverage Strategy** — Recommend coverage tooling commands. Call out files/functions still needing coverage and suggest additional tests if <100%.
12
- 6. **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.
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"}
@@ -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,GAA8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,CAAC;YAAE,OAAO,OAAO,CAAC,CAAC,CAAC,CAAC;QAC5C,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC;YAAE,OAAO,OAAO,CAAC;QAEvC,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ;AA5KD,oCA4KC"}
@@ -1,22 +0,0 @@
1
- export interface TerminalLocation {
2
- type: 'tmux' | 'iterm2' | 'terminal-app' | 'unknown';
3
- identifier: string;
4
- tty: string;
5
- }
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"}
@@ -1,195 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TerminalFocusManager = void 0;
4
- const child_process_1 = require("child_process");
5
- const util_1 = require("util");
6
- const process_1 = require("../util/process");
7
- const execAsync = (0, util_1.promisify)(child_process_1.exec);
8
- class TerminalFocusManager {
9
- /**
10
- * Find the terminal location (emulator info) for a given process ID
11
- */
12
- async findTerminal(pid) {
13
- const ttyShort = (0, process_1.getProcessTty)(pid);
14
- // If no TTY or invalid, we can't find the terminal
15
- if (!ttyShort || ttyShort === '?') {
16
- return null;
17
- }
18
- const fullTty = `/dev/${ttyShort}`;
19
- // 1. Check tmux (most specific if running inside it)
20
- const tmuxLocation = await this.findTmuxPane(fullTty);
21
- if (tmuxLocation)
22
- return tmuxLocation;
23
- // 2. Check iTerm2
24
- const itermLocation = await this.findITerm2Session(fullTty);
25
- if (itermLocation)
26
- return itermLocation;
27
- // 3. Check Terminal.app
28
- const terminalAppLocation = await this.findTerminalAppWindow(fullTty);
29
- if (terminalAppLocation)
30
- return terminalAppLocation;
31
- // 4. Fallback: we know the TTY but not the emulator wrapper
32
- return {
33
- type: 'unknown',
34
- identifier: '',
35
- tty: fullTty
36
- };
37
- }
38
- /**
39
- * Focus the terminal identified by the location
40
- */
41
- async focusTerminal(location) {
42
- try {
43
- switch (location.type) {
44
- case 'tmux':
45
- return await this.focusTmuxPane(location.identifier);
46
- case 'iterm2':
47
- return await this.focusITerm2Session(location.tty);
48
- case 'terminal-app':
49
- return await this.focusTerminalAppWindow(location.tty);
50
- default:
51
- return false;
52
- }
53
- }
54
- catch (error) {
55
- return false;
56
- }
57
- }
58
- async findTmuxPane(tty) {
59
- try {
60
- // List all panes with their TTYs and identifiers
61
- // Format: /dev/ttys001|my-session:1.1
62
- // using | as separator to handle spaces in session names
63
- const { stdout } = await execAsync("tmux list-panes -a -F '#{pane_tty}|#{session_name}:#{window_index}.#{pane_index}'");
64
- const lines = stdout.trim().split('\n');
65
- for (const line of lines) {
66
- if (!line.trim())
67
- continue;
68
- const [paneTty, identifier] = line.split('|');
69
- if (paneTty === tty && identifier) {
70
- return {
71
- type: 'tmux',
72
- identifier,
73
- tty
74
- };
75
- }
76
- }
77
- }
78
- catch (error) {
79
- // tmux might not be installed or running
80
- }
81
- return null;
82
- }
83
- async findITerm2Session(tty) {
84
- try {
85
- // Check if iTerm2 is running first to avoid launching it
86
- const { stdout: isRunning } = await execAsync('pgrep -x iTerm2 || echo "no"');
87
- if (isRunning.trim() === "no")
88
- return null;
89
- const script = `
90
- tell application "iTerm"
91
- repeat with w in windows
92
- repeat with t in tabs of w
93
- repeat with s in sessions of t
94
- if tty of s is "${tty}" then
95
- return "found"
96
- end if
97
- end repeat
98
- end repeat
99
- end repeat
100
- end tell
101
- `;
102
- const { stdout } = await execAsync(`osascript -e '${script}'`);
103
- if (stdout.trim() === "found") {
104
- return {
105
- type: 'iterm2',
106
- identifier: tty,
107
- tty
108
- };
109
- }
110
- }
111
- catch (error) {
112
- // iTerm2 not found or script failed
113
- }
114
- return null;
115
- }
116
- async findTerminalAppWindow(tty) {
117
- try {
118
- // Check if Terminal is running
119
- const { stdout: isRunning } = await execAsync('pgrep -x Terminal || echo "no"');
120
- if (isRunning.trim() === "no")
121
- return null;
122
- const script = `
123
- tell application "Terminal"
124
- repeat with w in windows
125
- repeat with t in tabs of w
126
- if tty of t is "${tty}" then
127
- return "found"
128
- end if
129
- end repeat
130
- end repeat
131
- end tell
132
- `;
133
- const { stdout } = await execAsync(`osascript -e '${script}'`);
134
- if (stdout.trim() === "found") {
135
- return {
136
- type: 'terminal-app',
137
- identifier: tty,
138
- tty
139
- };
140
- }
141
- }
142
- catch (error) {
143
- // Terminal not found or script failed
144
- }
145
- return null;
146
- }
147
- async focusTmuxPane(identifier) {
148
- try {
149
- await execAsync(`tmux switch-client -t ${identifier}`);
150
- return true;
151
- }
152
- catch (error) {
153
- return false;
154
- }
155
- }
156
- async focusITerm2Session(tty) {
157
- const script = `
158
- tell application "iTerm"
159
- activate
160
- repeat with w in windows
161
- repeat with t in tabs of w
162
- repeat with s in sessions of t
163
- if tty of s is "${tty}" then
164
- select s
165
- return "true"
166
- end if
167
- end repeat
168
- end repeat
169
- end repeat
170
- end tell
171
- `;
172
- const { stdout } = await execAsync(`osascript -e '${script}'`);
173
- return stdout.trim() === "true";
174
- }
175
- async focusTerminalAppWindow(tty) {
176
- const script = `
177
- tell application "Terminal"
178
- activate
179
- repeat with w in windows
180
- repeat with t in tabs of w
181
- if tty of t is "${tty}" then
182
- set index of w to 1
183
- set selected tab of w to t
184
- return "true"
185
- end if
186
- end repeat
187
- end repeat
188
- end tell
189
- `;
190
- const { stdout } = await execAsync(`osascript -e '${script}'`);
191
- return stdout.trim() === "true";
192
- }
193
- }
194
- exports.TerminalFocusManager = TerminalFocusManager;
195
- //# sourceMappingURL=TerminalFocusManager.js.map