neurastream 0.3.21 → 0.3.22

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.
@@ -53,14 +53,19 @@ export interface SetupFacts {
53
53
  current: Config | null;
54
54
  }
55
55
 
56
- function hasRepoBelow(dir: string): boolean {
56
+ /** Direct children of dir that are git repositories (`.git` file = worktree), unsorted (plan 20261122_1828_reuse_map P3: the one walk `reuse on` candidates reuse). */
57
+ export function repoDirs(dir: string): string[] {
57
58
  try {
58
- return readdirSync(dir, { withFileTypes: true }).some(c => c.isDirectory() && existsSync(join(dir, c.name, ".git")));
59
+ return readdirSync(dir, { withFileTypes: true }).filter(c => c.isDirectory() && existsSync(join(dir, c.name, ".git"))).map(c => join(dir, c.name));
59
60
  } catch {
60
- return false;
61
+ return [];
61
62
  }
62
63
  }
63
64
 
65
+ function hasRepoBelow(dir: string): boolean {
66
+ return repoDirs(dir).length > 0;
67
+ }
68
+
64
69
  function workRoots(home: string): string[] {
65
70
  return readdirSync(home, { withFileTypes: true })
66
71
  .filter(d => d.isDirectory() && !d.name.startsWith("."))
@@ -12,6 +12,7 @@ import { stripBlock } from "./agents-md.ts";
12
12
  import { configFile, loadConfig, type Config } from "./config.ts";
13
13
  import { printText } from "./help.ts";
14
14
  import { indexLockPath } from "./queue/lib.ts";
15
+ import { reuseOff } from "./reuse-map.ts";
15
16
 
16
17
  const HERE = dirname(fileURLToPath(import.meta.url));
17
18
  const PACKAGE_ROOT = resolve(HERE, "../..");
@@ -248,6 +249,19 @@ export function runUninstall(args: string[]): number {
248
249
  printText("dry run: re-run with --yes to remove these");
249
250
  return 1;
250
251
  }
252
+ // Reuse map (plan 20261122_1828_reuse_map P3): uninstalling with the map on runs the off
253
+ // routine first (exclude lines, config); --purge passes through, so graphify-out/ goes and
254
+ // graphifyy is uninstalled too. A failed off stops the uninstall: the gate must not stay on
255
+ // while its config is being removed.
256
+ if (cfg.reuse_map.enabled) {
257
+ const off = reuseOff(args.filter((a) => a === "--purge"), { home: homedir(), env: process.env, terminal: false, ask: () => "n" });
258
+ for (const l of off.out) printText(l);
259
+ if (off.code !== 0) {
260
+ for (const l of off.err) printText(l);
261
+ printText("uninstall stopped: the reuse map could not be turned off");
262
+ return 1;
263
+ }
264
+ }
251
265
  applyUninstall(cfg, plan);
252
266
  printText(`uninstalled ${plan.targets.length} target${plan.targets.length === 1 ? "" : "s"}${purge ? " (purged)" : ""}`);
253
267
  return 0;
@@ -240,6 +240,13 @@ tuning: # the tuner steps existing rules down and back up (
240
240
  guards: false # guard ids are scored and stepped only when this is true
241
241
  keep_off: [] # rule ids probation never raises
242
242
 
243
+ reuse_map: # the opt-in Graphify code map gating new plans (src/core/reuse-map.ts)
244
+ enabled: false # off: no graphify/uv/pipx process, no graphify-out/ read, nothing changes
245
+ tool: graphify # the mapping tool; only "graphify" (PyPI: graphifyy) is implemented
246
+ min_cited: 2 # distinct matched files a plan's `## Reuse` map line must have cited
247
+ repos: [] # repos `neurastream reuse on` mapped; set only by `reuse on`/`reuse off`
248
+ exclude: [] # globs `graphify extract` skips in every mapped repo
249
+
243
250
  machine:
244
251
  load_over_cores: 4 # load above the core count that draws a warning (used when load_max is 0)
245
252
  load_max: 0 # load ceiling; 0 = core count + load_over_cores