poe-code 3.0.136 → 3.0.138

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
@@ -14620,6 +14620,48 @@ var init_require_comment_prefix = __esm({
14620
14620
  }
14621
14621
  });
14622
14622
 
14623
+ // packages/github-workflows/src/setup-agent.ts
14624
+ function formatCommand2(command, args) {
14625
+ return [command, ...args].join(" ");
14626
+ }
14627
+ function trimOutput(value) {
14628
+ return value.trim();
14629
+ }
14630
+ function resolveWorkflowAgent(automation) {
14631
+ const configured = automation.agent?.trim();
14632
+ return configured && configured.length > 0 ? configured : "codex";
14633
+ }
14634
+ function formatCommandFailure(command, args, result) {
14635
+ const stderr = trimOutput(result.stderr);
14636
+ const stdout = trimOutput(result.stdout);
14637
+ return [
14638
+ `Command failed with exit code ${result.exitCode}: ${formatCommand2(command, args)}`,
14639
+ stderr.length > 0 ? `stderr:
14640
+ ${stderr}` : null,
14641
+ stdout.length > 0 ? `stdout:
14642
+ ${stdout}` : null
14643
+ ].filter((value) => value !== null).join("\n");
14644
+ }
14645
+ async function runPoeCodeCommand(args, cwd, runner) {
14646
+ const result = await runner("poe-code", args, { cwd });
14647
+ if (result.exitCode !== 0) {
14648
+ throw new UserError(formatCommandFailure("poe-code", args, result));
14649
+ }
14650
+ }
14651
+ async function setupWorkflowAgent(automation, cwd, runner = runCommand) {
14652
+ const agent2 = resolveWorkflowAgent(automation);
14653
+ await runPoeCodeCommand(["install", agent2, "--yes"], cwd, runner);
14654
+ await runPoeCodeCommand(["configure", agent2, "--yes"], cwd, runner);
14655
+ return agent2;
14656
+ }
14657
+ var init_setup_agent = __esm({
14658
+ "packages/github-workflows/src/setup-agent.ts"() {
14659
+ "use strict";
14660
+ init_src7();
14661
+ init_src16();
14662
+ }
14663
+ });
14664
+
14623
14665
  // packages/github-workflows/src/commands.ts
14624
14666
  import { access, mkdir as mkdir10, readFile as readFile9, unlink as unlink2, writeFile as writeFile6 } from "node:fs/promises";
14625
14667
  import path28 from "node:path";
@@ -14856,7 +14898,7 @@ async function selectAutomationName(message2, automations) {
14856
14898
  }
14857
14899
  return selected;
14858
14900
  }
14859
- var UPSTREAM_REPO, builtInPromptsDirCandidates, builtInWorkflowTemplatesDirCandidates, originalMustacheEscape, installableAutomations, runCommandDef, listCommand, installCommand, uninstallCommand, checkUserAllowCommand, requireCommentPrefixCommand, promptPreviewCommand, execGroup, ghGroup;
14901
+ var UPSTREAM_REPO, builtInPromptsDirCandidates, builtInWorkflowTemplatesDirCandidates, originalMustacheEscape, installableAutomations, runCommandDef, listCommand, installCommand, uninstallCommand, requireUserAllowCommand, requireCommentPrefixCommand, prepareCommand, promptPreviewCommand, ghGroup;
14860
14902
  var init_commands = __esm({
14861
14903
  "packages/github-workflows/src/commands.ts"() {
14862
14904
  "use strict";
@@ -14867,6 +14909,7 @@ var init_commands = __esm({
14867
14909
  init_discover();
14868
14910
  init_check_user_allow();
14869
14911
  init_require_comment_prefix();
14912
+ init_setup_agent();
14870
14913
  UPSTREAM_REPO = "poe-platform/poe-code";
14871
14914
  builtInPromptsDirCandidates = [
14872
14915
  fileURLToPath4(new URL("./prompts", import.meta.url)),
@@ -15010,14 +15053,12 @@ var init_commands = __esm({
15010
15053
  const automations = await discoverAutomations(await resolveBuiltInPromptsDir());
15011
15054
  return automations.map((a) => ({ label: a.label ?? formatLabel(a.name), value: a.name }));
15012
15055
  }
15013
- }),
15014
- eject: S2.Optional(S2.Boolean())
15056
+ })
15015
15057
  }),
15016
15058
  scope: ["cli"],
15017
15059
  handler: async ({ params }) => {
15018
15060
  const name = params.name;
15019
- const isEject = params.eject === true;
15020
- const variant = isEject ? "ejected" : "caller";
15061
+ const variant = "ejected";
15021
15062
  const [workflowTemplate, rawPrompt] = await Promise.all([
15022
15063
  readBuiltInWorkflowTemplate(name, variant),
15023
15064
  readBuiltInPromptFile(name)
@@ -15026,30 +15067,21 @@ var init_commands = __esm({
15026
15067
  const workflowPath = path28.join(cwd, ".github", "workflows", `poe-code-${name}.yml`);
15027
15068
  await mkdir10(path28.dirname(workflowPath), { recursive: true });
15028
15069
  await writeFile6(workflowPath, workflowTemplate, "utf8");
15029
- let promptPath;
15030
- if (isEject) {
15031
- promptPath = path28.join(projectPromptsDir(cwd), `poe-code-${name}.md`);
15032
- await mkdir10(path28.dirname(promptPath), { recursive: true });
15033
- await writeFile6(promptPath, addPromptHeader(rawPrompt, name), "utf8");
15034
- }
15070
+ const promptPath = path28.join(projectPromptsDir(cwd), `poe-code-${name}.md`);
15071
+ await mkdir10(path28.dirname(promptPath), { recursive: true });
15072
+ await writeFile6(promptPath, addPromptHeader(rawPrompt, name), "utf8");
15035
15073
  return {
15036
15074
  name,
15037
15075
  workflowPath,
15038
15076
  promptPath,
15039
- ejected: isEject,
15040
15077
  promptContent: rawPrompt
15041
15078
  };
15042
15079
  },
15043
15080
  render: {
15044
15081
  rich: (result, { logger: logger2, note: note2 }) => {
15045
15082
  logger2.success(`Installed workflow at ${result.workflowPath}`);
15046
- if (result.promptPath !== void 0) {
15047
- logger2.message(`Prompt copied to ${result.promptPath}`);
15048
- }
15083
+ logger2.message(`Prompt copied to ${result.promptPath}`);
15049
15084
  note2(result.promptContent, "Default prompt");
15050
- if (!result.ejected) {
15051
- logger2.message(`To customize the prompt, run: poe-code github-workflows install ${result.name} --eject`);
15052
- }
15053
15085
  },
15054
15086
  json: (result) => result
15055
15087
  }
@@ -15089,8 +15121,8 @@ var init_commands = __esm({
15089
15121
  json: (result) => result
15090
15122
  }
15091
15123
  });
15092
- checkUserAllowCommand = defineCommand({
15093
- name: "check-user-allow",
15124
+ requireUserAllowCommand = defineCommand({
15125
+ name: "require-user-allow",
15094
15126
  description: "Fail when COMMENT_AUTHOR_ASSOCIATION is not allowed by the automation frontmatter.",
15095
15127
  positional: ["name"],
15096
15128
  params: S2.Object({
@@ -15117,6 +15149,27 @@ var init_commands = __esm({
15117
15149
  return null;
15118
15150
  }
15119
15151
  });
15152
+ prepareCommand = defineCommand({
15153
+ name: "prepare",
15154
+ description: "Install and configure the agent required by a workflow automation.",
15155
+ positional: ["name"],
15156
+ params: S2.Object({
15157
+ name: S2.String()
15158
+ }),
15159
+ scope: ["cli"],
15160
+ handler: async ({ params }) => {
15161
+ const cwd = resolveCwd();
15162
+ const automation = await loadNamedAutomation(params.name, cwd);
15163
+ const agent2 = await setupWorkflowAgent(automation, cwd);
15164
+ return { agent: agent2, automation: automation.name };
15165
+ },
15166
+ render: {
15167
+ rich: (result, { logger: logger2 }) => {
15168
+ logger2.success(`Prepared agent "${result.agent}" for automation "${result.automation}".`);
15169
+ },
15170
+ json: (result) => result
15171
+ }
15172
+ });
15120
15173
  promptPreviewCommand = defineCommand({
15121
15174
  name: "prompt-preview",
15122
15175
  description: "Preview the resolved prompt for an automation.",
@@ -15136,17 +15189,20 @@ var init_commands = __esm({
15136
15189
  json: (result) => result
15137
15190
  }
15138
15191
  });
15139
- execGroup = defineGroup({
15140
- name: "exec",
15141
- description: "Workflow step helpers.",
15142
- scope: ["cli"],
15143
- children: [checkUserAllowCommand, requireCommentPrefixCommand]
15144
- });
15145
15192
  ghGroup = defineGroup({
15146
15193
  name: "github-workflows",
15147
15194
  aliases: ["gh"],
15148
15195
  description: "GitHub workflow automations.",
15149
- children: [runCommandDef, listCommand, installCommand, uninstallCommand, promptPreviewCommand, execGroup],
15196
+ children: [
15197
+ runCommandDef,
15198
+ prepareCommand,
15199
+ requireUserAllowCommand,
15200
+ requireCommentPrefixCommand,
15201
+ listCommand,
15202
+ installCommand,
15203
+ uninstallCommand,
15204
+ promptPreviewCommand
15205
+ ],
15150
15206
  default: runCommandDef
15151
15207
  });
15152
15208
  }
@@ -15512,9 +15568,9 @@ async function runServiceInstall(definition, context) {
15512
15568
  return true;
15513
15569
  }
15514
15570
  function describeInstallCommand(step) {
15515
- return `[${step.id}] ${formatCommand2(step.command, step.args)}`;
15571
+ return `[${step.id}] ${formatCommand3(step.command, step.args)}`;
15516
15572
  }
15517
- function formatCommand2(command, args) {
15573
+ function formatCommand3(command, args) {
15518
15574
  return [command, ...args.map(quoteIfNeeded)].join(" ");
15519
15575
  }
15520
15576
  function quoteIfNeeded(value) {
@@ -28016,7 +28072,7 @@ var init_package = __esm({
28016
28072
  "package.json"() {
28017
28073
  package_default = {
28018
28074
  name: "poe-code",
28019
- version: "3.0.136",
28075
+ version: "3.0.138",
28020
28076
  description: "CLI tool to configure Poe API for developer workflows.",
28021
28077
  type: "module",
28022
28078
  main: "./dist/index.js",