@karmaniverous/stan-cli 0.12.0 → 0.12.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/cli/stan.js CHANGED
@@ -18664,16 +18664,60 @@ const readExistingConfig = async (existingPath) => {
18664
18664
  }
18665
18665
  };
18666
18666
 
18667
+ // src/runner/selection/implicit-imports.ts
18668
+ /**
18669
+ * Implicit selection helpers for STAN's staged imports.
18670
+ *
18671
+ * Policy:
18672
+ * - <stanPath>/imports/ is gitignored by default (stan init).
18673
+ * - The CLI must still include <stanPath>/imports/** automatically in:
18674
+ * - snapshot baselines (stan init / stan snap),
18675
+ * - archive creation (full + diff),
18676
+ * so that changes to staged imports show up in archive.diff.tar without
18677
+ * requiring users to declare includes in config.
18678
+ *
18679
+ * Option A semantics:
18680
+ * - Implemented as an additive include pattern.
18681
+ * - Users can still opt out by explicitly excluding <stanPath>/imports/**.
18682
+ */
18683
+ const posix$1 = (p) => p.replace(/\\+/g, '/');
18684
+ const normalizeStanPath = (stanPath) => {
18685
+ const raw = typeof stanPath === 'string' ? stanPath.trim() : '';
18686
+ const cleaned = posix$1(raw).replace(/\/+$/, '');
18687
+ if (cleaned.length > 0) {
18688
+ return cleaned;
18689
+ }
18690
+ if (raw.startsWith('/')) {
18691
+ return ''; // Handle root path
18692
+ }
18693
+ return '.stan'; // Default for empty/whitespace
18694
+ };
18695
+ const implicitImportsInclude = (stanPath) => {
18696
+ const sp = normalizeStanPath(stanPath);
18697
+ return `${sp}/imports/**`;
18698
+ };
18699
+ /**
18700
+ * Append the implicit imports include (if missing) while preserving order.
18701
+ */
18702
+ const withImplicitImportsInclude = (stanPath, includes) => {
18703
+ const base = Array.isArray(includes)
18704
+ ? includes.filter((s) => typeof s === 'string' && s.length > 0)
18705
+ : [];
18706
+ const pattern = implicitImportsInclude(stanPath);
18707
+ return base.includes(pattern) ? base : [...base, pattern];
18708
+ };
18709
+
18667
18710
  // src/runner/init/service/snapshot.ts
18668
18711
  const snapshotPath = (cwd, stanPath) => path.join(cwd, stanPath, 'diff', '.archive.snapshot.json');
18669
18712
  const writeSnapshot = async (cwd, stanPath, base, dryRun) => {
18670
18713
  const sel = resolveIncludesExcludes(base);
18671
18714
  if (dryRun)
18672
18715
  return;
18716
+ const includes = withImplicitImportsInclude(stanPath, sel.includes);
18673
18717
  await tu({
18674
18718
  cwd,
18675
18719
  stanPath,
18676
- includes: sel.includes,
18720
+ includes,
18677
18721
  excludes: sel.excludes,
18678
18722
  });
18679
18723
  };
@@ -18784,6 +18828,7 @@ const ensureStanGitignore = async (cwd, stanPath) => {
18784
18828
  `${rel('diff')}/`,
18785
18829
  `${rel('dist')}/`,
18786
18830
  `${rel('patch')}/`,
18831
+ `${rel('imports')}/`,
18787
18832
  // System files: ephemeral state/metadata should never be committed.
18788
18833
  // Keep these gitignored explicitly (and add deterministically if absent).
18789
18834
  rel('system/facet.state.json'),
@@ -29746,6 +29791,7 @@ const archivePhase = async (args, opts) => {
29746
29791
  const shouldContinue = typeof opts?.shouldContinue === 'function'
29747
29792
  ? opts.shouldContinue
29748
29793
  : undefined;
29794
+ const includes = withImplicitImportsInclude(config.stanPath, config.includes ?? []);
29749
29795
  if (!silent && (which === 'both' || which === 'full')) {
29750
29796
  console.log(`stan: start "${alert('archive')}"`);
29751
29797
  }
@@ -29765,7 +29811,7 @@ const archivePhase = async (args, opts) => {
29765
29811
  const startedFull = Date.now();
29766
29812
  archivePath = await ye(cwd, config.stanPath, {
29767
29813
  includeOutputDir: includeOutputs,
29768
- includes: config.includes ?? [],
29814
+ includes,
29769
29815
  excludes: config.excludes ?? [],
29770
29816
  anchors: config.anchors ?? [],
29771
29817
  });
@@ -29798,7 +29844,7 @@ const archivePhase = async (args, opts) => {
29798
29844
  cwd,
29799
29845
  stanPath: config.stanPath,
29800
29846
  baseName: 'archive',
29801
- includes: config.includes ?? [],
29847
+ includes,
29802
29848
  excludes: config.excludes ?? [],
29803
29849
  anchors: config.anchors ?? [],
29804
29850
  updateSnapshot: 'createIfMissing',
@@ -33025,6 +33071,7 @@ async function handleSnap(opts) {
33025
33071
  const cfg = loadConfigFn ? await loadConfigFn(cwd) : null;
33026
33072
  includes = Array.isArray(cfg?.includes) ? cfg.includes : [];
33027
33073
  excludes = Array.isArray(cfg?.excludes) ? cfg.excludes : [];
33074
+ includes = withImplicitImportsInclude(stanPath, includes);
33028
33075
  // Decide overlay enablement from run defaults (snap has no facet flags).
33029
33076
  const eff = getRunDefaults(cwd);
33030
33077
  try {