github-issue-tower-defence-management 1.97.4 → 1.98.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 (30) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/README.md +12 -0
  3. package/bin/adapter/entry-points/cli/index.js +62 -0
  4. package/bin/adapter/entry-points/cli/index.js.map +1 -1
  5. package/bin/adapter/entry-points/handlers/InTmuxByHumanSessionTokenCountHandler.js +48 -0
  6. package/bin/adapter/entry-points/handlers/InTmuxByHumanSessionTokenCountHandler.js.map +1 -0
  7. package/bin/adapter/repositories/ProcClaudeInteractiveSessionRepository.js +145 -0
  8. package/bin/adapter/repositories/ProcClaudeInteractiveSessionRepository.js.map +1 -0
  9. package/bin/domain/usecases/InTmuxByHumanSessionTokenCountUseCase.js +41 -0
  10. package/bin/domain/usecases/InTmuxByHumanSessionTokenCountUseCase.js.map +1 -0
  11. package/bin/domain/usecases/adapter-interfaces/ClaudeInteractiveSessionRepository.js +3 -0
  12. package/bin/domain/usecases/adapter-interfaces/ClaudeInteractiveSessionRepository.js.map +1 -0
  13. package/package.json +1 -1
  14. package/src/adapter/entry-points/cli/index.ts +120 -0
  15. package/src/adapter/entry-points/handlers/InTmuxByHumanSessionTokenCountHandler.test.ts +123 -0
  16. package/src/adapter/entry-points/handlers/InTmuxByHumanSessionTokenCountHandler.ts +77 -0
  17. package/src/adapter/repositories/ProcClaudeInteractiveSessionRepository.test.ts +184 -0
  18. package/src/adapter/repositories/ProcClaudeInteractiveSessionRepository.ts +138 -0
  19. package/src/domain/usecases/InTmuxByHumanSessionTokenCountUseCase.test.ts +169 -0
  20. package/src/domain/usecases/InTmuxByHumanSessionTokenCountUseCase.ts +63 -0
  21. package/src/domain/usecases/adapter-interfaces/ClaudeInteractiveSessionRepository.ts +9 -0
  22. package/types/adapter/entry-points/cli/index.d.ts.map +1 -1
  23. package/types/adapter/entry-points/handlers/InTmuxByHumanSessionTokenCountHandler.d.ts +18 -0
  24. package/types/adapter/entry-points/handlers/InTmuxByHumanSessionTokenCountHandler.d.ts.map +1 -0
  25. package/types/adapter/repositories/ProcClaudeInteractiveSessionRepository.d.ts +11 -0
  26. package/types/adapter/repositories/ProcClaudeInteractiveSessionRepository.d.ts.map +1 -0
  27. package/types/domain/usecases/InTmuxByHumanSessionTokenCountUseCase.d.ts +17 -0
  28. package/types/domain/usecases/InTmuxByHumanSessionTokenCountUseCase.d.ts.map +1 -0
  29. package/types/domain/usecases/adapter-interfaces/ClaudeInteractiveSessionRepository.d.ts +9 -0
  30. package/types/domain/usecases/adapter-interfaces/ClaudeInteractiveSessionRepository.d.ts.map +1 -0
@@ -0,0 +1,63 @@
1
+ import { Issue } from '../entities/Issue';
2
+ import { IN_TMUX_STATUS_NAME } from '../entities/WorkflowStatus';
3
+ import { ClaudeInteractiveSession } from './adapter-interfaces/ClaudeInteractiveSessionRepository';
4
+ import { OauthTokenCandidate } from './OauthTokenSelectUseCase';
5
+
6
+ export type InTmuxByHumanSessionTokenCount = {
7
+ name: string;
8
+ token: string;
9
+ count: number;
10
+ };
11
+
12
+ export type InTmuxByHumanSessionTokenCountResult = {
13
+ counts: InTmuxByHumanSessionTokenCount[];
14
+ };
15
+
16
+ export class InTmuxByHumanSessionTokenCountUseCase {
17
+ run = (
18
+ candidates: OauthTokenCandidate[],
19
+ interactiveSessions: ClaudeInteractiveSession[],
20
+ issues: Issue[],
21
+ ): InTmuxByHumanSessionTokenCountResult => {
22
+ const inTmuxByHumanIssueUrls = this.inTmuxByHumanIssueUrls(issues);
23
+ const distinctSessionIdsByToken = this.distinctSessionIdsByToken(
24
+ interactiveSessions,
25
+ inTmuxByHumanIssueUrls,
26
+ );
27
+
28
+ const counts = candidates.map((candidate) => ({
29
+ name: candidate.name,
30
+ token: candidate.token,
31
+ count: distinctSessionIdsByToken.get(candidate.token)?.size ?? 0,
32
+ }));
33
+
34
+ return { counts };
35
+ };
36
+
37
+ private inTmuxByHumanIssueUrls = (issues: Issue[]): Set<string> => {
38
+ const urls = new Set<string>();
39
+ for (const issue of issues) {
40
+ if (issue.status === IN_TMUX_STATUS_NAME && issue.isClosed === false) {
41
+ urls.add(issue.url);
42
+ }
43
+ }
44
+ return urls;
45
+ };
46
+
47
+ private distinctSessionIdsByToken = (
48
+ interactiveSessions: ClaudeInteractiveSession[],
49
+ inTmuxByHumanIssueUrls: Set<string>,
50
+ ): Map<string, Set<string>> => {
51
+ const sessionIdsByToken = new Map<string, Set<string>>();
52
+ for (const session of interactiveSessions) {
53
+ if (!inTmuxByHumanIssueUrls.has(session.issueUrl)) {
54
+ continue;
55
+ }
56
+ const sessionIds =
57
+ sessionIdsByToken.get(session.token) ?? new Set<string>();
58
+ sessionIds.add(session.sessionId);
59
+ sessionIdsByToken.set(session.token, sessionIds);
60
+ }
61
+ return sessionIdsByToken;
62
+ };
63
+ }
@@ -0,0 +1,9 @@
1
+ export type ClaudeInteractiveSession = {
2
+ token: string;
3
+ sessionId: string;
4
+ issueUrl: string;
5
+ };
6
+
7
+ export interface ClaudeInteractiveSessionRepository {
8
+ listInteractiveSessions: () => ClaudeInteractiveSession[];
9
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/adapter/entry-points/cli/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EACL,UAAU,EACV,cAAc,EACd,wBAAwB,EACxB,YAAY,EACZ,kBAAkB,GACnB,MAAM,iBAAiB,CAAC;AAwGzB,eAAO,MAAM,OAAO,SAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/adapter/entry-points/cli/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EACL,UAAU,EACV,cAAc,EACd,wBAAwB,EACxB,YAAY,EACZ,kBAAkB,GACnB,MAAM,iBAAiB,CAAC;AA+GzB,eAAO,MAAM,OAAO,SAAgB,CAAC"}
@@ -0,0 +1,18 @@
1
+ import { Issue } from '../../../domain/entities/Issue';
2
+ import { ClaudeInteractiveSessionRepository } from '../../../domain/usecases/adapter-interfaces/ClaudeInteractiveSessionRepository';
3
+ import { InTmuxByHumanSessionTokenCountUseCase } from '../../../domain/usecases/InTmuxByHumanSessionTokenCountUseCase';
4
+ export type InTmuxByHumanSessionTokenCountHandlerInput = {
5
+ tokenListJsonPath: string | null;
6
+ issues: Issue[];
7
+ };
8
+ export type InTmuxByHumanSessionTokenCountHandlerOutput = {
9
+ lines: string[];
10
+ diagnostics: string[];
11
+ };
12
+ export declare class InTmuxByHumanSessionTokenCountHandler {
13
+ private readonly useCase;
14
+ private readonly interactiveSessionRepository;
15
+ constructor(useCase?: InTmuxByHumanSessionTokenCountUseCase, interactiveSessionRepository?: ClaudeInteractiveSessionRepository);
16
+ handle: (input: InTmuxByHumanSessionTokenCountHandlerInput) => InTmuxByHumanSessionTokenCountHandlerOutput;
17
+ }
18
+ //# sourceMappingURL=InTmuxByHumanSessionTokenCountHandler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InTmuxByHumanSessionTokenCountHandler.d.ts","sourceRoot":"","sources":["../../../../src/adapter/entry-points/handlers/InTmuxByHumanSessionTokenCountHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,gCAAgC,CAAC;AACvD,OAAO,EAAE,kCAAkC,EAAE,MAAM,gFAAgF,CAAC;AACpI,OAAO,EAAE,qCAAqC,EAAE,MAAM,gEAAgE,CAAC;AAMvH,MAAM,MAAM,0CAA0C,GAAG;IACvD,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,MAAM,EAAE,KAAK,EAAE,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,2CAA2C,GAAG;IACxD,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB,CAAC;AAEF,qBAAa,qCAAqC;IAE9C,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,4BAA4B;gBAD5B,OAAO,GAAE,qCAAmF,EAC5F,4BAA4B,GAAE,kCAAiF;IAGlI,MAAM,GACJ,OAAO,0CAA0C,KAChD,2CAA2C,CAiD5C;CACH"}
@@ -0,0 +1,11 @@
1
+ import { ClaudeInteractiveSession, ClaudeInteractiveSessionRepository } from '../../domain/usecases/adapter-interfaces/ClaudeInteractiveSessionRepository';
2
+ export declare class ProcClaudeInteractiveSessionRepository implements ClaudeInteractiveSessionRepository {
3
+ private readonly procDirectory;
4
+ constructor(procDirectory?: string);
5
+ listInteractiveSessions: () => ClaudeInteractiveSession[];
6
+ private listProcessIdDirectories;
7
+ private readInteractiveSession;
8
+ private readCommandArguments;
9
+ private readEnviron;
10
+ }
11
+ //# sourceMappingURL=ProcClaudeInteractiveSessionRepository.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProcClaudeInteractiveSessionRepository.d.ts","sourceRoot":"","sources":["../../../src/adapter/repositories/ProcClaudeInteractiveSessionRepository.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,wBAAwB,EACxB,kCAAkC,EACnC,MAAM,6EAA6E,CAAC;AA6BrF,qBAAa,sCAAuC,YAAW,kCAAkC;IAE7F,OAAO,CAAC,QAAQ,CAAC,aAAa;gBAAb,aAAa,GAAE,MAA+B;IAGjE,uBAAuB,QAAO,wBAAwB,EAAE,CAStD;IAEF,OAAO,CAAC,wBAAwB,CAQ9B;IAEF,OAAO,CAAC,sBAAsB,CA6B5B;IAEF,OAAO,CAAC,oBAAoB,CAe1B;IAEF,OAAO,CAAC,WAAW,CA4BjB;CACH"}
@@ -0,0 +1,17 @@
1
+ import { Issue } from '../entities/Issue';
2
+ import { ClaudeInteractiveSession } from './adapter-interfaces/ClaudeInteractiveSessionRepository';
3
+ import { OauthTokenCandidate } from './OauthTokenSelectUseCase';
4
+ export type InTmuxByHumanSessionTokenCount = {
5
+ name: string;
6
+ token: string;
7
+ count: number;
8
+ };
9
+ export type InTmuxByHumanSessionTokenCountResult = {
10
+ counts: InTmuxByHumanSessionTokenCount[];
11
+ };
12
+ export declare class InTmuxByHumanSessionTokenCountUseCase {
13
+ run: (candidates: OauthTokenCandidate[], interactiveSessions: ClaudeInteractiveSession[], issues: Issue[]) => InTmuxByHumanSessionTokenCountResult;
14
+ private inTmuxByHumanIssueUrls;
15
+ private distinctSessionIdsByToken;
16
+ }
17
+ //# sourceMappingURL=InTmuxByHumanSessionTokenCountUseCase.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InTmuxByHumanSessionTokenCountUseCase.d.ts","sourceRoot":"","sources":["../../../src/domain/usecases/InTmuxByHumanSessionTokenCountUseCase.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAE1C,OAAO,EAAE,wBAAwB,EAAE,MAAM,yDAAyD,CAAC;AACnG,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAEhE,MAAM,MAAM,8BAA8B,GAAG;IAC3C,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,oCAAoC,GAAG;IACjD,MAAM,EAAE,8BAA8B,EAAE,CAAC;CAC1C,CAAC;AAEF,qBAAa,qCAAqC;IAChD,GAAG,GACD,YAAY,mBAAmB,EAAE,EACjC,qBAAqB,wBAAwB,EAAE,EAC/C,QAAQ,KAAK,EAAE,KACd,oCAAoC,CAcrC;IAEF,OAAO,CAAC,sBAAsB,CAQ5B;IAEF,OAAO,CAAC,yBAAyB,CAe/B;CACH"}
@@ -0,0 +1,9 @@
1
+ export type ClaudeInteractiveSession = {
2
+ token: string;
3
+ sessionId: string;
4
+ issueUrl: string;
5
+ };
6
+ export interface ClaudeInteractiveSessionRepository {
7
+ listInteractiveSessions: () => ClaudeInteractiveSession[];
8
+ }
9
+ //# sourceMappingURL=ClaudeInteractiveSessionRepository.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ClaudeInteractiveSessionRepository.d.ts","sourceRoot":"","sources":["../../../../src/domain/usecases/adapter-interfaces/ClaudeInteractiveSessionRepository.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,wBAAwB,GAAG;IACrC,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,WAAW,kCAAkC;IACjD,uBAAuB,EAAE,MAAM,wBAAwB,EAAE,CAAC;CAC3D"}