@lousy-agents/cli 5.0.0 → 5.1.1

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/index.js CHANGED
@@ -31542,6 +31542,34 @@ function defaultExec(command, args, options) {
31542
31542
  return new FileSystemInstructionAnalysisGateway();
31543
31543
  }
31544
31544
 
31545
+ ;// CONCATENATED MODULE: ../core/src/gateways/npmrc-gateway.ts
31546
+ /**
31547
+ * Gateway for reading and writing `.npmrc` configuration files.
31548
+ */
31549
+
31550
+ const MAX_NPMRC_BYTES = 64 * 1024;
31551
+ /**
31552
+ * File system implementation of the NpmrcGateway.
31553
+ */ class FileSystemNpmrcGateway {
31554
+ async readNpmrc(targetDir) {
31555
+ const npmrcPath = await file_system_utils_resolveSafePath(targetDir, ".npmrc");
31556
+ if (!await file_system_utils_fileExists(npmrcPath)) {
31557
+ return null;
31558
+ }
31559
+ await assertFileSizeWithinLimit(npmrcPath, MAX_NPMRC_BYTES, "`.npmrc` file");
31560
+ return (0,promises_.readFile)(npmrcPath, "utf-8");
31561
+ }
31562
+ async writeNpmrc(targetDir, content) {
31563
+ const npmrcPath = await file_system_utils_resolveSafePath(targetDir, ".npmrc");
31564
+ await (0,promises_.writeFile)(npmrcPath, content, "utf-8");
31565
+ }
31566
+ }
31567
+ /**
31568
+ * Creates and returns the default NpmrcGateway.
31569
+ */ function createNpmrcGateway() {
31570
+ return new FileSystemNpmrcGateway();
31571
+ }
31572
+
31545
31573
  ;// CONCATENATED MODULE: ../core/src/entities/feedback-loop.ts
31546
31574
  /**
31547
31575
  * Core domain entities for SDLC feedback loop discovery and validation.
@@ -32281,6 +32309,53 @@ function createWorkflowGateway() {
32281
32309
 
32282
32310
 
32283
32311
 
32312
+
32313
+ ;// CONCATENATED MODULE: ../core/src/use-cases/add-agent-shell.ts
32314
+ /**
32315
+ * Use case for adding agent-shell to an npm project's `.npmrc` configuration.
32316
+ * Enables npm script observability via the agent-shell script-shell shim.
32317
+ */ /**
32318
+ * The script-shell entry added to `.npmrc` to enable agent-shell.
32319
+ * Uses a PATH-resolved binary name so it works independently of local node_modules.
32320
+ */ const AGENT_SHELL_NPMRC_ENTRY = "script-shell=agent-shell";
32321
+ /**
32322
+ * Checks whether `.npmrc` content already has an active (non-comment) script-shell entry.
32323
+ * Lines starting with `#` or `;` are treated as comments and ignored.
32324
+ */ function hasScriptShellEntry(content) {
32325
+ return /^\s*script-shell\s*=/m.test(content);
32326
+ }
32327
+ /**
32328
+ * Adds agent-shell to the project's `.npmrc` if not already configured.
32329
+ * Only operates on npm projects.
32330
+ */ async function addAgentShell(input, npmrcGateway) {
32331
+ if (input.packageManager.type !== "npm") {
32332
+ return {
32333
+ wasAdded: false,
32334
+ alreadyConfigured: false
32335
+ };
32336
+ }
32337
+ const existingContent = await npmrcGateway.readNpmrc(input.targetDir);
32338
+ if (existingContent !== null && hasScriptShellEntry(existingContent)) {
32339
+ return {
32340
+ wasAdded: false,
32341
+ alreadyConfigured: true
32342
+ };
32343
+ }
32344
+ const newEntry = `${AGENT_SHELL_NPMRC_ENTRY}\n`;
32345
+ let updatedContent;
32346
+ if (existingContent !== null) {
32347
+ const separator = existingContent.length > 0 && !existingContent.endsWith("\n") ? "\n" : "";
32348
+ updatedContent = `${existingContent}${separator}${newEntry}`;
32349
+ } else {
32350
+ updatedContent = newEntry;
32351
+ }
32352
+ await npmrcGateway.writeNpmrc(input.targetDir, updatedContent);
32353
+ return {
32354
+ wasAdded: true,
32355
+ alreadyConfigured: false
32356
+ };
32357
+ }
32358
+
32284
32359
  ;// CONCATENATED MODULE: ../core/src/use-cases/check-copilot-review-ruleset.ts
32285
32360
  function isCopilotCodeReviewRule(rule) {
32286
32361
  return rule.type === "copilot_code_review";
@@ -34759,6 +34834,7 @@ const consola = dist_createConsola();
34759
34834
 
34760
34835
 
34761
34836
 
34837
+
34762
34838
  const copilotSetupArgs = {};
34763
34839
  const copilotSetupCommand = defineCommand({
34764
34840
  meta: {
@@ -34772,6 +34848,7 @@ const copilotSetupCommand = defineCommand({
34772
34848
  const workflowGateway = createWorkflowGateway();
34773
34849
  const copilotSetupConfig = await loadCopilotSetupConfig();
34774
34850
  const rulesetGateway = context.data?.rulesetGateway ?? await createGitHubRulesetGateway();
34851
+ const npmrcGateway = context.data?.npmrcGateway ?? createNpmrcGateway();
34775
34852
  const prompt = context.data?.prompt ?? ((message, options)=>consola.prompt(message, options));
34776
34853
  consola.info("Detecting environment configuration...");
34777
34854
  // Step 1: Detect environment configuration files
@@ -34814,7 +34891,7 @@ const copilotSetupCommand = defineCommand({
34814
34891
  const missingCandidates = findMissingCandidates(allCandidates, existingActions);
34815
34892
  if (missingCandidates.length === 0) {
34816
34893
  consola.success("Copilot Setup Steps workflow already contains all detected setup steps. No changes needed.");
34817
- await checkAndPromptRuleset(rulesetGateway, targetDir, prompt);
34894
+ await runPostWorkflowSteps(rulesetGateway, npmrcGateway, targetDir, prompt, environment);
34818
34895
  return;
34819
34896
  }
34820
34897
  const missingNames = missingCandidates.map((c)=>c.action).join(", ");
@@ -34834,8 +34911,8 @@ const copilotSetupCommand = defineCommand({
34834
34911
  consola.info(`Included setup steps: ${actionNames}`);
34835
34912
  }
34836
34913
  }
34837
- // Step 6: Check for Copilot PR review rulesets
34838
- await checkAndPromptRuleset(rulesetGateway, targetDir, prompt);
34914
+ // Step 6: Run post-workflow steps (ruleset + agent-shell)
34915
+ await runPostWorkflowSteps(rulesetGateway, npmrcGateway, targetDir, prompt, environment);
34839
34916
  }
34840
34917
  });
34841
34918
  async function checkAndPromptRuleset(rulesetGateway, targetDir, prompt) {
@@ -34878,6 +34955,33 @@ async function checkAndPromptRuleset(rulesetGateway, targetDir, prompt) {
34878
34955
  consola.error(`Failed to create ruleset: ${message}. You may need admin access to the repository.`);
34879
34956
  }
34880
34957
  }
34958
+ async function runPostWorkflowSteps(rulesetGateway, npmrcGateway, targetDir, prompt, environment) {
34959
+ await checkAndPromptRuleset(rulesetGateway, targetDir, prompt);
34960
+ await checkAndPromptAgentShell(npmrcGateway, targetDir, prompt, environment);
34961
+ }
34962
+ async function checkAndPromptAgentShell(npmrcGateway, targetDir, prompt, environment) {
34963
+ const npmPackageManager = environment.packageManagers.find((pm)=>pm.type === "npm");
34964
+ if (!npmPackageManager) {
34965
+ return;
34966
+ }
34967
+ const shouldAdd = await prompt("Would you like to add agent-shell to observe npm script execution?", {
34968
+ type: "confirm",
34969
+ default: true
34970
+ });
34971
+ if (!shouldAdd) {
34972
+ consola.info("Skipping agent-shell setup.");
34973
+ return;
34974
+ }
34975
+ const result = await addAgentShell({
34976
+ targetDir,
34977
+ packageManager: npmPackageManager
34978
+ }, npmrcGateway);
34979
+ if (result.alreadyConfigured) {
34980
+ consola.success("agent-shell is already configured in .npmrc.");
34981
+ return;
34982
+ }
34983
+ consola.success("Added agent-shell to .npmrc. Run `npm install -g @lousy-agents/agent-shell` to complete setup.");
34984
+ }
34881
34985
 
34882
34986
  ;// CONCATENATED MODULE: ./src/lib/config.ts
34883
34987