@ai-devkit/agent-manager 0.3.0 → 0.5.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 (50) hide show
  1. package/dist/adapters/AgentAdapter.d.ts +2 -0
  2. package/dist/adapters/AgentAdapter.d.ts.map +1 -1
  3. package/dist/adapters/ClaudeCodeAdapter.d.ts +49 -38
  4. package/dist/adapters/ClaudeCodeAdapter.d.ts.map +1 -1
  5. package/dist/adapters/ClaudeCodeAdapter.js +286 -293
  6. package/dist/adapters/ClaudeCodeAdapter.js.map +1 -1
  7. package/dist/adapters/CodexAdapter.d.ts +32 -30
  8. package/dist/adapters/CodexAdapter.d.ts.map +1 -1
  9. package/dist/adapters/CodexAdapter.js +148 -284
  10. package/dist/adapters/CodexAdapter.js.map +1 -1
  11. package/dist/index.d.ts +1 -3
  12. package/dist/index.d.ts.map +1 -1
  13. package/dist/index.js +1 -10
  14. package/dist/index.js.map +1 -1
  15. package/dist/utils/index.d.ts +6 -3
  16. package/dist/utils/index.d.ts.map +1 -1
  17. package/dist/utils/index.js +12 -11
  18. package/dist/utils/index.js.map +1 -1
  19. package/dist/utils/matching.d.ts +39 -0
  20. package/dist/utils/matching.d.ts.map +1 -0
  21. package/dist/utils/matching.js +103 -0
  22. package/dist/utils/matching.js.map +1 -0
  23. package/dist/utils/process.d.ts +25 -40
  24. package/dist/utils/process.d.ts.map +1 -1
  25. package/dist/utils/process.js +151 -105
  26. package/dist/utils/process.js.map +1 -1
  27. package/dist/utils/session.d.ts +30 -0
  28. package/dist/utils/session.d.ts.map +1 -0
  29. package/dist/utils/session.js +101 -0
  30. package/dist/utils/session.js.map +1 -0
  31. package/package.json +2 -2
  32. package/src/__tests__/AgentManager.test.ts +0 -25
  33. package/src/__tests__/adapters/ClaudeCodeAdapter.test.ts +921 -205
  34. package/src/__tests__/adapters/CodexAdapter.test.ts +468 -269
  35. package/src/__tests__/utils/matching.test.ts +191 -0
  36. package/src/__tests__/utils/process.test.ts +202 -0
  37. package/src/__tests__/utils/session.test.ts +117 -0
  38. package/src/adapters/AgentAdapter.ts +3 -0
  39. package/src/adapters/ClaudeCodeAdapter.ts +341 -418
  40. package/src/adapters/CodexAdapter.ts +155 -420
  41. package/src/index.ts +1 -3
  42. package/src/utils/index.ts +6 -3
  43. package/src/utils/matching.ts +92 -0
  44. package/src/utils/process.ts +133 -119
  45. package/src/utils/session.ts +92 -0
  46. package/dist/utils/file.d.ts +0 -52
  47. package/dist/utils/file.d.ts.map +0 -1
  48. package/dist/utils/file.js +0 -135
  49. package/dist/utils/file.js.map +0 -1
  50. package/src/utils/file.ts +0 -100
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Session File Utilities
3
+ *
4
+ * Shell command wrappers for discovering session files and their birth times.
5
+ * Uses `stat` to get exact epoch-second birth timestamps without reading file contents.
6
+ */
7
+ /**
8
+ * Represents a session file with its birth time metadata.
9
+ */
10
+ export interface SessionFile {
11
+ /** Session identifier (filename without .jsonl extension) */
12
+ sessionId: string;
13
+ /** Full path to the session file */
14
+ filePath: string;
15
+ /** Parent directory of the session file */
16
+ projectDir: string;
17
+ /** File creation time in milliseconds since epoch */
18
+ birthtimeMs: number;
19
+ /** CWD this session maps to — set by the adapter after calling batchGetSessionFileBirthtimes() */
20
+ resolvedCwd: string;
21
+ }
22
+ /**
23
+ * Get birth times for .jsonl session files across multiple directories in a single shell call.
24
+ *
25
+ * Combines all directory globs into one `stat` command to avoid per-directory exec overhead.
26
+ * Returns empty array if no directories have .jsonl files or command fails.
27
+ * resolvedCwd is left empty — the adapter must set it.
28
+ */
29
+ export declare function batchGetSessionFileBirthtimes(dirs: string[]): SessionFile[];
30
+ //# sourceMappingURL=session.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../src/utils/session.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH;;GAEG;AACH,MAAM,WAAW,WAAW;IACxB,6DAA6D;IAC7D,SAAS,EAAE,MAAM,CAAC;IAElB,oCAAoC;IACpC,QAAQ,EAAE,MAAM,CAAC;IAEjB,2CAA2C;IAC3C,UAAU,EAAE,MAAM,CAAC;IAEnB,qDAAqD;IACrD,WAAW,EAAE,MAAM,CAAC;IAEpB,kGAAkG;IAClG,WAAW,EAAE,MAAM,CAAC;CACvB;AAED;;;;;;GAMG;AACH,wBAAgB,6BAA6B,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,WAAW,EAAE,CAiB3E"}
@@ -0,0 +1,101 @@
1
+ "use strict";
2
+ /**
3
+ * Session File Utilities
4
+ *
5
+ * Shell command wrappers for discovering session files and their birth times.
6
+ * Uses `stat` to get exact epoch-second birth timestamps without reading file contents.
7
+ */
8
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
9
+ if (k2 === undefined) k2 = k;
10
+ var desc = Object.getOwnPropertyDescriptor(m, k);
11
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
12
+ desc = { enumerable: true, get: function() { return m[k]; } };
13
+ }
14
+ Object.defineProperty(o, k2, desc);
15
+ }) : (function(o, m, k, k2) {
16
+ if (k2 === undefined) k2 = k;
17
+ o[k2] = m[k];
18
+ }));
19
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
20
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
21
+ }) : function(o, v) {
22
+ o["default"] = v;
23
+ });
24
+ var __importStar = (this && this.__importStar) || (function () {
25
+ var ownKeys = function(o) {
26
+ ownKeys = Object.getOwnPropertyNames || function (o) {
27
+ var ar = [];
28
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
29
+ return ar;
30
+ };
31
+ return ownKeys(o);
32
+ };
33
+ return function (mod) {
34
+ if (mod && mod.__esModule) return mod;
35
+ var result = {};
36
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
37
+ __setModuleDefault(result, mod);
38
+ return result;
39
+ };
40
+ })();
41
+ Object.defineProperty(exports, "__esModule", { value: true });
42
+ exports.batchGetSessionFileBirthtimes = batchGetSessionFileBirthtimes;
43
+ const path = __importStar(require("path"));
44
+ const child_process_1 = require("child_process");
45
+ /**
46
+ * Get birth times for .jsonl session files across multiple directories in a single shell call.
47
+ *
48
+ * Combines all directory globs into one `stat` command to avoid per-directory exec overhead.
49
+ * Returns empty array if no directories have .jsonl files or command fails.
50
+ * resolvedCwd is left empty — the adapter must set it.
51
+ */
52
+ function batchGetSessionFileBirthtimes(dirs) {
53
+ if (dirs.length === 0)
54
+ return [];
55
+ try {
56
+ const isMacOS = process.platform === 'darwin';
57
+ const globs = dirs.map((d) => `"${d}"/*.jsonl`).join(' ');
58
+ // || true prevents non-zero exit when some globs have no .jsonl matches
59
+ const command = isMacOS
60
+ ? `stat -f '%B %N' ${globs} 2>/dev/null || true`
61
+ : `stat --format='%W %n' ${globs} 2>/dev/null || true`;
62
+ const output = (0, child_process_1.execSync)(command, { encoding: 'utf-8' });
63
+ return parseStatOutput(output);
64
+ }
65
+ catch {
66
+ return [];
67
+ }
68
+ }
69
+ /**
70
+ * Parse stat output lines into SessionFile entries.
71
+ */
72
+ function parseStatOutput(output) {
73
+ const results = [];
74
+ for (const rawLine of output.trim().split('\n')) {
75
+ const line = rawLine.trim();
76
+ if (!line)
77
+ continue;
78
+ // Format: "<epoch_seconds> <filepath>"
79
+ const spaceIdx = line.indexOf(' ');
80
+ if (spaceIdx === -1)
81
+ continue;
82
+ const epochStr = line.slice(0, spaceIdx);
83
+ const filePath = line.slice(spaceIdx + 1).trim();
84
+ const epochSeconds = parseInt(epochStr, 10);
85
+ if (!Number.isFinite(epochSeconds) || epochSeconds <= 0)
86
+ continue;
87
+ const fileName = path.basename(filePath);
88
+ if (!fileName.endsWith('.jsonl'))
89
+ continue;
90
+ const sessionId = fileName.replace(/\.jsonl$/, '');
91
+ results.push({
92
+ sessionId,
93
+ filePath,
94
+ projectDir: path.dirname(filePath),
95
+ birthtimeMs: epochSeconds * 1000,
96
+ resolvedCwd: '',
97
+ });
98
+ }
99
+ return results;
100
+ }
101
+ //# sourceMappingURL=session.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session.js","sourceRoot":"","sources":["../../src/utils/session.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCH,sEAiBC;AA/CD,2CAA6B;AAC7B,iDAAyC;AAsBzC;;;;;;GAMG;AACH,SAAgB,6BAA6B,CAAC,IAAc;IACxD,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IAEjC,IAAI,CAAC;QACD,MAAM,OAAO,GAAG,OAAO,CAAC,QAAQ,KAAK,QAAQ,CAAC;QAC9C,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC1D,wEAAwE;QACxE,MAAM,OAAO,GAAG,OAAO;YACnB,CAAC,CAAC,mBAAmB,KAAK,sBAAsB;YAChD,CAAC,CAAC,yBAAyB,KAAK,sBAAsB,CAAC;QAE3D,MAAM,MAAM,GAAG,IAAA,wBAAQ,EAAC,OAAO,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,CAAC;QAExD,OAAO,eAAe,CAAC,MAAM,CAAC,CAAC;IACnC,CAAC;IAAC,MAAM,CAAC;QACL,OAAO,EAAE,CAAC;IACd,CAAC;AACL,CAAC;AAED;;GAEG;AACH,SAAS,eAAe,CAAC,MAAc;IACnC,MAAM,OAAO,GAAkB,EAAE,CAAC;IAElC,KAAK,MAAM,OAAO,IAAI,MAAM,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;QAC9C,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;QAC5B,IAAI,CAAC,IAAI;YAAE,SAAS;QAEpB,uCAAuC;QACvC,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QACnC,IAAI,QAAQ,KAAK,CAAC,CAAC;YAAE,SAAS;QAE9B,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC;QACzC,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;QAEjD,MAAM,YAAY,GAAG,QAAQ,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;QAC5C,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,YAAY,CAAC,IAAI,YAAY,IAAI,CAAC;YAAE,SAAS;QAElE,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QACzC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,QAAQ,CAAC;YAAE,SAAS;QAE3C,MAAM,SAAS,GAAG,QAAQ,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;QAEnD,OAAO,CAAC,IAAI,CAAC;YACT,SAAS;YACT,QAAQ;YACR,UAAU,EAAE,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC;YAClC,WAAW,EAAE,YAAY,GAAG,IAAI;YAChC,WAAW,EAAE,EAAE;SAClB,CAAC,CAAC;IACP,CAAC;IAED,OAAO,OAAO,CAAC;AACnB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-devkit/agent-manager",
3
- "version": "0.3.0",
3
+ "version": "0.5.0",
4
4
  "description": "Standalone agent detection and management utilities for AI DevKit",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -37,6 +37,6 @@
37
37
  "typescript": "^5.3.3"
38
38
  },
39
39
  "engines": {
40
- "node": ">=16.0.0"
40
+ "node": ">=20.20.0"
41
41
  }
42
42
  }
@@ -130,17 +130,6 @@ describe('AgentManager', () => {
130
130
  });
131
131
  });
132
132
 
133
- describe('hasAdapter', () => {
134
- it('should return true for registered adapter', () => {
135
- manager.registerAdapter(new MockAdapter('claude'));
136
- expect(manager.hasAdapter('claude')).toBe(true);
137
- });
138
-
139
- it('should return false for non-registered adapter', () => {
140
- expect(manager.hasAdapter('claude')).toBe(false);
141
- });
142
- });
143
-
144
133
  describe('listAgents', () => {
145
134
  it('should return empty array when no adapters registered', async () => {
146
135
  const agents = await manager.listAgents();
@@ -222,20 +211,6 @@ describe('AgentManager', () => {
222
211
  });
223
212
  });
224
213
 
225
- describe('getAdapterCount', () => {
226
- it('should return 0 when no adapters registered', () => {
227
- expect(manager.getAdapterCount()).toBe(0);
228
- });
229
-
230
- it('should return correct count', () => {
231
- manager.registerAdapter(new MockAdapter('claude'));
232
- expect(manager.getAdapterCount()).toBe(1);
233
-
234
- manager.registerAdapter(new MockAdapter('gemini_cli'));
235
- expect(manager.getAdapterCount()).toBe(2);
236
- });
237
- });
238
-
239
214
  describe('clear', () => {
240
215
  it('should remove all adapters', () => {
241
216
  manager.registerAdapter(new MockAdapter('claude'));