agent-trajectories 0.5.9 → 0.6.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.
package/dist/cli/index.js CHANGED
@@ -587,6 +587,14 @@ var TRAJECTORY_FILE = "trajectory.json";
587
587
  var SUMMARY_FILE = "summary.md";
588
588
  var COMPACTION_FILE = "compaction.json";
589
589
  var LEGACY_COMPACTION_SUFFIX = ".compaction.json";
590
+ var DEFAULT_TRAJECTORY_DATA_DIR = join(
591
+ ".agentworkforce",
592
+ "trajectories"
593
+ );
594
+ var LEGACY_TRAJECTORY_DATA_DIR = ".trajectories";
595
+ function getDefaultTrajectoryDataDir(baseDir = process.cwd()) {
596
+ return join(baseDir, DEFAULT_TRAJECTORY_DATA_DIR);
597
+ }
590
598
  function expandPath(path2) {
591
599
  if (path2.startsWith("~")) {
592
600
  return join(process.env.HOME ?? "", path2.slice(1));
@@ -602,7 +610,7 @@ function getSearchPaths() {
602
610
  if (dataDir) {
603
611
  return [expandPath(dataDir)];
604
612
  }
605
- return [join(process.cwd(), ".trajectories")];
613
+ return [getDefaultTrajectoryDataDir()];
606
614
  }
607
615
  function describeReadFailure(reason, error) {
608
616
  if (reason === "schema_violation" && error && typeof error === "object" && "issues" in error) {
@@ -624,13 +632,15 @@ var FileStorage = class {
624
632
  activeDir;
625
633
  completedDir;
626
634
  lastReconcileSummary;
635
+ shouldMigrateLegacyDefault = false;
627
636
  constructor(baseDir) {
628
637
  this.baseDir = baseDir ?? process.cwd();
629
638
  const dataDir = process.env.TRAJECTORIES_DATA_DIR;
630
639
  if (dataDir) {
631
640
  this.trajectoriesDir = expandPath(dataDir);
632
641
  } else {
633
- this.trajectoriesDir = join(this.baseDir, ".trajectories");
642
+ this.trajectoriesDir = getDefaultTrajectoryDataDir(this.baseDir);
643
+ this.shouldMigrateLegacyDefault = true;
634
644
  }
635
645
  this.activeDir = join(this.trajectoriesDir, "active");
636
646
  this.completedDir = join(this.trajectoriesDir, "completed");
@@ -639,6 +649,7 @@ var FileStorage = class {
639
649
  * Initialize storage directories
640
650
  */
641
651
  async initialize() {
652
+ await this.migrateLegacyDefaultDir();
642
653
  await mkdir(this.trajectoriesDir, { recursive: true });
643
654
  await mkdir(this.activeDir, { recursive: true });
644
655
  await mkdir(this.completedDir, { recursive: true });
@@ -646,6 +657,17 @@ var FileStorage = class {
646
657
  await rm(join(this.trajectoriesDir, "index.json"), { force: true });
647
658
  await this.reconcileIndex();
648
659
  }
660
+ async migrateLegacyDefaultDir() {
661
+ if (!this.shouldMigrateLegacyDefault) {
662
+ return;
663
+ }
664
+ const legacyDir = join(this.baseDir, LEGACY_TRAJECTORY_DATA_DIR);
665
+ if (!existsSync(legacyDir) || existsSync(this.trajectoriesDir)) {
666
+ return;
667
+ }
668
+ await mkdir(dirname(this.trajectoriesDir), { recursive: true });
669
+ await rename(legacyDir, this.trajectoriesDir);
670
+ }
649
671
  /**
650
672
  * Scan active/ and completed/ recursively and report trajectory files
651
673
  * that can be loaded plus files that should be surfaced by doctor.
@@ -716,7 +738,7 @@ var FileStorage = class {
716
738
  return this.lastReconcileSummary;
717
739
  }
718
740
  /**
719
- * Move trajectory files that fail to load into `.trajectories/invalid/`
741
+ * Move trajectory files that fail to load into `.agentworkforce/trajectories/invalid/`
720
742
  * so reconcile no longer scans them. Only quarantines parse and schema
721
743
  * failures — transient io_error failures are left in place because the
722
744
  * file may load fine on the next attempt.
@@ -1471,7 +1493,7 @@ function loadFileConfig() {
1471
1493
  }
1472
1494
  function getPrimaryConfigDir() {
1473
1495
  const searchPaths = getSearchPaths();
1474
- return searchPaths[0] ?? join2(process.cwd(), ".trajectories");
1496
+ return searchPaths[0] ?? getDefaultTrajectoryDataDir();
1475
1497
  }
1476
1498
  function readStringEnv(name) {
1477
1499
  return readString(process.env[name]);
@@ -3061,7 +3083,7 @@ function getProviderLabel(provider) {
3061
3083
  return "LLM";
3062
3084
  }
3063
3085
  function getDefaultOutputPath(compacted, workflowId) {
3064
- const trajDir = process.env.TRAJECTORIES_DATA_DIR || ".trajectories";
3086
+ const trajDir = process.env.TRAJECTORIES_DATA_DIR || getDefaultTrajectoryDataDir();
3065
3087
  const compactedDir = join4(trajDir, "compacted");
3066
3088
  if (!existsSync3(compactedDir)) {
3067
3089
  mkdirSync(compactedDir, { recursive: true });
@@ -3477,7 +3499,7 @@ if [ "$COMMIT_SOURCE" = "merge" ] || [ "$COMMIT_SOURCE" = "squash" ] || [ "$COMM
3477
3499
  fi
3478
3500
 
3479
3501
  # Find the trajectories data directory
3480
- TRAJ_DIR="\${TRAJECTORIES_DATA_DIR:-$(git rev-parse --show-toplevel)/.trajectories}"
3502
+ TRAJ_DIR="\${TRAJECTORIES_DATA_DIR:-$(git rev-parse --show-toplevel)/.agentworkforce/trajectories}"
3481
3503
  ACTIVE_DIR="$TRAJ_DIR/active"
3482
3504
 
3483
3505
  # Check if there's an active trajectory
@@ -3537,7 +3559,7 @@ function detectExistingHook() {
3537
3559
  // src/cli/commands/complete.ts
3538
3560
  async function saveTraceFile(trajectory, trace) {
3539
3561
  const dataDir = process.env.TRAJECTORIES_DATA_DIR;
3540
- const baseDir = dataDir ? dataDir : join5(process.cwd(), ".trajectories");
3562
+ const baseDir = dataDir ? dataDir : getDefaultTrajectoryDataDir();
3541
3563
  const completedDir = join5(baseDir, "completed");
3542
3564
  const date = new Date(trajectory.completedAt ?? trajectory.startedAt);
3543
3565
  const monthDir = join5(
@@ -3665,7 +3687,7 @@ function registerDoctorCommand(program2) {
3665
3687
  "List trajectory files that fail to load; optionally quarantine them"
3666
3688
  ).option(
3667
3689
  "--quarantine",
3668
- "Move invalid files to .trajectories/invalid/ so reconcile stops scanning them"
3690
+ "Move invalid files to .agentworkforce/trajectories/invalid/ so reconcile stops scanning them"
3669
3691
  ).action(async (opts) => {
3670
3692
  const storage = new FileStorage();
3671
3693
  await storage.initialize();
@@ -3683,7 +3705,7 @@ function registerDoctorCommand(program2) {
3683
3705
  }
3684
3706
  if (!opts.quarantine) {
3685
3707
  console.log(
3686
- "\nRun `trail doctor --quarantine` to move these files into .trajectories/invalid/."
3708
+ "\nRun `trail doctor --quarantine` to move these files into .agentworkforce/trajectories/invalid/."
3687
3709
  );
3688
3710
  return;
3689
3711
  }
@@ -4487,7 +4509,10 @@ function registerExportCommand(program2) {
4487
4509
  openInBrowser(options.output);
4488
4510
  }
4489
4511
  } else if (options.open && options.format === "html") {
4490
- const outputDir = join7(process.cwd(), ".trajectories", "html");
4512
+ const outputDir = join7(
4513
+ process.env.TRAJECTORIES_DATA_DIR ?? getDefaultTrajectoryDataDir(),
4514
+ "html"
4515
+ );
4491
4516
  await mkdir4(outputDir, { recursive: true });
4492
4517
  const filePath = join7(outputDir, `${trajectory.id}.html`);
4493
4518
  await writeFile4(filePath, output, "utf-8");