@lousy-agents/cli 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.
Files changed (151) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +148 -0
  3. package/dist/commands/copilot-setup.d.ts +5 -0
  4. package/dist/commands/copilot-setup.d.ts.map +1 -0
  5. package/dist/commands/copilot-setup.js +97 -0
  6. package/dist/commands/copilot-setup.js.map +1 -0
  7. package/dist/commands/init.d.ts +12 -0
  8. package/dist/commands/init.d.ts.map +1 -0
  9. package/dist/commands/init.js +115 -0
  10. package/dist/commands/init.js.map +1 -0
  11. package/dist/commands/new.d.ts +11 -0
  12. package/dist/commands/new.d.ts.map +1 -0
  13. package/dist/commands/new.js +41 -0
  14. package/dist/commands/new.js.map +1 -0
  15. package/dist/entities/copilot-agent.d.ts +15 -0
  16. package/dist/entities/copilot-agent.d.ts.map +1 -0
  17. package/dist/entities/copilot-agent.js +53 -0
  18. package/dist/entities/copilot-agent.js.map +1 -0
  19. package/dist/entities/copilot-setup.d.ts +65 -0
  20. package/dist/entities/copilot-setup.d.ts.map +1 -0
  21. package/dist/entities/copilot-setup.js +6 -0
  22. package/dist/entities/copilot-setup.js.map +1 -0
  23. package/dist/entities/index.d.ts +6 -0
  24. package/dist/entities/index.d.ts.map +1 -0
  25. package/dist/entities/index.js +6 -0
  26. package/dist/entities/index.js.map +1 -0
  27. package/dist/gateways/action-version-gateway.d.ts +39 -0
  28. package/dist/gateways/action-version-gateway.d.ts.map +1 -0
  29. package/dist/gateways/action-version-gateway.js +47 -0
  30. package/dist/gateways/action-version-gateway.js.map +1 -0
  31. package/dist/gateways/agent-file-gateway.d.ts +50 -0
  32. package/dist/gateways/agent-file-gateway.d.ts.map +1 -0
  33. package/dist/gateways/agent-file-gateway.js +34 -0
  34. package/dist/gateways/agent-file-gateway.js.map +1 -0
  35. package/dist/gateways/environment-gateway.d.ts +30 -0
  36. package/dist/gateways/environment-gateway.d.ts.map +1 -0
  37. package/dist/gateways/environment-gateway.js +56 -0
  38. package/dist/gateways/environment-gateway.js.map +1 -0
  39. package/dist/gateways/file-system-utils.d.ts +8 -0
  40. package/dist/gateways/file-system-utils.d.ts.map +1 -0
  41. package/dist/gateways/file-system-utils.js +17 -0
  42. package/dist/gateways/file-system-utils.js.map +1 -0
  43. package/dist/gateways/file-system-workflow-gateway.d.ts +27 -0
  44. package/dist/gateways/file-system-workflow-gateway.d.ts.map +1 -0
  45. package/dist/gateways/file-system-workflow-gateway.js +99 -0
  46. package/dist/gateways/file-system-workflow-gateway.js.map +1 -0
  47. package/dist/gateways/index.d.ts +9 -0
  48. package/dist/gateways/index.d.ts.map +1 -0
  49. package/dist/gateways/index.js +9 -0
  50. package/dist/gateways/index.js.map +1 -0
  51. package/dist/gateways/workflow-gateway.d.ts +43 -0
  52. package/dist/gateways/workflow-gateway.d.ts.map +1 -0
  53. package/dist/gateways/workflow-gateway.js +6 -0
  54. package/dist/gateways/workflow-gateway.js.map +1 -0
  55. package/dist/index.d.ts +3 -0
  56. package/dist/index.d.ts.map +1 -0
  57. package/dist/index.js +19 -0
  58. package/dist/index.js.map +1 -0
  59. package/dist/lib/config.d.ts +27 -0
  60. package/dist/lib/config.d.ts.map +1 -0
  61. package/dist/lib/config.js +226 -0
  62. package/dist/lib/config.js.map +1 -0
  63. package/dist/lib/copilot-setup-config.d.ts +79 -0
  64. package/dist/lib/copilot-setup-config.d.ts.map +1 -0
  65. package/dist/lib/copilot-setup-config.js +119 -0
  66. package/dist/lib/copilot-setup-config.js.map +1 -0
  67. package/dist/lib/filesystem-structure.d.ts +45 -0
  68. package/dist/lib/filesystem-structure.d.ts.map +1 -0
  69. package/dist/lib/filesystem-structure.js +69 -0
  70. package/dist/lib/filesystem-structure.js.map +1 -0
  71. package/dist/lib/mcp-test-client.d.ts +43 -0
  72. package/dist/lib/mcp-test-client.d.ts.map +1 -0
  73. package/dist/lib/mcp-test-client.js +167 -0
  74. package/dist/lib/mcp-test-client.js.map +1 -0
  75. package/dist/lib/project-name-validation.d.ts +43 -0
  76. package/dist/lib/project-name-validation.d.ts.map +1 -0
  77. package/dist/lib/project-name-validation.js +131 -0
  78. package/dist/lib/project-name-validation.js.map +1 -0
  79. package/dist/mcp/index.d.ts +5 -0
  80. package/dist/mcp/index.d.ts.map +1 -0
  81. package/dist/mcp/index.js +5 -0
  82. package/dist/mcp/index.js.map +1 -0
  83. package/dist/mcp/server.d.ts +15 -0
  84. package/dist/mcp/server.d.ts.map +1 -0
  85. package/dist/mcp/server.js +120 -0
  86. package/dist/mcp/server.js.map +1 -0
  87. package/dist/mcp/tools/analyze-action-versions.d.ts +9 -0
  88. package/dist/mcp/tools/analyze-action-versions.d.ts.map +1 -0
  89. package/dist/mcp/tools/analyze-action-versions.js +81 -0
  90. package/dist/mcp/tools/analyze-action-versions.js.map +1 -0
  91. package/dist/mcp/tools/create-copilot-setup-workflow.d.ts +9 -0
  92. package/dist/mcp/tools/create-copilot-setup-workflow.d.ts.map +1 -0
  93. package/dist/mcp/tools/create-copilot-setup-workflow.js +121 -0
  94. package/dist/mcp/tools/create-copilot-setup-workflow.js.map +1 -0
  95. package/dist/mcp/tools/discover-environment.d.ts +9 -0
  96. package/dist/mcp/tools/discover-environment.d.ts.map +1 -0
  97. package/dist/mcp/tools/discover-environment.js +30 -0
  98. package/dist/mcp/tools/discover-environment.js.map +1 -0
  99. package/dist/mcp/tools/discover-workflow-setup-actions.d.ts +9 -0
  100. package/dist/mcp/tools/discover-workflow-setup-actions.d.ts.map +1 -0
  101. package/dist/mcp/tools/discover-workflow-setup-actions.js +37 -0
  102. package/dist/mcp/tools/discover-workflow-setup-actions.js.map +1 -0
  103. package/dist/mcp/tools/index.d.ts +11 -0
  104. package/dist/mcp/tools/index.d.ts.map +1 -0
  105. package/dist/mcp/tools/index.js +11 -0
  106. package/dist/mcp/tools/index.js.map +1 -0
  107. package/dist/mcp/tools/read-copilot-setup-workflow.d.ts +9 -0
  108. package/dist/mcp/tools/read-copilot-setup-workflow.d.ts.map +1 -0
  109. package/dist/mcp/tools/read-copilot-setup-workflow.js +38 -0
  110. package/dist/mcp/tools/read-copilot-setup-workflow.js.map +1 -0
  111. package/dist/mcp/tools/resolve-action-versions.d.ts +10 -0
  112. package/dist/mcp/tools/resolve-action-versions.d.ts.map +1 -0
  113. package/dist/mcp/tools/resolve-action-versions.js +61 -0
  114. package/dist/mcp/tools/resolve-action-versions.js.map +1 -0
  115. package/dist/mcp/tools/types.d.ts +67 -0
  116. package/dist/mcp/tools/types.d.ts.map +1 -0
  117. package/dist/mcp/tools/types.js +24 -0
  118. package/dist/mcp/tools/types.js.map +1 -0
  119. package/dist/mcp-server.d.ts +7 -0
  120. package/dist/mcp-server.d.ts.map +1 -0
  121. package/dist/mcp-server.js +17 -0
  122. package/dist/mcp-server.js.map +1 -0
  123. package/dist/use-cases/action-resolution.d.ts +66 -0
  124. package/dist/use-cases/action-resolution.d.ts.map +1 -0
  125. package/dist/use-cases/action-resolution.js +107 -0
  126. package/dist/use-cases/action-resolution.js.map +1 -0
  127. package/dist/use-cases/candidate-builder.d.ts +17 -0
  128. package/dist/use-cases/candidate-builder.d.ts.map +1 -0
  129. package/dist/use-cases/candidate-builder.js +67 -0
  130. package/dist/use-cases/candidate-builder.js.map +1 -0
  131. package/dist/use-cases/copilot-setup.d.ts +8 -0
  132. package/dist/use-cases/copilot-setup.d.ts.map +1 -0
  133. package/dist/use-cases/copilot-setup.js +10 -0
  134. package/dist/use-cases/copilot-setup.js.map +1 -0
  135. package/dist/use-cases/create-copilot-agent.d.ts +29 -0
  136. package/dist/use-cases/create-copilot-agent.d.ts.map +1 -0
  137. package/dist/use-cases/create-copilot-agent.js +73 -0
  138. package/dist/use-cases/create-copilot-agent.js.map +1 -0
  139. package/dist/use-cases/index.d.ts +9 -0
  140. package/dist/use-cases/index.d.ts.map +1 -0
  141. package/dist/use-cases/index.js +9 -0
  142. package/dist/use-cases/index.js.map +1 -0
  143. package/dist/use-cases/setup-step-discovery.d.ts +87 -0
  144. package/dist/use-cases/setup-step-discovery.d.ts.map +1 -0
  145. package/dist/use-cases/setup-step-discovery.js +202 -0
  146. package/dist/use-cases/setup-step-discovery.js.map +1 -0
  147. package/dist/use-cases/workflow-generator.d.ts +34 -0
  148. package/dist/use-cases/workflow-generator.d.ts.map +1 -0
  149. package/dist/use-cases/workflow-generator.js +195 -0
  150. package/dist/use-cases/workflow-generator.js.map +1 -0
  151. package/package.json +65 -0
@@ -0,0 +1,107 @@
1
+ /**
2
+ * Use case for building action resolution metadata.
3
+ * This module provides logic for identifying actions that need version resolution
4
+ * and generating lookup URLs for the LLM to fetch latest versions.
5
+ */
6
+ /**
7
+ * The placeholder string used in workflow templates when version resolution is needed.
8
+ */
9
+ export const VERSION_PLACEHOLDER = "RESOLVE_VERSION";
10
+ /**
11
+ * Instructions for the LLM to resolve action versions.
12
+ */
13
+ export const VERSION_RESOLUTION_INSTRUCTIONS = `To resolve action versions:
14
+ 1. For each action in actionsToResolve, fetch the lookup_url to find the latest release
15
+ 2. Find the latest release tag (e.g., v4.0.0)
16
+ 3. Get the commit SHA for that tag from the release page or GitHub API
17
+ 4. Pin actions to SHA with version comment: action@SHA # vX.X.X
18
+ 5. Call this tool again with resolvedVersions to generate the final workflow
19
+
20
+ Example resolved format: actions/setup-node@1a2b3c4d5e6f # v4.0.0`;
21
+ /**
22
+ * Generates a GitHub releases lookup URL for an action.
23
+ * @param action The action name (e.g., "actions/setup-node")
24
+ * @returns The URL to the action's latest release page
25
+ */
26
+ export function generateLookupUrl(action) {
27
+ return `https://github.com/${action}/releases/latest`;
28
+ }
29
+ /**
30
+ * Builds an ActionToResolve entry for a given action.
31
+ * @param action The action name (e.g., "actions/setup-node")
32
+ * @returns ActionToResolve metadata for the action
33
+ */
34
+ export function buildActionToResolve(action) {
35
+ return {
36
+ action,
37
+ currentPlaceholder: VERSION_PLACEHOLDER,
38
+ lookupUrl: generateLookupUrl(action),
39
+ };
40
+ }
41
+ /**
42
+ * Builds an array of ActionToResolve entries from setup step candidates.
43
+ * Filters out actions that already have resolved versions.
44
+ * @param candidates The setup step candidates
45
+ * @param resolvedVersions Optional array of already-resolved versions
46
+ * @returns Array of actions that need version resolution
47
+ */
48
+ export function buildActionsToResolve(candidates, resolvedVersions) {
49
+ const resolvedActions = new Set(resolvedVersions?.map((r) => r.action) ?? []);
50
+ // Include checkout action which is always added to workflows
51
+ const allActions = ["actions/checkout", ...candidates.map((c) => c.action)];
52
+ // Deduplicate and filter out already-resolved actions
53
+ const uniqueActions = [...new Set(allActions)].filter((action) => !resolvedActions.has(action));
54
+ return uniqueActions.map(buildActionToResolve);
55
+ }
56
+ /**
57
+ * Formats an action reference with SHA pinning and version comment.
58
+ * @param action The action name (e.g., "actions/setup-node")
59
+ * @param sha The commit SHA
60
+ * @param versionTag The version tag for the comment (e.g., "v4.0.0")
61
+ * @returns Formatted action reference (e.g., "actions/setup-node@abc123 # v4.0.0")
62
+ */
63
+ export function formatShaPinnedAction(action, sha, versionTag) {
64
+ return `${action}@${sha} # ${versionTag}`;
65
+ }
66
+ /**
67
+ * Finds a resolved version for a given action.
68
+ * @param action The action name to look up
69
+ * @param resolvedVersions Array of resolved versions
70
+ * @returns The resolved version or undefined if not found
71
+ */
72
+ export function findResolvedVersion(action, resolvedVersions) {
73
+ return resolvedVersions.find((r) => r.action === action);
74
+ }
75
+ /**
76
+ * Gets the version string to use for an action.
77
+ * Returns SHA-pinned format if resolved, or placeholder if not.
78
+ * @param action The action name
79
+ * @param resolvedVersions Optional array of resolved versions
80
+ * @param fallbackVersion Optional fallback version (e.g., "v4")
81
+ * @returns The version string to use in the workflow
82
+ */
83
+ export function getActionVersion(action, resolvedVersions, fallbackVersion) {
84
+ if (resolvedVersions) {
85
+ const resolved = findResolvedVersion(action, resolvedVersions);
86
+ if (resolved) {
87
+ return `${resolved.sha} # ${resolved.versionTag}`;
88
+ }
89
+ }
90
+ // If we have a fallback version (from existing workflow or gateway), use it
91
+ if (fallbackVersion) {
92
+ return fallbackVersion;
93
+ }
94
+ // Otherwise, use placeholder
95
+ return VERSION_PLACEHOLDER;
96
+ }
97
+ /**
98
+ * Checks if all required actions have been resolved.
99
+ * @param candidates The setup step candidates
100
+ * @param resolvedVersions Array of resolved versions
101
+ * @returns True if all actions (including checkout) are resolved
102
+ */
103
+ export function allActionsResolved(candidates, resolvedVersions) {
104
+ const actionsToResolve = buildActionsToResolve(candidates, resolvedVersions);
105
+ return actionsToResolve.length === 0;
106
+ }
107
+ //# sourceMappingURL=action-resolution.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"action-resolution.js","sourceRoot":"","sources":["../../src/use-cases/action-resolution.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAQH;;GAEG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,iBAAiB,CAAC;AAErD;;GAEG;AACH,MAAM,CAAC,MAAM,+BAA+B,GAAG;;;;;;;mEAOoB,CAAC;AAEpE;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAAC,MAAc;IAC5C,OAAO,sBAAsB,MAAM,kBAAkB,CAAC;AAC1D,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAAC,MAAc;IAC/C,OAAO;QACH,MAAM;QACN,kBAAkB,EAAE,mBAAmB;QACvC,SAAS,EAAE,iBAAiB,CAAC,MAAM,CAAC;KACvC,CAAC;AACN,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,qBAAqB,CACjC,UAAgC,EAChC,gBAAoC;IAEpC,MAAM,eAAe,GAAG,IAAI,GAAG,CAC3B,gBAAgB,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE,CAC/C,CAAC;IAEF,6DAA6D;IAC7D,MAAM,UAAU,GAAG,CAAC,kBAAkB,EAAE,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;IAE5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CAAC,CAAC;AACzC,CAAC"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Use case for building setup step candidates from environment detection.
3
+ * This module handles the logic of determining which GitHub Actions
4
+ * setup steps should be added based on detected version files.
5
+ */
6
+ import type { DetectedEnvironment, SetupStepCandidate } from "../entities/copilot-setup.js";
7
+ import type { ActionVersionGateway } from "../gateways/action-version-gateway.js";
8
+ import { type CopilotSetupConfig } from "../lib/copilot-setup-config.js";
9
+ /**
10
+ * Builds setup step candidates from detected environment
11
+ * @param environment The detected environment configuration
12
+ * @param versionGateway Optional gateway for looking up action versions (defaults to local)
13
+ * @param config Optional copilot-setup configuration
14
+ * @returns Array of setup step candidates
15
+ */
16
+ export declare function buildCandidatesFromEnvironment(environment: DetectedEnvironment, versionGateway?: ActionVersionGateway, config?: CopilotSetupConfig): Promise<SetupStepCandidate[]>;
17
+ //# sourceMappingURL=candidate-builder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"candidate-builder.d.ts","sourceRoot":"","sources":["../../src/use-cases/candidate-builder.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EACR,mBAAmB,EACnB,kBAAkB,EAGrB,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAElF,OAAO,EACH,KAAK,kBAAkB,EAI1B,MAAM,gCAAgC,CAAC;AAExC;;;;;;GAMG;AACH,wBAAsB,8BAA8B,CAChD,WAAW,EAAE,mBAAmB,EAChC,cAAc,GAAE,oBAAmD,EACnE,MAAM,CAAC,EAAE,kBAAkB,GAC5B,OAAO,CAAC,kBAAkB,EAAE,CAAC,CAyB/B"}
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Use case for building setup step candidates from environment detection.
3
+ * This module handles the logic of determining which GitHub Actions
4
+ * setup steps should be added based on detected version files.
5
+ */
6
+ import { createActionVersionGateway } from "../gateways/action-version-gateway.js";
7
+ import { getVersionFileConfigKeyMap, getVersionTypeToActionMap, loadCopilotSetupConfig, } from "../lib/copilot-setup-config.js";
8
+ /**
9
+ * Builds setup step candidates from detected environment
10
+ * @param environment The detected environment configuration
11
+ * @param versionGateway Optional gateway for looking up action versions (defaults to local)
12
+ * @param config Optional copilot-setup configuration
13
+ * @returns Array of setup step candidates
14
+ */
15
+ export async function buildCandidatesFromEnvironment(environment, versionGateway = createActionVersionGateway(), config) {
16
+ const loadedConfig = config || (await loadCopilotSetupConfig());
17
+ const versionTypeToAction = getVersionTypeToActionMap(loadedConfig);
18
+ const versionFileConfigKeys = getVersionFileConfigKeyMap(loadedConfig);
19
+ const candidates = [];
20
+ // If mise.toml is present, add mise-action only
21
+ if (environment.hasMise) {
22
+ const miseVersion = await versionGateway.getVersion("jdx/mise-action");
23
+ candidates.push({
24
+ action: "jdx/mise-action",
25
+ version: miseVersion,
26
+ source: "version-file",
27
+ });
28
+ return candidates;
29
+ }
30
+ // Otherwise, add individual setup actions for each version file
31
+ return buildCandidatesFromVersionFiles(environment.versionFiles, versionTypeToAction, versionFileConfigKeys, versionGateway);
32
+ }
33
+ /**
34
+ * Builds setup step candidates from individual version files
35
+ * @param versionFiles Array of version files to process
36
+ * @param versionTypeToAction Map from version file type to action name
37
+ * @param versionFileConfigKeys Map from version file type to config key
38
+ * @param versionGateway Gateway for looking up action versions
39
+ * @returns Array of setup step candidates
40
+ */
41
+ async function buildCandidatesFromVersionFiles(versionFiles, versionTypeToAction, versionFileConfigKeys, versionGateway) {
42
+ const candidates = [];
43
+ // Track which types we've already added to deduplicate (e.g., .nvmrc and .node-version)
44
+ const addedTypes = new Set();
45
+ for (const versionFile of versionFiles) {
46
+ if (addedTypes.has(versionFile.type)) {
47
+ continue;
48
+ }
49
+ addedTypes.add(versionFile.type);
50
+ const action = versionTypeToAction[versionFile.type];
51
+ const configKey = versionFileConfigKeys[versionFile.type];
52
+ if (!action || !configKey) {
53
+ continue;
54
+ }
55
+ const version = await versionGateway.getVersion(action);
56
+ candidates.push({
57
+ action,
58
+ version,
59
+ config: {
60
+ [configKey]: versionFile.filename,
61
+ },
62
+ source: "version-file",
63
+ });
64
+ }
65
+ return candidates;
66
+ }
67
+ //# sourceMappingURL=candidate-builder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"candidate-builder.js","sourceRoot":"","sources":["../../src/use-cases/candidate-builder.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AASH,OAAO,EAAE,0BAA0B,EAAE,MAAM,uCAAuC,CAAC;AACnF,OAAO,EAEH,0BAA0B,EAC1B,yBAAyB,EACzB,sBAAsB,GACzB,MAAM,gCAAgC,CAAC;AAExC;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,8BAA8B,CAChD,WAAgC,EAChC,iBAAuC,0BAA0B,EAAE,EACnE,MAA2B;IAE3B,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,MAAM,sBAAsB,EAAE,CAAC,CAAC;IAChE,MAAM,mBAAmB,GAAG,yBAAyB,CAAC,YAAY,CAAC,CAAC;IACpE,MAAM,qBAAqB,GAAG,0BAA0B,CAAC,YAAY,CAAC,CAAC;IAEvE,MAAM,UAAU,GAAyB,EAAE,CAAC;IAE5C,gDAAgD;IAChD,IAAI,WAAW,CAAC,OAAO,EAAE,CAAC;QACtB,MAAM,WAAW,GAAG,MAAM,cAAc,CAAC,UAAU,CAAC,iBAAiB,CAAC,CAAC;QACvE,UAAU,CAAC,IAAI,CAAC;YACZ,MAAM,EAAE,iBAAiB;YACzB,OAAO,EAAE,WAAW;YACpB,MAAM,EAAE,cAAc;SACzB,CAAC,CAAC;QACH,OAAO,UAAU,CAAC;IACtB,CAAC;IAED,gEAAgE;IAChE,OAAO,+BAA+B,CAClC,WAAW,CAAC,YAAY,EACxB,mBAAmB,EACnB,qBAAqB,EACrB,cAAc,CACjB,CAAC;AACN,CAAC;AAED;;;;;;;GAOG;AACH,KAAK,UAAU,+BAA+B,CAC1C,YAA2B,EAC3B,mBAA6D,EAC7D,qBAA+D,EAC/D,cAAoC;IAEpC,MAAM,UAAU,GAAyB,EAAE,CAAC;IAC5C,wFAAwF;IACxF,MAAM,UAAU,GAAG,IAAI,GAAG,EAAmB,CAAC;IAE9C,KAAK,MAAM,WAAW,IAAI,YAAY,EAAE,CAAC;QACrC,IAAI,UAAU,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC;YACnC,SAAS;QACb,CAAC;QACD,UAAU,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;QAEjC,MAAM,MAAM,GAAG,mBAAmB,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;QACrD,MAAM,SAAS,GAAG,qBAAqB,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;QAE1D,IAAI,CAAC,MAAM,IAAI,CAAC,SAAS,EAAE,CAAC;YACxB,SAAS;QACb,CAAC;QAED,MAAM,OAAO,GAAG,MAAM,cAAc,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;QAExD,UAAU,CAAC,IAAI,CAAC;YACZ,MAAM;YACN,OAAO;YACP,MAAM,EAAE;gBACJ,CAAC,SAAS,CAAC,EAAE,WAAW,CAAC,QAAQ;aACpC;YACD,MAAM,EAAE,cAAc;SACzB,CAAC,CAAC;IACP,CAAC;IAED,OAAO,UAAU,CAAC;AACtB,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Use cases for the Copilot Setup Steps feature.
3
+ * This module re-exports from candidate-builder and workflow-generator
4
+ * for backwards compatibility.
5
+ */
6
+ export { buildCandidatesFromEnvironment } from "./candidate-builder.js";
7
+ export { type GenerateWorkflowOptions, generateWorkflowContent, updateWorkflowWithMissingSteps, } from "./workflow-generator.js";
8
+ //# sourceMappingURL=copilot-setup.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"copilot-setup.d.ts","sourceRoot":"","sources":["../../src/use-cases/copilot-setup.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,8BAA8B,EAAE,MAAM,wBAAwB,CAAC;AAGxE,OAAO,EACH,KAAK,uBAAuB,EAC5B,uBAAuB,EACvB,8BAA8B,GACjC,MAAM,yBAAyB,CAAC"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Use cases for the Copilot Setup Steps feature.
3
+ * This module re-exports from candidate-builder and workflow-generator
4
+ * for backwards compatibility.
5
+ */
6
+ // Re-export candidate building functionality
7
+ export { buildCandidatesFromEnvironment } from "./candidate-builder.js";
8
+ // Re-export workflow generation functionality
9
+ export { generateWorkflowContent, updateWorkflowWithMissingSteps, } from "./workflow-generator.js";
10
+ //# sourceMappingURL=copilot-setup.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"copilot-setup.js","sourceRoot":"","sources":["../../src/use-cases/copilot-setup.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,6CAA6C;AAC7C,OAAO,EAAE,8BAA8B,EAAE,MAAM,wBAAwB,CAAC;AAExE,8CAA8C;AAC9C,OAAO,EAEH,uBAAuB,EACvB,8BAA8B,GACjC,MAAM,yBAAyB,CAAC"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Use case for creating GitHub Copilot custom agent files.
3
+ * Orchestrates entity logic with gateway operations.
4
+ */
5
+ import type { AgentFileGateway } from "../gateways/agent-file-gateway.js";
6
+ /**
7
+ * Result of the create copilot agent operation
8
+ */
9
+ export interface CreateCopilotAgentResult {
10
+ success: boolean;
11
+ normalizedName?: string;
12
+ filePath?: string;
13
+ error?: string;
14
+ }
15
+ /**
16
+ * Use case for creating a new Copilot agent file
17
+ */
18
+ export declare class CreateCopilotAgentUseCase {
19
+ private readonly gateway;
20
+ constructor(gateway: AgentFileGateway);
21
+ /**
22
+ * Executes the create agent operation
23
+ * @param targetDir The root directory of the repository
24
+ * @param agentName The name of the agent to create
25
+ * @returns Result of the operation
26
+ */
27
+ execute(targetDir: string, agentName: string): Promise<CreateCopilotAgentResult>;
28
+ }
29
+ //# sourceMappingURL=create-copilot-agent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-copilot-agent.d.ts","sourceRoot":"","sources":["../../src/use-cases/create-copilot-agent.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAe1E;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACrC,OAAO,EAAE,OAAO,CAAC;IACjB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,qBAAa,yBAAyB;IACtB,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAAP,OAAO,EAAE,gBAAgB;IAEtD;;;;;OAKG;IACG,OAAO,CACT,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,GAClB,OAAO,CAAC,wBAAwB,CAAC;CAsDvC"}
@@ -0,0 +1,73 @@
1
+ /**
2
+ * Use case for creating GitHub Copilot custom agent files.
3
+ * Orchestrates entity logic with gateway operations.
4
+ */
5
+ import { z } from "zod";
6
+ import { generateAgentContent, normalizeAgentName, } from "../entities/copilot-agent.js";
7
+ /**
8
+ * Schema for validating agent name input
9
+ * Validates that the input is a non-empty string with reasonable constraints
10
+ */
11
+ const AgentNameSchema = z
12
+ .string()
13
+ .min(1, "Agent name is required")
14
+ .max(100, "Agent name must be 100 characters or less")
15
+ .regex(/^[a-zA-Z0-9\s_-]+$/, "Agent name can only contain letters, numbers, spaces, hyphens, and underscores");
16
+ /**
17
+ * Use case for creating a new Copilot agent file
18
+ */
19
+ export class CreateCopilotAgentUseCase {
20
+ gateway;
21
+ constructor(gateway) {
22
+ this.gateway = gateway;
23
+ }
24
+ /**
25
+ * Executes the create agent operation
26
+ * @param targetDir The root directory of the repository
27
+ * @param agentName The name of the agent to create
28
+ * @returns Result of the operation
29
+ */
30
+ async execute(targetDir, agentName) {
31
+ // Validate the agent name using Zod schema
32
+ const validationResult = AgentNameSchema.safeParse(agentName);
33
+ if (!validationResult.success) {
34
+ const errorMessage = validationResult.error.issues[0]?.message ??
35
+ "Invalid agent name";
36
+ return {
37
+ success: false,
38
+ error: errorMessage,
39
+ };
40
+ }
41
+ // Normalize the agent name
42
+ const normalizedName = normalizeAgentName(validationResult.data);
43
+ // Validate that the normalized name is not empty (handles whitespace-only input)
44
+ if (!normalizedName) {
45
+ return {
46
+ success: false,
47
+ error: "Agent name is required",
48
+ };
49
+ }
50
+ // Get the file path
51
+ const filePath = this.gateway.getAgentFilePath(targetDir, normalizedName);
52
+ // Check if the file already exists
53
+ if (await this.gateway.agentFileExists(targetDir, normalizedName)) {
54
+ return {
55
+ success: false,
56
+ error: `Agent file already exists: ${filePath}`,
57
+ filePath,
58
+ };
59
+ }
60
+ // Ensure the directory exists
61
+ await this.gateway.ensureAgentsDirectory(targetDir);
62
+ // Generate the content
63
+ const content = generateAgentContent(normalizedName);
64
+ // Write the file
65
+ await this.gateway.writeAgentFile(targetDir, normalizedName, content);
66
+ return {
67
+ success: true,
68
+ normalizedName,
69
+ filePath,
70
+ };
71
+ }
72
+ }
73
+ //# sourceMappingURL=create-copilot-agent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-copilot-agent.js","sourceRoot":"","sources":["../../src/use-cases/create-copilot-agent.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACH,oBAAoB,EACpB,kBAAkB,GACrB,MAAM,8BAA8B,CAAC;AAGtC;;;GAGG;AACH,MAAM,eAAe,GAAG,CAAC;KACpB,MAAM,EAAE;KACR,GAAG,CAAC,CAAC,EAAE,wBAAwB,CAAC;KAChC,GAAG,CAAC,GAAG,EAAE,2CAA2C,CAAC;KACrD,KAAK,CACF,oBAAoB,EACpB,gFAAgF,CACnF,CAAC;AAYN;;GAEG;AACH,MAAM,OAAO,yBAAyB;IACL;IAA7B,YAA6B,OAAyB;QAAzB,Y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CAAC;QAEtE,OAAO;YACH,OAAO,EAAE,IAAI;YACb,cAAc;YACd,QAAQ;SACX,CAAC;IACN,CAAC;CACJ"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Use Cases - Application-specific business rules
3
+ */
4
+ export * from "./action-resolution.js";
5
+ export * from "./candidate-builder.js";
6
+ export * from "./copilot-setup.js";
7
+ export * from "./create-copilot-agent.js";
8
+ export * from "./workflow-generator.js";
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/use-cases/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC;AACnC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yBAAyB,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Use Cases - Application-specific business rules
3
+ */
4
+ export * from "./action-resolution.js";
5
+ export * from "./candidate-builder.js";
6
+ export * from "./copilot-setup.js";
7
+ export * from "./create-copilot-agent.js";
8
+ export * from "./workflow-generator.js";
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/use-cases/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC;AACnC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yBAAyB,CAAC"}
@@ -0,0 +1,87 @@
1
+ /**
2
+ * Use case for discovering setup steps in workflows.
3
+ * This module provides reusable logic for finding existing and missing setup steps.
4
+ */
5
+ import type { SetupStepCandidate } from "../entities/copilot-setup.js";
6
+ /**
7
+ * Extracts action name from a "uses" string
8
+ * @example "actions/setup-node@v4" -> "actions/setup-node"
9
+ */
10
+ export declare function parseActionName(uses: string): string;
11
+ /**
12
+ * Checks if an action matches any of the setup action patterns
13
+ * @param actionName The action name to check (e.g., "actions/setup-node")
14
+ * @param patterns List of patterns to match against
15
+ */
16
+ export declare function isSetupAction(actionName: string, patterns: string[]): boolean;
17
+ /**
18
+ * Step object with all fields (for workflow reading)
19
+ */
20
+ export interface WorkflowStepDetails {
21
+ name?: string;
22
+ uses?: string;
23
+ with?: Record<string, unknown>;
24
+ }
25
+ /**
26
+ * Extracts all steps from a workflow (including steps without "uses")
27
+ * @param workflow The parsed workflow object
28
+ * @returns Array of step details
29
+ */
30
+ export declare function extractAllWorkflowSteps(workflow: unknown): WorkflowStepDetails[];
31
+ /**
32
+ * Extracts existing setup actions from a parsed workflow
33
+ * @param workflow The parsed workflow object
34
+ * @returns Set of action names already present
35
+ */
36
+ export declare function getExistingActionsFromWorkflow(workflow: unknown): Set<string>;
37
+ /**
38
+ * Identifies candidates that are missing from an existing workflow
39
+ * @param candidates All candidates to potentially add
40
+ * @param existingActions Actions already present in the workflow
41
+ * @returns Candidates that need to be added
42
+ */
43
+ export declare function findMissingCandidates(candidates: SetupStepCandidate[], existingActions: Set<string>): SetupStepCandidate[];
44
+ /**
45
+ * Merges candidates from multiple sources, with earlier sources taking precedence
46
+ * @param candidateSources Arrays of candidates, in order of precedence
47
+ * @returns Merged and deduplicated candidates
48
+ */
49
+ export declare function mergeCandidates(...candidateSources: SetupStepCandidate[][]): SetupStepCandidate[];
50
+ /**
51
+ * Extracts version from a "uses" string
52
+ * @example "actions/setup-node@v4" -> "v4"
53
+ */
54
+ export declare function parseActionVersion(uses: string): string | undefined;
55
+ /**
56
+ * Action reference with name and version.
57
+ * @example { name: "actions/setup-node", version: "v4" }
58
+ * @example { name: "actions/checkout", version: "b4ffde65f46336ab88eb53be808477a3936bae11" }
59
+ */
60
+ export interface ActionReference {
61
+ /** The action name without version (e.g., "actions/setup-node") */
62
+ name: string;
63
+ /** The version, tag, or commit SHA (e.g., "v4", "main", "a1b2c3d4") */
64
+ version: string;
65
+ }
66
+ /**
67
+ * Extracts all action references from a workflow.
68
+ * Only includes actions that have a version specified (format: "action@version").
69
+ * Actions without versions are skipped as they represent incomplete references.
70
+ * @param workflow The parsed workflow object
71
+ * @returns Array of action references with name and version
72
+ */
73
+ export declare function extractActionsFromWorkflow(workflow: unknown): ActionReference[];
74
+ /**
75
+ * Extracts setup step candidates from a parsed workflow based on action patterns
76
+ * @param workflow The parsed workflow object
77
+ * @param patterns List of action patterns to detect
78
+ * @returns Array of setup step candidates
79
+ */
80
+ export declare function extractSetupStepsFromWorkflow(workflow: unknown, patterns: string[]): SetupStepCandidate[];
81
+ /**
82
+ * Deduplicates candidates by action name, keeping the first occurrence
83
+ * @param candidates Array of candidates to deduplicate
84
+ * @returns Deduplicated array of candidates
85
+ */
86
+ export declare function deduplicateCandidates(candidates: SetupStepCandidate[]): SetupStepCandidate[];
87
+ //# sourceMappingURL=setup-step-discovery.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setup-step-discovery.d.ts","sourceRoot":"","sources":["../../src/use-cases/setup-step-discovery.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAEvE;;;GAGG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAGpD;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAE7E;AAUD;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAChC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClC;AAoDD;;;;GAIG;AACH,wBAAgB,uBAAuB,CACnC,QAAQ,EAAE,OAAO,GAClB,mBAAmB,EAAE,CA4CvB;AAED;;;;GAIG;AACH,wBAAgB,8BAA8B,CAAC,QAAQ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