fifony 0.1.14-next.b8d8a21 → 0.1.14-next.bc6cdbf

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.
@@ -3948,9 +3948,6 @@ var issues_resource_default = {
3948
3948
  tokensByPhase: "json|optional",
3949
3949
  tokensByModel: "json|optional",
3950
3950
  plan: "json|optional",
3951
- planningStatus: "string|optional",
3952
- planningStartedAt: "datetime|optional",
3953
- planningError: "string|optional",
3954
3951
  linesAdded: "number|optional",
3955
3952
  linesRemoved: "number|optional",
3956
3953
  filesChanged: "number|optional",
@@ -4783,28 +4780,35 @@ async function runProviderCommand(command, provider, prompt, title, description,
4783
4780
  const promptFile = join10(tempDir, "fifony-enhance-prompt.md");
4784
4781
  const issuePayloadFile = join10(tempDir, "fifony-issue.json");
4785
4782
  const resultFile = join10(tempDir, "fifony-result.txt");
4783
+ const envFile = join10(tempDir, "fifony-enhance-env.sh");
4786
4784
  writeFileSync4(promptFile, `${prompt}
4787
4785
  `, "utf8");
4788
4786
  writeFileSync4(issuePayloadFile, JSON.stringify({ title, description, field }, null, 2), "utf8");
4789
- const spawnEnv = {
4790
- ...env8,
4791
- FIFONY_ISSUE_TITLE: title,
4792
- FIFONY_ISSUE_DESCRIPTION: description,
4793
- FIFONY_ENHANCE_FIELD: field,
4794
- FIFONY_PROMPT_FILE: promptFile,
4795
- FIFONY_PROMPT: prompt,
4796
- FIFONY_ISSUE_JSON: issuePayloadFile,
4797
- FIFONY_AGENT_PROVIDER: provider,
4798
- FIFONY_RESULT_FILE: resultFile
4799
- };
4787
+ const envLines = [
4788
+ `export FIFONY_ISSUE_TITLE=${JSON.stringify(title)}`,
4789
+ `export FIFONY_ISSUE_DESCRIPTION=${JSON.stringify(description)}`,
4790
+ `export FIFONY_ENHANCE_FIELD=${JSON.stringify(field)}`,
4791
+ "export FIFONY_PROMPT_FILE=" + JSON.stringify(promptFile),
4792
+ "export FIFONY_PROMPT=" + JSON.stringify(prompt),
4793
+ "export FIFONY_ISSUE_JSON=" + JSON.stringify(issuePayloadFile),
4794
+ "export FIFONY_AGENT_PROVIDER=" + JSON.stringify(provider),
4795
+ "export FIFONY_RESULT_FILE=" + JSON.stringify(resultFile)
4796
+ ];
4797
+ const processEnv = Object.entries(env8).map(([key, value]) => {
4798
+ if (typeof value !== "string") return `export ${key}=${JSON.stringify("")}`;
4799
+ return `export ${key}=${JSON.stringify(value)}`;
4800
+ }).join("\n");
4801
+ writeFileSync4(envFile, `${processEnv}
4802
+ ${envLines.join("\n")}
4803
+ `, "utf8");
4804
+ const wrappedCommand = `. "${envFile}" && ${command}`;
4800
4805
  return await new Promise((resolve4, reject) => {
4801
4806
  const startedAt = Date.now();
4802
4807
  let output = "";
4803
4808
  let timeout = false;
4804
- const child = spawn3(command, {
4809
+ const child = spawn3(wrappedCommand, {
4805
4810
  shell: true,
4806
- cwd: tempDir,
4807
- env: spawnEnv
4811
+ cwd: tempDir
4808
4812
  });
4809
4813
  if (child.stdin) child.stdin.end();
4810
4814
  child.stdout?.on("data", (chunk) => {
@@ -5208,22 +5212,23 @@ async function generatePlan(title, description, config, workflowDefinition, opti
5208
5212
  const prompt = await buildPlanPrompt(title, description, fast);
5209
5213
  const tempDir = mkdtempSync2(join11(tmpdir2(), "fifony-plan-"));
5210
5214
  const promptFile = join11(tempDir, "fifony-plan-prompt.md");
5215
+ const envFile = join11(tempDir, "fifony-plan-env.sh");
5211
5216
  writeFileSync5(promptFile, `${prompt}
5212
5217
  `, "utf8");
5218
+ writeFileSync5(envFile, [
5219
+ `export FIFONY_PROMPT_FILE=${JSON.stringify(promptFile)}`,
5220
+ `export FIFONY_AGENT_PROVIDER=${JSON.stringify(preferred)}`
5221
+ ].join("\n"), "utf8");
5222
+ const wrappedCommand = `. "${envFile}" && ${command}`;
5213
5223
  let lastProgressPersist = 0;
5214
5224
  const PROGRESS_INTERVAL_MS = 2e3;
5215
5225
  const output = await new Promise((resolve4, reject) => {
5216
5226
  let stdout2 = "";
5217
- const child = spawn4(command, {
5227
+ const child = spawn4(wrappedCommand, {
5218
5228
  shell: true,
5219
5229
  cwd: tempDir,
5220
5230
  detached: true,
5221
- stdio: ["pipe", "pipe", "pipe"],
5222
- env: {
5223
- ...process.env,
5224
- FIFONY_PROMPT_FILE: promptFile,
5225
- FIFONY_AGENT_PROVIDER: preferred
5226
- }
5231
+ stdio: ["pipe", "pipe", "pipe"]
5227
5232
  });
5228
5233
  child.unref();
5229
5234
  child.stdin?.end();
@@ -5348,20 +5353,21 @@ async function refinePlan(issue, feedback, config, workflowDefinition) {
5348
5353
  const prompt = await buildRefinePrompt(issue.title, issue.description, issue.plan, feedback);
5349
5354
  const tempDir = mkdtempSync2(join11(tmpdir2(), "fifony-refine-"));
5350
5355
  const promptFile = join11(tempDir, "fifony-refine-prompt.md");
5356
+ const envFile = join11(tempDir, "fifony-refine-env.sh");
5351
5357
  writeFileSync5(promptFile, `${prompt}
5352
5358
  `, "utf8");
5359
+ writeFileSync5(envFile, [
5360
+ `export FIFONY_PROMPT_FILE=${JSON.stringify(promptFile)}`,
5361
+ `export FIFONY_AGENT_PROVIDER=${JSON.stringify(preferred)}`
5362
+ ].join("\n"), "utf8");
5363
+ const wrappedCommand = `. "${envFile}" && ${command}`;
5353
5364
  const output = await new Promise((resolve4, reject) => {
5354
5365
  let stdout2 = "";
5355
- const child = spawn4(command, {
5366
+ const child = spawn4(wrappedCommand, {
5356
5367
  shell: true,
5357
5368
  cwd: tempDir,
5358
5369
  detached: true,
5359
- stdio: ["pipe", "pipe", "pipe"],
5360
- env: {
5361
- ...process.env,
5362
- FIFONY_PROMPT_FILE: promptFile,
5363
- FIFONY_AGENT_PROVIDER: preferred
5364
- }
5370
+ stdio: ["pipe", "pipe", "pipe"]
5365
5371
  });
5366
5372
  child.unref();
5367
5373
  child.stdin?.end();
@@ -5440,14 +5446,12 @@ function generatePlanInBackground(issue, config, workflowDefinition, callbacks,
5440
5446
  const { addEvent: addEvent2, persistState: persistState2, applyUsage, applySuggestions } = callbacks;
5441
5447
  const fast = options?.fast ?? false;
5442
5448
  issue.planningStatus = "planning";
5443
- issue.planningStartedAt = now();
5444
5449
  issue.planningError = void 0;
5445
5450
  issue.updatedAt = now();
5446
5451
  addEvent2(issue.id, "info", `${fast ? "Fast plan" : "Plan"} generation starting for ${issue.identifier} (provider detection in progress).`);
5447
5452
  generatePlan(issue.title, issue.description, config, workflowDefinition, { fast }).then(async ({ plan, usage: usage2 }) => {
5448
5453
  issue.plan = plan;
5449
5454
  issue.planningStatus = "idle";
5450
- issue.planningStartedAt = void 0;
5451
5455
  issue.planningError = void 0;
5452
5456
  issue.updatedAt = now();
5453
5457
  applyUsage(issue, usage2);
@@ -5459,7 +5463,6 @@ function generatePlanInBackground(issue, config, workflowDefinition, callbacks,
5459
5463
  await persistState2();
5460
5464
  }).catch(async (err) => {
5461
5465
  issue.planningStatus = "idle";
5462
- issue.planningStartedAt = void 0;
5463
5466
  issue.planningError = err instanceof Error ? err.message : String(err);
5464
5467
  issue.updatedAt = now();
5465
5468
  addEvent2(issue.id, "error", `Plan generation failed for ${issue.identifier}: ${issue.planningError}`);
@@ -5470,7 +5473,6 @@ function generatePlanInBackground(issue, config, workflowDefinition, callbacks,
5470
5473
  function refinePlanInBackground(issue, feedback, config, workflowDefinition, callbacks) {
5471
5474
  const { addEvent: addEvent2, persistState: persistState2, applyUsage, applySuggestions } = callbacks;
5472
5475
  issue.planningStatus = "refining";
5473
- issue.planningStartedAt = now();
5474
5476
  issue.planningError = void 0;
5475
5477
  issue.updatedAt = now();
5476
5478
  const feedbackSnippet = feedback.length > 60 ? `${feedback.slice(0, 57)}...` : feedback;
@@ -5478,7 +5480,6 @@ function refinePlanInBackground(issue, feedback, config, workflowDefinition, cal
5478
5480
  refinePlan(issue, feedback, config, workflowDefinition).then(async ({ plan, usage: usage2 }) => {
5479
5481
  issue.plan = plan;
5480
5482
  issue.planningStatus = "idle";
5481
- issue.planningStartedAt = void 0;
5482
5483
  issue.planningError = void 0;
5483
5484
  issue.updatedAt = now();
5484
5485
  applyUsage(issue, usage2);
@@ -5491,7 +5492,6 @@ function refinePlanInBackground(issue, feedback, config, workflowDefinition, cal
5491
5492
  await persistState2();
5492
5493
  }).catch(async (err) => {
5493
5494
  issue.planningStatus = "idle";
5494
- issue.planningStartedAt = void 0;
5495
5495
  issue.planningError = err instanceof Error ? err.message : String(err);
5496
5496
  issue.updatedAt = now();
5497
5497
  addEvent2(issue.id, "error", `Plan refinement failed for ${issue.identifier}: ${issue.planningError}`);
@@ -6311,15 +6311,10 @@ async function startApiServer(state, port, workflowDefinition) {
6311
6311
  if (!issue) {
6312
6312
  return c.json({ ok: false, error: "Issue not found" }, 404);
6313
6313
  }
6314
- try {
6315
- await updater(issue);
6316
- await persistState(state);
6317
- wakeScheduler();
6318
- return c.json({ ok: true, issue });
6319
- } catch (error) {
6320
- logger.error({ err: error, issueId }, "[API] mutateIssueState failed");
6321
- return c.json({ ok: false, error: error instanceof Error ? error.message : String(error) }, 500);
6322
- }
6314
+ await updater(issue);
6315
+ await persistState(state);
6316
+ wakeScheduler();
6317
+ return c.json({ ok: true, issue });
6323
6318
  };
6324
6319
  const resourceConfigs = Object.fromEntries(
6325
6320
  NATIVE_RESOURCE_CONFIGS.map((resourceConfig) => [