@autonoma-ai/planner 0.1.27 → 0.1.28

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
@@ -5314,8 +5314,7 @@ __export(coding_agent_exports, {
5314
5314
  buildAllLaunchers: () => buildAllLaunchers,
5315
5315
  isSpawnedByPlanner: () => isSpawnedByPlanner2,
5316
5316
  parsePermissionMode: () => parsePermissionMode,
5317
- selectLauncher: () => selectLauncher,
5318
- selectPermissionMode: () => selectPermissionMode
5317
+ selectLauncher: () => selectLauncher
5319
5318
  });
5320
5319
  import spawn from "cross-spawn";
5321
5320
  import which from "which";
@@ -5359,20 +5358,6 @@ async function selectLauncher(launchers, presetId, interactive = true) {
5359
5358
  await updatePreferences({ agentId: selected });
5360
5359
  return available.find((l) => l.id === selected);
5361
5360
  }
5362
- async function selectPermissionMode(preset) {
5363
- if (preset != null) return preset;
5364
- const selected = await select({
5365
- message: "How much autonomy should the agent have?",
5366
- options: [
5367
- { value: "bypassPermissions", label: PERMISSION_MODE_LABELS.bypassPermissions },
5368
- { value: "acceptEdits", label: PERMISSION_MODE_LABELS.acceptEdits },
5369
- { value: "default", label: PERMISSION_MODE_LABELS.default }
5370
- ],
5371
- initialValue: DEFAULT_PERMISSION_MODE
5372
- });
5373
- if (isCancel(selected)) throw new Error("Permission mode selection cancelled");
5374
- return selected;
5375
- }
5376
5361
  function parsePermissionMode(value) {
5377
5362
  if (value === "default" || value === "acceptEdits" || value === "bypassPermissions") return value;
5378
5363
  return void 0;
@@ -6242,6 +6227,37 @@ var init_interrupt = __esm({
6242
6227
  }
6243
6228
  });
6244
6229
 
6230
+ // src/core/permission-mode.ts
6231
+ async function resolvePermissionMode(request) {
6232
+ const known = request.preset ?? runPermissionMode ?? request.remembered;
6233
+ if (known != null) {
6234
+ runPermissionMode = known;
6235
+ return known;
6236
+ }
6237
+ if (!request.interactive) return DEFAULT_PERMISSION_MODE;
6238
+ const selected = await select({
6239
+ message: "How much autonomy should the agent have?",
6240
+ options: [
6241
+ { value: "bypassPermissions", label: PERMISSION_MODE_LABELS.bypassPermissions },
6242
+ { value: "acceptEdits", label: PERMISSION_MODE_LABELS.acceptEdits },
6243
+ { value: "default", label: PERMISSION_MODE_LABELS.default }
6244
+ ],
6245
+ initialValue: DEFAULT_PERMISSION_MODE
6246
+ });
6247
+ if (isCancel(selected)) throw new Error("Permission mode selection cancelled");
6248
+ runPermissionMode = selected;
6249
+ return selected;
6250
+ }
6251
+ var runPermissionMode;
6252
+ var init_permission_mode = __esm({
6253
+ "src/core/permission-mode.ts"() {
6254
+ "use strict";
6255
+ init_esm_shims();
6256
+ init_prompts();
6257
+ init_coding_agent();
6258
+ }
6259
+ });
6260
+
6245
6261
  // src/core/preview-phase.ts
6246
6262
  function previewPrompt(code, interactive) {
6247
6263
  const instruction = `set up my preview environments with the ${MCP_SERVER_NAME} MCP, code ${code}`;
@@ -6461,8 +6477,10 @@ async function runPreviewHandoff(deps) {
6461
6477
  captureLog("warn", "No coding agent available for the preview phase", { source: "front_door" });
6462
6478
  return { kind: "no-agent" };
6463
6479
  }
6464
- const preset = parsePermissionMode(config.permissionMode);
6465
- const permissionMode = interactive ? await selectPermissionMode(preset) : preset ?? DEFAULT_PERMISSION_MODE;
6480
+ const permissionMode = await resolvePermissionMode({
6481
+ preset: parsePermissionMode(config.permissionMode),
6482
+ interactive
6483
+ });
6466
6484
  suspend();
6467
6485
  let outcome;
6468
6486
  try {
@@ -6504,8 +6522,10 @@ async function runSdkRepairHandoff(deps) {
6504
6522
  captureLog("warn", "No coding agent available for the SDK repair phase", { source: "front_door" });
6505
6523
  return void 0;
6506
6524
  }
6507
- const preset = parsePermissionMode(config.permissionMode);
6508
- const permissionMode = interactive ? await selectPermissionMode(preset) : preset ?? DEFAULT_PERMISSION_MODE;
6525
+ const permissionMode = await resolvePermissionMode({
6526
+ preset: parsePermissionMode(config.permissionMode),
6527
+ interactive
6528
+ });
6509
6529
  suspend();
6510
6530
  try {
6511
6531
  return await runSdkRepairPhase({
@@ -6540,6 +6560,7 @@ var init_front_door = __esm({
6540
6560
  init_interrupt();
6541
6561
  init_logs();
6542
6562
  init_onboarding_phase();
6563
+ init_permission_mode();
6543
6564
  init_preview_phase();
6544
6565
  init_sdk_repair_phase();
6545
6566
  }
@@ -9839,7 +9860,11 @@ async function runHandoffPhase(state, deps, outputDir) {
9839
9860
  }
9840
9861
  return manualFallback(outputDir, recipePath, deps.cliCommand, NO_AGENT_FOUND);
9841
9862
  }
9842
- const permissionMode = deps.interactive ? await selectPermissionMode(state.permissionMode ?? deps.presetPermissionMode) : state.permissionMode ?? deps.presetPermissionMode ?? DEFAULT_PERMISSION_MODE;
9863
+ const permissionMode = await resolvePermissionMode({
9864
+ preset: deps.presetPermissionMode,
9865
+ remembered: state.permissionMode,
9866
+ interactive: deps.interactive
9867
+ });
9843
9868
  state.agentId = launcher.id;
9844
9869
  state.permissionMode = permissionMode;
9845
9870
  await saveRecipeState(outputDir, state);
@@ -9983,6 +10008,7 @@ var init_handoff = __esm({
9983
10008
  init_debug();
9984
10009
  init_interrupt();
9985
10010
  init_notify();
10011
+ init_permission_mode();
9986
10012
  init_prompts();
9987
10013
  init_completion();
9988
10014
  init_completion_watch();
@@ -11251,12 +11277,12 @@ When done reviewing, call finish with your structured evaluation.`
11251
11277
  });
11252
11278
 
11253
11279
  // src/agents/05-test-generator/review-pass.ts
11254
- import { basename as basename4 } from "path";
11280
+ import { basename as basename5 } from "path";
11255
11281
  import "ai";
11256
11282
  import { tool as tool15 } from "ai";
11257
11283
  async function runReviewPass(testContent, testPath, rubric, projectRoot, model, scenarioData) {
11258
11284
  let result;
11259
- const agentLabel = `review:${rubric.name}:${basename4(testPath)}`;
11285
+ const agentLabel = `review:${rubric.name}:${basename5(testPath)}`;
11260
11286
  const { onStepFinish } = buildDefaultStepLogger(agentLabel, rubric.maxSteps);
11261
11287
  const finishTool = tool15({
11262
11288
  description: "Submit your structured review. Every dimension must have evidence from your investigation.",
@@ -11322,7 +11348,7 @@ var init_review_pass = __esm({
11322
11348
 
11323
11349
  // src/agents/05-test-generator/review.ts
11324
11350
  import { readFile as readFile21 } from "fs/promises";
11325
- import { join as join33, relative as relative7, basename as basename5 } from "path";
11351
+ import { join as join33, relative as relative7, basename as basename6 } from "path";
11326
11352
  import "ai";
11327
11353
  import { glob as glob5 } from "glob";
11328
11354
  function markReview(relativePath, status) {
@@ -11360,7 +11386,7 @@ async function reviewOneTest({
11360
11386
  dataContract
11361
11387
  ).catch((err) => {
11362
11388
  console.warn(
11363
- ` [review] ${rubric.name} error on ${basename5(test.relativePath)}: ${err instanceof Error ? err.message : String(err)}`
11389
+ ` [review] ${rubric.name} error on ${basename6(test.relativePath)}: ${err instanceof Error ? err.message : String(err)}`
11364
11390
  );
11365
11391
  return void 0;
11366
11392
  });
@@ -11439,7 +11465,7 @@ async function runConsolidatedReview(outputDir, projectRoot, model, deadline, se
11439
11465
  );
11440
11466
  for (const { item, error } of outcome.failed) {
11441
11467
  console.warn(
11442
- ` [review] ${item.rubric.name} error on ${basename5(item.test.path)}: ${error instanceof Error ? error.message : String(error)}`
11468
+ ` [review] ${item.rubric.name} error on ${basename6(item.test.path)}: ${error instanceof Error ? error.message : String(error)}`
11443
11469
  );
11444
11470
  }
11445
11471
  const record = (relativePath, rubricName, result) => {
@@ -12079,7 +12105,7 @@ __export(test_generator_exports, {
12079
12105
  });
12080
12106
  import { existsSync as existsSync2 } from "fs";
12081
12107
  import { mkdir as mkdir6, readFile as readFile23, rmdir, unlink, writeFile as writeFile15 } from "fs/promises";
12082
- import { basename as basename6, join as join36 } from "path";
12108
+ import { basename as basename7, join as join36 } from "path";
12083
12109
  import { tool as tool17 } from "ai";
12084
12110
  import { glob as glob6 } from "glob";
12085
12111
  import { z as z56 } from "zod";
@@ -12484,7 +12510,7 @@ IMPORTANT: Do NOT try to finish early. Process every node via next_node until it
12484
12510
  if (!validation.valid) {
12485
12511
  const invalidDir = join36(input.outputDir, TESTS_DIR, INVALID_DIR);
12486
12512
  await mkdir6(invalidDir, { recursive: true });
12487
- const dest = join36(invalidDir, basename6(testPath));
12513
+ const dest = join36(invalidDir, basename7(testPath));
12488
12514
  const annotated = `<!-- VALIDATION ERRORS: ${validation.errors.join("; ")} -->
12489
12515
  ${content}`;
12490
12516
  await writeFile15(dest, annotated, "utf-8");
@@ -15680,6 +15706,24 @@ init_front_door();
15680
15706
  // src/core/help.ts
15681
15707
  init_esm_shims();
15682
15708
  init_colors();
15709
+
15710
+ // src/core/self-invocation.ts
15711
+ init_esm_shims();
15712
+ import { basename as basename4, sep } from "path";
15713
+ var NPX_INVOCATION = "npx @autonoma-ai/planner@latest";
15714
+ var BIN_NAME = "autonoma-planner";
15715
+ function selfInvocation(argv = process.argv, execPath = process.execPath) {
15716
+ const scriptPath = argv[1];
15717
+ if (scriptPath == null || scriptPath === "") return NPX_INVOCATION;
15718
+ if (basename4(scriptPath) === BIN_NAME) return BIN_NAME;
15719
+ if (isNpxCachePath(scriptPath)) return NPX_INVOCATION;
15720
+ return `${execPath} ${scriptPath}`;
15721
+ }
15722
+ function isNpxCachePath(scriptPath) {
15723
+ return scriptPath.split(sep).includes("_npx");
15724
+ }
15725
+
15726
+ // src/core/help.ts
15683
15727
  var DOCS_URL = "https://docs.autonoma.app/test-planner/";
15684
15728
  var LLMS_URL = "https://docs.autonoma.app/llms.txt";
15685
15729
  var LLMS_FULL_URL = "https://docs.autonoma.app/llms-full.txt";
@@ -15782,18 +15826,27 @@ var ENVIRONMENT = [
15782
15826
  " up the preview environment and validates the result; leave it unset",
15783
15827
  " and the planner runs standalone against any repository.",
15784
15828
  " AUTONOMA_API_URL Point at a non-production Autonoma. Defaults to production.",
15785
- " AUTONOMA_DEBUG Set to anything for verbose diagnostics on stderr.",
15786
- " DONT_TRACK Set to anything to turn off analytics, logs and session replay."
15829
+ // Both are read as `1`/`true` exactly (core/posthog.ts, core/debug-sink.ts), so
15830
+ // "set to anything" invites DONT_TRACK=0 - which reads as opted IN.
15831
+ " AUTONOMA_DEBUG Set to 1 or true for diagnostics on stderr, plus a full JSONL",
15832
+ " transcript at ~/.autonoma/debug/<run-id>.jsonl.",
15833
+ " AUTONOMA_DEBUG_FILE Write that transcript to this path instead, without the stderr",
15834
+ " noise. Independent of DONT_TRACK - it never leaves your machine.",
15835
+ " DONT_TRACK Set to 1 or true to turn off analytics, logs and session replay."
15787
15836
  ];
15788
15837
  function renderHelp() {
15838
+ const self = selfInvocation();
15789
15839
  return [
15790
- `${BOLD}autonoma-planner${RESET} - generate an end-to-end test suite from your codebase`,
15840
+ `${BOLD}@autonoma-ai/planner${RESET} - generate an end-to-end test suite from your codebase`,
15791
15841
  "",
15842
+ // Spelled the way this run was actually reached. Almost everyone arrives via
15843
+ // npx, which installs nothing on PATH, so a synopsis written as a bare
15844
+ // `autonoma-planner` teaches a command the reader does not have.
15792
15845
  `${BOLD}USAGE${RESET}`,
15793
- " autonoma-planner [run] [flags] Plan and generate the suite. `run` may be omitted.",
15794
- " autonoma-planner status Show what a previous run completed.",
15795
- " autonoma-planner upload Re-upload an already-generated suite.",
15796
- " autonoma-planner help Print this.",
15846
+ ` ${self} [run] [flags] Plan and generate the suite. \`run\` may be omitted.`,
15847
+ ` ${self} status Show what a previous run completed.`,
15848
+ ` ${self} upload Re-upload an already-generated suite.`,
15849
+ ` ${self} help Print this.`,
15797
15850
  "",
15798
15851
  `${BOLD}WHAT IT DOES${RESET}`,
15799
15852
  ...WHAT_IT_DOES.map(indent),
@@ -16441,7 +16494,8 @@ async function main() {
16441
16494
  }
16442
16495
  console.log(BANNER);
16443
16496
  const projectArg = args.value("project");
16444
- const resumeCommand = `autonoma-planner --resume` + (projectArg != null ? ` --project ${projectArg}` : "");
16497
+ const self = selfInvocation();
16498
+ const resumeCommand = `${self} --resume` + (projectArg != null ? ` --project ${projectArg}` : "");
16445
16499
  let mountedUi;
16446
16500
  let stoppedAt;
16447
16501
  installInterruptHandler({
@@ -16591,7 +16645,7 @@ or reveal hidden files (macOS: Cmd+Shift+. ) to see it.`,
16591
16645
  mountedUi?.unmount();
16592
16646
  mountedUi = void 0;
16593
16647
  if (state.steps[targetStep] === "failed") {
16594
- const retryCommand = `autonoma-planner --step ${targetStep}` + (projectArg != null ? ` --project ${projectArg}` : "");
16648
+ const retryCommand = `${self} --step ${targetStep}` + (projectArg != null ? ` --project ${projectArg}` : "");
16595
16649
  log.warn(`Your progress is saved. To retry this step, run:
16596
16650
  ${retryCommand}`);
16597
16651
  process.exitCode = 1;