@haus-tech/haus-workflow 7.2.1 → 7.3.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.js CHANGED
@@ -1235,11 +1235,11 @@ function stripHausEnabledPlugins(settings) {
1235
1235
 
1236
1236
  // src/sync/suggest-packages.ts
1237
1237
  import { readFile as readFile3 } from "node:fs/promises";
1238
- import path19 from "node:path";
1238
+ import path18 from "node:path";
1239
1239
  import YAML2 from "yaml";
1240
1240
 
1241
1241
  // src/claude/write-agents-md.ts
1242
- import path12 from "node:path";
1242
+ import path11 from "node:path";
1243
1243
 
1244
1244
  // src/utils/diff.ts
1245
1245
  import { createTwoFilesPatch } from "diff";
@@ -2176,184 +2176,18 @@ function outcomeStream(code2) {
2176
2176
 
2177
2177
  // src/claude/write-root-claude-md.ts
2178
2178
  import { stat } from "node:fs/promises";
2179
- import path11 from "node:path";
2180
-
2181
- // src/claude/project-intent.ts
2182
- var PROJECT_CONFIG_FILE = "haus.config.json";
2183
- var PROJECT_CONFIG_REL = `${HAUS_DIR}/${PROJECT_CONFIG_FILE}`;
2184
- function normalizeIdList(value) {
2185
- if (!Array.isArray(value)) return [];
2186
- return [
2187
- ...new Set(
2188
- value.filter((entry) => typeof entry === "string" && entry.length > 0)
2189
- )
2190
- ];
2191
- }
2192
- async function readProjectConfigObject(root) {
2193
- try {
2194
- const data = await readJson(hausPath(root, PROJECT_CONFIG_FILE));
2195
- if (data == null || typeof data !== "object" || Array.isArray(data)) return null;
2196
- return data;
2197
- } catch (err) {
2198
- if (err.code === "ENOENT") return null;
2199
- warn(
2200
- `${PROJECT_CONFIG_REL} could not be read (${err instanceof Error ? err.message : String(err)}), treating project intent as unset`
2201
- );
2202
- return null;
2203
- }
2204
- }
2205
- function refuseConfig(parserMessage) {
2206
- error(notValidLine(PROJECT_CONFIG_REL, "JSON", parserMessage));
2207
- return { refused: true };
2208
- }
2209
- async function readConfigToEdit(root) {
2210
- const read = await readTextDetailed(hausPath(root, PROJECT_CONFIG_FILE));
2211
- if (read.status === "unreadable") {
2212
- const linkedMissing = await linkedFileRefusal(root, PROJECT_CONFIG_REL);
2213
- error(linkedMissing ?? unreadableLine(PROJECT_CONFIG_REL, messageOf(read.error)));
2214
- return { refused: true };
2215
- }
2216
- if (read.status === "missing") return { existing: {} };
2217
- let value;
2218
- try {
2219
- value = JSON.parse(read.text);
2220
- } catch (err) {
2221
- return refuseConfig(messageOf(err));
2222
- }
2223
- if (!isPlainObject(value)) return refuseConfig(NOT_A_JSON_OBJECT);
2224
- return { existing: value };
2225
- }
2226
- async function checkProjectConfigEditable(root) {
2227
- const read = await readConfigToEdit(root);
2228
- if ("refused" in read) return read;
2229
- const linked = await linkedFileRefusal(root, PROJECT_CONFIG_REL);
2230
- if (linked !== null) {
2231
- error(linked);
2232
- return { refused: true };
2233
- }
2234
- return null;
2235
- }
2236
- async function updateProjectConfig(root, mutate, opts = {}) {
2237
- const file = hausPath(root, PROJECT_CONFIG_FILE);
2238
- const read = await readConfigToEdit(root);
2239
- if ("refused" in read) return read;
2240
- const { existing } = read;
2241
- const next = mutate({ ...existing });
2242
- const linked = await linkedFileRefusal(root, PROJECT_CONFIG_REL);
2243
- let written;
2244
- try {
2245
- written = await writeJsonRecord(file, next, { dryRun: opts.dryRun === true || linked !== null });
2246
- } catch (err) {
2247
- if (!(err instanceof MalformedJsonFileError)) throw err;
2248
- return refuseConfig(messageOf(err.cause));
2249
- }
2250
- if (linked !== null && written !== "unchanged") {
2251
- error(linked);
2252
- return { refused: true };
2253
- }
2254
- if (written === "unchanged") {
2255
- return {
2256
- file: PROJECT_CONFIG_REL,
2257
- outcome: "unchanged",
2258
- added: [],
2259
- removed: [],
2260
- reRecorded: []
2261
- };
2262
- }
2263
- return {
2264
- file: PROJECT_CONFIG_REL,
2265
- outcome: "changed",
2266
- ...recordDelta(keyRows(existing), keyRows(next))
2267
- };
2268
- }
2269
- function withdrawIncludedIds(existing, ids) {
2270
- const drop = new Set(ids);
2271
- return normalizeIdList(existing.includedIds).filter((id) => !drop.has(id));
2272
- }
2273
-
2274
- // src/claude/workflow-template.ts
2275
2179
  import path10 from "node:path";
2276
- import fs7 from "fs-extra";
2277
- var WORKFLOW_TEMPLATE_REL = "templates/agentic-workflow-standard.md";
2278
- async function readWorkflowTemplate(opts = {}) {
2279
- const file = path10.join(packageRoot(), "packages", opts.templateRel ?? WORKFLOW_TEMPLATE_REL);
2280
- try {
2281
- return await fs7.readFile(file, "utf8");
2282
- } catch {
2283
- return null;
2284
- }
2285
- }
2286
-
2287
- // src/claude/project-profile.ts
2288
- var PROFILE_IDS = ["production", "poc"];
2289
- var DEFAULT_PROFILE = "production";
2290
- var PROFILES = {
2291
- production: {
2292
- workflowTemplateRel: WORKFLOW_TEMPLATE_REL,
2293
- writesGate: true,
2294
- writesDecisionsSeed: true,
2295
- runsDocsPass: true,
2296
- droppedHookCommands: [],
2297
- workflowConfig: "standard"
2298
- },
2299
- poc: {
2300
- // Catalog item `haus.agentic-workflow-poc` (catalog ADR-0066); fetched by path for WORKFLOW.md, exactly like the production standard, and kept out of item recommendations by id (Task 3).
2301
- workflowTemplateRel: "templates/agentic-workflow-poc.md",
2302
- writesGate: false,
2303
- writesDecisionsSeed: false,
2304
- runsDocsPass: false,
2305
- droppedHookCommands: ["haus decisions guard --from-hook", "haus decisions suggest --from-hook"],
2306
- workflowConfig: "poc"
2307
- }
2308
- };
2309
- function isProfileId(value) {
2310
- return typeof value === "string" && PROFILE_IDS.includes(value);
2311
- }
2312
- function parseProfile(value) {
2313
- if (value === void 0 || value === null) return { profile: DEFAULT_PROFILE, malformed: false };
2314
- if (isProfileId(value)) return { profile: value, malformed: false };
2315
- return { profile: DEFAULT_PROFILE, malformed: true };
2316
- }
2317
- async function readProjectProfile(root) {
2318
- const data = await readProjectConfigObject(root);
2319
- const { profile, malformed } = parseProfile(data?.profile);
2320
- if (malformed) {
2321
- warn(
2322
- `${PROJECT_CONFIG_REL}: unknown profile ${JSON.stringify(data?.profile)}: expected one of ${PROFILE_IDS.join(", ")}; treating as ${DEFAULT_PROFILE}`
2323
- );
2324
- }
2325
- return profile;
2326
- }
2327
- async function readProjectProfileOr(root, fallback2) {
2328
- const data = await readProjectConfigObject(root);
2329
- if (data?.profile === void 0 || data.profile === null) return fallback2;
2330
- return readProjectProfile(root);
2331
- }
2332
- async function writeProjectProfile(root, profile, opts = {}) {
2333
- return updateProjectConfig(root, (existing) => ({ ...existing, profile }), opts);
2334
- }
2335
- function pocLockedMessage() {
2336
- return `This repo is a PoC (profile "poc" in ${PROJECT_CONFIG_REL}). Production starts from zero in a new repo, with docs/MANUS.md as input (\`/haus-workflow new\` in production mode). To re-run setup here, pass \`haus init --profile poc\`. To leave the PoC profile on purpose, remove the "profile" line from ${PROJECT_CONFIG_REL} by hand. Nothing was written.`;
2337
- }
2338
- var SYNC_SESSION_COMMAND = "haus sync --session-hook";
2339
- function droppedHookCommands(profile, sessionSyncHook) {
2340
- const dropped = new Set(PROFILES[profile].droppedHookCommands);
2341
- if (!sessionSyncHook) dropped.add(SYNC_SESSION_COMMAND);
2342
- return dropped;
2343
- }
2344
-
2345
- // src/claude/write-root-claude-md.ts
2346
2180
  var ROOT_CLAUDE_MD_FILE = "CLAUDE.md";
2347
2181
  var BLOCK_BEGIN = "<!-- HAUS:BEGIN haus-imports v=1 -->";
2348
2182
  var BLOCK_END = "<!-- HAUS:END haus-imports -->";
2349
2183
  var WORKSPACE_BLOCK_BEGIN = "<!-- HAUS:BEGIN haus-workspace-imports v=1 -->";
2350
2184
  var WORKSPACE_BLOCK_END = "<!-- HAUS:END haus-workspace-imports -->";
2351
2185
  var DEFAULT_SENTINELS = { begin: BLOCK_BEGIN, end: BLOCK_END };
2352
- function importContentFor(profile) {
2353
- const lines = ["@.haus-workflow/WORKFLOW.md", "@.haus-workflow/workflow-config.md"];
2354
- if (PROFILES[profile].writesDecisionsSeed) lines.push("@docs/decisions/README.md");
2355
- return lines.join("\n");
2356
- }
2186
+ var IMPORT_CONTENT = [
2187
+ "@.haus-workflow/WORKFLOW.md",
2188
+ "@.haus-workflow/workflow-config.md"
2189
+ ].join("\n");
2190
+ var RETIRED_IMPORTS = ["docs/decisions/README.md"];
2357
2191
  var CLAUDE_MD_IMPORT = "@AGENTS.md";
2358
2192
  function buildImportBlock() {
2359
2193
  return `${BLOCK_BEGIN}
@@ -2364,8 +2198,8 @@ ${BLOCK_END}`;
2364
2198
  async function claudeMdIsAgentsMd(root) {
2365
2199
  try {
2366
2200
  const [claude, agents] = await Promise.all([
2367
- stat(path11.join(root, ROOT_CLAUDE_MD_FILE)),
2368
- stat(path11.join(root, "AGENTS.md"))
2201
+ stat(path10.join(root, ROOT_CLAUDE_MD_FILE)),
2202
+ stat(path10.join(root, "AGENTS.md"))
2369
2203
  ]);
2370
2204
  return claude.dev === agents.dev && claude.ino === agents.ino;
2371
2205
  } catch {
@@ -2395,7 +2229,7 @@ var WRITE_THROUGH_WITHIN = (root) => ({
2395
2229
  throughLink: { within: root }
2396
2230
  });
2397
2231
  async function writeRootClaudeMd(root, dryRun, quiet = false) {
2398
- const filePath = path11.join(root, ROOT_CLAUDE_MD_FILE);
2232
+ const filePath = path10.join(root, ROOT_CLAUDE_MD_FILE);
2399
2233
  const block = buildImportBlock();
2400
2234
  const found = await readTextDetailed(filePath);
2401
2235
  if (found.status === "unreadable") {
@@ -2429,8 +2263,8 @@ var AGENTS_MD_FILE = "AGENTS.md";
2429
2263
  var AGENTS_BLOCK_BEGIN = "<!-- HAUS:BEGIN haus-agents v=1 -->";
2430
2264
  var AGENTS_BLOCK_END = "<!-- HAUS:END haus-agents -->";
2431
2265
  var AGENTS_SENTINELS = { begin: AGENTS_BLOCK_BEGIN, end: AGENTS_BLOCK_END };
2432
- function buildAgentsBlock(profile, routing) {
2433
- const imports = importContentFor(profile);
2266
+ function buildAgentsBlock(routing) {
2267
+ const imports = IMPORT_CONTENT;
2434
2268
  if (routing.length === 0) return `${AGENTS_BLOCK_BEGIN}
2435
2269
 
2436
2270
  ${imports}
@@ -2455,8 +2289,8 @@ function agentsBlockOf(text) {
2455
2289
  const end = findLineMarker(text, AGENTS_BLOCK_END, begin.end);
2456
2290
  return end === null ? null : text.slice(begin.start, end.end);
2457
2291
  }
2458
- async function writeAgentsMdBlock(root, routing, dryRun, profile, quiet = false) {
2459
- const filePath = path12.join(root, AGENTS_MD_FILE);
2292
+ async function writeAgentsMdBlock(root, routing, dryRun, quiet = false) {
2293
+ const filePath = path11.join(root, AGENTS_MD_FILE);
2460
2294
  const found = await readTextDetailed(filePath);
2461
2295
  if (found.status === "unreadable") {
2462
2296
  const line2 = unreadableLine(AGENTS_MD_FILE, messageOf(found.error));
@@ -2470,7 +2304,7 @@ async function writeAgentsMdBlock(root, routing, dryRun, profile, quiet = false)
2470
2304
  return { status: "refused", reason: "linked", line: line2 };
2471
2305
  }
2472
2306
  const prev = found.status === "ok" ? found.text : null;
2473
- const edit = injectHausBlock(prev ?? "", buildAgentsBlock(profile, routing), AGENTS_SENTINELS);
2307
+ const edit = injectHausBlock(prev ?? "", buildAgentsBlock(routing), AGENTS_SENTINELS);
2474
2308
  if ("refused" in edit) {
2475
2309
  const line2 = loneBeginLine(AGENTS_MD_FILE);
2476
2310
  warn(line2);
@@ -2489,7 +2323,7 @@ import { randomBytes as randomBytes2 } from "node:crypto";
2489
2323
  import { existsSync as existsSync2 } from "node:fs";
2490
2324
  import { mkdir, readFile, rename, rm, writeFile } from "node:fs/promises";
2491
2325
  import os2 from "node:os";
2492
- import path13 from "node:path";
2326
+ import path12 from "node:path";
2493
2327
  import { execa as execa2 } from "execa";
2494
2328
 
2495
2329
  // src/utils/git-ref.ts
@@ -2551,13 +2385,13 @@ function netRun(args, opts, cwd) {
2551
2385
  });
2552
2386
  }
2553
2387
  var MIRROR_ATTRIBUTES = "* -export-ignore -export-subst\n";
2554
- var hasMirror = (dir) => existsSync2(path13.join(dir, "HEAD"));
2388
+ var hasMirror = (dir) => existsSync2(path12.join(dir, "HEAD"));
2555
2389
  function assertTag(tag) {
2556
2390
  if (!isSafeRef(tag)) throw new Error(`refusing tag ${JSON.stringify(tag)}`);
2557
2391
  }
2558
2392
  function cacheDir() {
2559
2393
  const env = process.env.HAUS_CACHE_DIR;
2560
- return env !== void 0 && env !== "" ? env : path13.join(os2.homedir(), ".cache", "haus");
2394
+ return env !== void 0 && env !== "" ? env : path12.join(os2.homedir(), ".cache", "haus");
2561
2395
  }
2562
2396
  function packagesRepoUrl() {
2563
2397
  const env = process.env.HAUS_PACKAGES_REPO;
@@ -2571,7 +2405,7 @@ function mirrorPath(repoUrl) {
2571
2405
  if (segments.length === 0) segments.push("repo");
2572
2406
  const last = segments.length - 1;
2573
2407
  segments[last] = `${segments[last].replace(/\.git$/, "") || "repo"}.git`;
2574
- return path13.join(cacheDir(), ...segments);
2408
+ return path12.join(cacheDir(), ...segments);
2575
2409
  }
2576
2410
  function encodeSegment(segment) {
2577
2411
  if (/^\.+$/.test(segment)) return segment.replace(/\./g, "%2E");
@@ -2616,14 +2450,14 @@ async function hasCommit(dir, commit) {
2616
2450
  return r.exitCode === 0;
2617
2451
  }
2618
2452
  async function cloneMirror(repoUrl, dir, opts) {
2619
- await mkdir(path13.dirname(dir), { recursive: true });
2453
+ await mkdir(path12.dirname(dir), { recursive: true });
2620
2454
  const tmp = `${dir}.tmp-${process.pid}-${randomBytes2(4).toString("hex")}`;
2621
2455
  const r = await netRun(["clone", "--bare", "--quiet", "--", repoUrl, tmp], opts);
2622
2456
  if (r.exitCode !== 0 || r.killed) {
2623
2457
  await rm(tmp, { recursive: true, force: true });
2624
2458
  return networkFailure(repoUrl, r);
2625
2459
  }
2626
- await writeFile(path13.join(tmp, "info", "attributes"), MIRROR_ATTRIBUTES);
2460
+ await writeFile(path12.join(tmp, "info", "attributes"), MIRROR_ATTRIBUTES);
2627
2461
  try {
2628
2462
  await rename(tmp, dir);
2629
2463
  } catch (err) {
@@ -2871,20 +2705,20 @@ async function extractTree(repoUrl, commit, treePath2, dest) {
2871
2705
  return { ok: true, kind: isFile ? "file" : "dir" };
2872
2706
  }
2873
2707
  async function ensureAttributes(dir) {
2874
- const file = path13.join(dir, "info", "attributes");
2708
+ const file = path12.join(dir, "info", "attributes");
2875
2709
  const current = await readFile(file, "utf8").catch(() => void 0);
2876
2710
  if (current === MIRROR_ATTRIBUTES) return;
2877
- await mkdir(path13.dirname(file), { recursive: true });
2711
+ await mkdir(path12.dirname(file), { recursive: true });
2878
2712
  await writeFile(file, MIRROR_ATTRIBUTES);
2879
2713
  }
2880
2714
 
2881
2715
  // src/sync/project-sync.ts
2882
2716
  import { createHash as createHash2 } from "node:crypto";
2883
2717
  import { realpath } from "node:fs/promises";
2884
- import path18 from "node:path";
2718
+ import path17 from "node:path";
2885
2719
 
2886
2720
  // src/utils/git-root.ts
2887
- import path14 from "node:path";
2721
+ import path13 from "node:path";
2888
2722
  function fallback(start) {
2889
2723
  return {
2890
2724
  cwd: start,
@@ -2900,11 +2734,11 @@ function fallback(start) {
2900
2734
  async function resolveAbsoluteGitPath(flag, cwd, repoRoot) {
2901
2735
  const withFormat = await runGit(["rev-parse", "--path-format=absolute", flag], { cwd });
2902
2736
  const raw = withFormat.exitCode === 0 ? withFormat.stdout.trim() : "";
2903
- if (raw && path14.isAbsolute(raw)) return path14.resolve(raw);
2737
+ if (raw && path13.isAbsolute(raw)) return path13.resolve(raw);
2904
2738
  const plain2 = await runGit(["rev-parse", flag], { cwd });
2905
2739
  const plainRaw = plain2.exitCode === 0 ? plain2.stdout.trim() : "";
2906
2740
  if (!plainRaw) return "";
2907
- return path14.isAbsolute(plainRaw) ? path14.resolve(plainRaw) : path14.resolve(repoRoot, plainRaw);
2741
+ return path13.isAbsolute(plainRaw) ? path13.resolve(plainRaw) : path13.resolve(repoRoot, plainRaw);
2908
2742
  }
2909
2743
  async function resolveRoots(start) {
2910
2744
  const cwd = start ?? process.cwd();
@@ -2913,15 +2747,15 @@ async function resolveRoots(start) {
2913
2747
  if (toplevel.exitCode !== 0) return fallback(cwd);
2914
2748
  const toplevelRaw = toplevel.stdout.trim();
2915
2749
  if (!toplevelRaw) return fallback(cwd);
2916
- const repoRoot = path14.resolve(toplevelRaw);
2750
+ const repoRoot = path13.resolve(toplevelRaw);
2917
2751
  const [gitDir, gitCommonDir] = await Promise.all([
2918
2752
  resolveAbsoluteGitPath("--git-dir", cwd, repoRoot),
2919
2753
  resolveAbsoluteGitPath("--git-common-dir", cwd, repoRoot)
2920
2754
  ]);
2921
2755
  if (!gitDir || !gitCommonDir) return fallback(cwd);
2922
2756
  const isLinkedWorktree = gitDir !== gitCommonDir;
2923
- const mainRoot = isLinkedWorktree && path14.basename(gitCommonDir) === ".git" ? path14.dirname(gitCommonDir) : repoRoot;
2924
- const worktreeName2 = isLinkedWorktree ? path14.basename(gitDir) : null;
2757
+ const mainRoot = isLinkedWorktree && path13.basename(gitCommonDir) === ".git" ? path13.dirname(gitCommonDir) : repoRoot;
2758
+ const worktreeName2 = isLinkedWorktree ? path13.basename(gitDir) : null;
2925
2759
  return {
2926
2760
  cwd,
2927
2761
  repoRoot,
@@ -2938,10 +2772,10 @@ async function resolveRoots(start) {
2938
2772
  }
2939
2773
 
2940
2774
  // src/workspace/members.ts
2941
- import path16 from "node:path";
2775
+ import path15 from "node:path";
2942
2776
 
2943
2777
  // src/commands/workspace/config.ts
2944
- import path15 from "node:path";
2778
+ import path14 from "node:path";
2945
2779
  import YAML from "yaml";
2946
2780
  var WORKSPACE_FILE = "haus.workspace.yaml";
2947
2781
  function parseWorkspaceConfig(text) {
@@ -2973,7 +2807,7 @@ function parseWorkspaceConfig(text) {
2973
2807
  };
2974
2808
  }
2975
2809
  async function readWorkspaceConfig(workspaceRoot) {
2976
- return parseWorkspaceConfig(await readText(path15.join(workspaceRoot, WORKSPACE_FILE)));
2810
+ return parseWorkspaceConfig(await readText(path14.join(workspaceRoot, WORKSPACE_FILE)));
2977
2811
  }
2978
2812
 
2979
2813
  // src/workspace/members.ts
@@ -2989,14 +2823,14 @@ var MemberConfigError = class extends Error {
2989
2823
  };
2990
2824
  function resolveAbsPath(workspaceRoot, folder, overrides) {
2991
2825
  const override = overrides[folder];
2992
- if (override) return path16.resolve(workspaceRoot, override);
2993
- return path16.resolve(workspaceRoot, folder);
2826
+ if (override) return path15.resolve(workspaceRoot, override);
2827
+ return path15.resolve(workspaceRoot, folder);
2994
2828
  }
2995
2829
  function isSelfMember(workspaceRoot, member) {
2996
- return path16.resolve(member.absPath) === path16.resolve(workspaceRoot);
2830
+ return path15.resolve(member.absPath) === path15.resolve(workspaceRoot);
2997
2831
  }
2998
2832
  async function readPathOverrides(workspaceRoot) {
2999
- const filePath = path16.join(workspaceRoot, REPOS_LOCAL_FILE);
2833
+ const filePath = path15.join(workspaceRoot, REPOS_LOCAL_FILE);
3000
2834
  const result = await readJsonDetailed(filePath);
3001
2835
  if (result.status === "missing") return {};
3002
2836
  if (result.status === "invalid") throw new MemberConfigError(filePath, "invalid JSON");
@@ -3012,7 +2846,7 @@ async function readPathOverrides(workspaceRoot) {
3012
2846
  return overrides;
3013
2847
  }
3014
2848
  async function readFromWorkspaceYaml(workspaceRoot, overrides) {
3015
- const filePath = path16.join(workspaceRoot, WORKSPACE_FILE);
2849
+ const filePath = path15.join(workspaceRoot, WORKSPACE_FILE);
3016
2850
  const text = await readText(filePath);
3017
2851
  if (text === void 0) return void 0;
3018
2852
  const config = parseWorkspaceConfig(text);
@@ -3025,7 +2859,7 @@ async function readFromWorkspaceYaml(workspaceRoot, overrides) {
3025
2859
  }));
3026
2860
  }
3027
2861
  async function readFromManifest(workspaceRoot, overrides) {
3028
- const filePath = path16.join(workspaceRoot, REPOS_MANIFEST_FILE);
2862
+ const filePath = path15.join(workspaceRoot, REPOS_MANIFEST_FILE);
3029
2863
  const result = await readJsonDetailed(filePath);
3030
2864
  if (result.status === "missing") return void 0;
3031
2865
  if (result.status === "invalid") throw new MemberConfigError(filePath, "invalid JSON");
@@ -3069,16 +2903,16 @@ async function readMembers(rootInfo) {
3069
2903
  // src/sync/haus-json.ts
3070
2904
  import { createHash } from "node:crypto";
3071
2905
  import { readFile as readFile2 } from "node:fs/promises";
3072
- import path17 from "node:path";
2906
+ import path16 from "node:path";
3073
2907
  var HAUS_JSON_FILE = "haus.json";
3074
2908
  var KEYS = /* @__PURE__ */ new Set(["release", "packages", "superpowers"]);
3075
2909
  var PACKAGE_NAME = /^[a-z0-9][a-z0-9-]*$/;
3076
2910
  var RELEASE = /^\d+\.\d+\.\d+$/;
3077
2911
  async function hausJsonPresent(root) {
3078
- return lexists(path17.join(root, HAUS_JSON_FILE));
2912
+ return lexists(path16.join(root, HAUS_JSON_FILE));
3079
2913
  }
3080
2914
  async function readHausJson(root) {
3081
- const file = path17.join(root, HAUS_JSON_FILE);
2915
+ const file = path16.join(root, HAUS_JSON_FILE);
3082
2916
  let bytes;
3083
2917
  try {
3084
2918
  bytes = await readFile2(file);
@@ -3140,7 +2974,7 @@ async function resolveProjectSync(root) {
3140
2974
  async function resolveProjectSyncDetailed(root) {
3141
2975
  if (await hausJsonPresent(root)) return { sync: { mode: "own" } };
3142
2976
  const self = await realOr(root);
3143
- let dir = path18.dirname(self);
2977
+ let dir = path17.dirname(self);
3144
2978
  for (; ; ) {
3145
2979
  if (await hausJsonPresent(dir)) {
3146
2980
  const info = await resolveRoots(dir);
@@ -3148,7 +2982,7 @@ async function resolveProjectSyncDetailed(root) {
3148
2982
  return inheritedFrom(info, self);
3149
2983
  }
3150
2984
  }
3151
- const up = path18.dirname(dir);
2985
+ const up = path17.dirname(dir);
3152
2986
  if (up === dir) return { sync: { mode: "none" } };
3153
2987
  dir = up;
3154
2988
  }
@@ -3174,13 +3008,13 @@ async function inheritedFrom(info, self) {
3174
3008
  }
3175
3009
  return {
3176
3010
  sync: { mode: "none" },
3177
- blocked: `the workspace root's ${path18.join(info.repoRoot, "haus.json")} cannot be read (${haus.state === "unreadable" ? haus.reason : "missing"})`
3011
+ blocked: `the workspace root's ${path17.join(info.repoRoot, "haus.json")} cannot be read (${haus.state === "unreadable" ? haus.reason : "missing"})`
3178
3012
  };
3179
3013
  }
3180
3014
  return { sync: { mode: "none" } };
3181
3015
  }
3182
3016
  function memberDir(rootInfo, member) {
3183
- return rootInfo.isLinkedWorktree ? path18.join(rootInfo.repoRoot, member.folder) : member.absPath;
3017
+ return rootInfo.isLinkedWorktree ? path17.join(rootInfo.repoRoot, member.folder) : member.absPath;
3184
3018
  }
3185
3019
  async function isOwnRepo(dir) {
3186
3020
  const roots = await resolveRoots(dir);
@@ -3195,7 +3029,7 @@ async function memberWithoutRepoAt(rootInfo, members, start) {
3195
3029
  const at = await realOr(start);
3196
3030
  for (const member of members) {
3197
3031
  const dir = await realOr(memberDir(rootInfo, member));
3198
- if (at !== dir && !at.startsWith(`${dir}${path18.sep}`)) continue;
3032
+ if (at !== dir && !at.startsWith(`${dir}${path17.sep}`)) continue;
3199
3033
  if (!await isOwnRepo(dir)) return member;
3200
3034
  }
3201
3035
  return void 0;
@@ -3211,7 +3045,7 @@ async function realOr(p) {
3211
3045
  try {
3212
3046
  return await realpath(p);
3213
3047
  } catch {
3214
- return path18.resolve(p);
3048
+ return path17.resolve(p);
3215
3049
  }
3216
3050
  }
3217
3051
 
@@ -3236,7 +3070,7 @@ function suggestPackages(scan) {
3236
3070
  return out;
3237
3071
  }
3238
3072
  function bundledPackagesFile() {
3239
- return path19.join(packageRoot(), "packages", "packages.yaml");
3073
+ return path18.join(packageRoot(), "packages", "packages.yaml");
3240
3074
  }
3241
3075
  async function bundledPackages() {
3242
3076
  const packages = packagesOf(YAML2.parse(await readFile3(bundledPackagesFile(), "utf8")));
@@ -3268,7 +3102,7 @@ async function resolveRouting(hausJson, agentsText) {
3268
3102
  }
3269
3103
  async function projectRouting(root, sync, planned) {
3270
3104
  const hausJson = planned === void 0 ? await effectiveHausJson(root, sync) : null;
3271
- const agents = await readTextDetailed(path19.join(root, "AGENTS.md"));
3105
+ const agents = await readTextDetailed(path18.join(root, "AGENTS.md"));
3272
3106
  return resolveRouting(
3273
3107
  planned ?? (hausJson?.state === "ok" ? hausJson.value : null),
3274
3108
  agents.status === "ok" ? agents.text : null
@@ -3288,10 +3122,10 @@ async function releasePackages(release2) {
3288
3122
 
3289
3123
  // src/utils/haus-version.ts
3290
3124
  import { readFileSync as readFileSync2 } from "node:fs";
3291
- import path20 from "node:path";
3125
+ import path19 from "node:path";
3292
3126
  function hausVersion() {
3293
3127
  try {
3294
- const pkg = JSON.parse(readFileSync2(path20.join(packageRoot(), "package.json"), "utf8"));
3128
+ const pkg = JSON.parse(readFileSync2(path19.join(packageRoot(), "package.json"), "utf8"));
3295
3129
  return pkg.version ?? "0.0.0";
3296
3130
  } catch {
3297
3131
  return "0.0.0";
@@ -3300,10 +3134,10 @@ function hausVersion() {
3300
3134
 
3301
3135
  // src/claude/ci-gate-workflow.ts
3302
3136
  import crypto2 from "node:crypto";
3303
- import path21 from "node:path";
3304
- import fs8 from "fs-extra";
3137
+ import path20 from "node:path";
3138
+ import fs7 from "fs-extra";
3305
3139
  import YAML3 from "yaml";
3306
- var CI_GATE_WORKFLOW_REL = path21.join(".github", "workflows", "haus-gate.yml");
3140
+ var CI_GATE_WORKFLOW_REL = path20.join(".github", "workflows", "haus-gate.yml");
3307
3141
  var LAST_CI_GATE_WORKFLOW = `# Written by \`haus init\`. Yours to edit \u2014 haus will not rewrite this file.
3308
3142
  #
3309
3143
  # Runs the checks haus already knows how to run, on every pull request:
@@ -3377,10 +3211,10 @@ function runScripts(node, found = []) {
3377
3211
  return found;
3378
3212
  }
3379
3213
  async function projectRunsCiGate(root, opts = {}) {
3380
- const dir = path21.join(root, ".github", "workflows");
3214
+ const dir = path20.join(root, ".github", "workflows");
3381
3215
  let entries;
3382
3216
  try {
3383
- entries = await fs8.readdir(dir);
3217
+ entries = await fs7.readdir(dir);
3384
3218
  } catch {
3385
3219
  return false;
3386
3220
  }
@@ -3388,7 +3222,7 @@ async function projectRunsCiGate(root, opts = {}) {
3388
3222
  if (!/\.ya?ml$/i.test(entry)) continue;
3389
3223
  try {
3390
3224
  if (opts.exceptHausGateFile && entry === "haus-gate.yml") continue;
3391
- const text = await fs8.readFile(path21.join(dir, entry), "utf8");
3225
+ const text = await fs7.readFile(path20.join(dir, entry), "utf8");
3392
3226
  if (opts.exceptKnownHausCopy && entry === "haus-gate.yml" && isKnownHausCiGate(text)) {
3393
3227
  continue;
3394
3228
  }
@@ -3400,8 +3234,8 @@ async function projectRunsCiGate(root, opts = {}) {
3400
3234
  }
3401
3235
 
3402
3236
  // src/claude/legacy-files.ts
3403
- import path22 from "node:path";
3404
- import fs9 from "fs-extra";
3237
+ import path21 from "node:path";
3238
+ import fs8 from "fs-extra";
3405
3239
  var LEGACY_STUBS = [
3406
3240
  {
3407
3241
  id: "haus-review",
@@ -3426,7 +3260,7 @@ var LEGACY_ARTIFACTS = [
3426
3260
  ];
3427
3261
  async function legacyFileState(abs) {
3428
3262
  try {
3429
- return (await fs9.lstat(abs)).isFile() ? "file" : "other";
3263
+ return (await fs8.lstat(abs)).isFile() ? "file" : "other";
3430
3264
  } catch (err) {
3431
3265
  const code2 = err.code;
3432
3266
  return code2 === "ENOENT" || code2 === "ENOTDIR" ? "absent" : "other";
@@ -3435,7 +3269,7 @@ async function legacyFileState(abs) {
3435
3269
  async function holdsKnownStub(abs, stub) {
3436
3270
  let found;
3437
3271
  try {
3438
- found = await fs9.readFile(abs);
3272
+ found = await fs8.readFile(abs);
3439
3273
  } catch {
3440
3274
  return false;
3441
3275
  }
@@ -3446,7 +3280,7 @@ async function holdsKnownStub(abs, stub) {
3446
3280
  async function keptForLinkedFolder(root, rel, unsafeByRel) {
3447
3281
  if (unsafeByRel.get(rel) !== "symlink") return false;
3448
3282
  try {
3449
- return await realPathInsideRoot(root, path22.join(root, rel));
3283
+ return await realPathInsideRoot(root, path21.join(root, rel));
3450
3284
  } catch {
3451
3285
  return false;
3452
3286
  }
@@ -3461,10 +3295,10 @@ function legacyKeptLine(rel, kind) {
3461
3295
  return `kept (not owned) ${rel}: haus no longer writes this file and cannot verify it; delete it by hand.`;
3462
3296
  }
3463
3297
  var CI_GATE_COMMIT_HINT = 'Commit this with an [adr-skip] line in the commit body (e.g. "[adr-skip] haus moved its gate from CI to Lefthook, ADR-0161"): removing a workflow is a decision trigger.';
3464
- var CI_GATE_REL = CI_GATE_WORKFLOW_REL.split(path22.sep).join("/");
3298
+ var CI_GATE_REL = CI_GATE_WORKFLOW_REL.split(path21.sep).join("/");
3465
3299
  var CI_GATE_RULES = { installRoot: false };
3466
3300
  async function findCiGateWorkflow(root) {
3467
- if (await legacyFileState(path22.join(root, CI_GATE_REL)) !== "file") return void 0;
3301
+ if (await legacyFileState(path21.join(root, CI_GATE_REL)) !== "file") return void 0;
3468
3302
  const unsafeByRel = await unsafeReasonsFor(root, [CI_GATE_REL], CI_GATE_RULES);
3469
3303
  const [tracked] = await resolveExistingTrackedPaths(
3470
3304
  root,
@@ -3478,7 +3312,7 @@ async function findCiGateWorkflow(root) {
3478
3312
  if (tracked === void 0 && !linked) return void 0;
3479
3313
  let content2;
3480
3314
  try {
3481
- content2 = await fs9.readFile(tracked?.abs ?? path22.join(root, CI_GATE_REL));
3315
+ content2 = await fs8.readFile(tracked?.abs ?? path21.join(root, CI_GATE_REL));
3482
3316
  } catch {
3483
3317
  return void 0;
3484
3318
  }
@@ -3488,14 +3322,14 @@ async function findCiGateWorkflow(root) {
3488
3322
  async function findLegacyStubPaths(root) {
3489
3323
  const found = [];
3490
3324
  for (const stub of LEGACY_STUBS) {
3491
- const state = await legacyFileState(path22.join(root, stub.rel));
3325
+ const state = await legacyFileState(path21.join(root, stub.rel));
3492
3326
  if (state === "absent") continue;
3493
3327
  const unsafeByRel = state === "file" ? await unsafeReasonsFor(root, [stub.rel]) : /* @__PURE__ */ new Map();
3494
3328
  const existing = state === "file" ? await resolveExistingTrackedPaths(root, stub.id, [stub.rel], () => {
3495
3329
  }, unsafeByRel) : [];
3496
3330
  const tracked = existing[0];
3497
3331
  const linked = tracked === void 0 && await keptForLinkedFolder(root, stub.rel, unsafeByRel);
3498
- const readAt = tracked?.abs ?? (linked ? path22.join(root, stub.rel) : void 0);
3332
+ const readAt = tracked?.abs ?? (linked ? path21.join(root, stub.rel) : void 0);
3499
3333
  const kind = readAt === void 0 || !await holdsKnownStub(readAt, stub.text) ? "other" : linked ? "linked" : "stub";
3500
3334
  found.push({ id: stub.id, rel: stub.rel, kind });
3501
3335
  }
@@ -3549,7 +3383,7 @@ async function removeLegacyHausFiles(root, dryRun, say, opts = {}) {
3549
3383
  } else if (matched.length > 0) {
3550
3384
  let backupDir;
3551
3385
  try {
3552
- backupDir = path22.basename(
3386
+ backupDir = path21.basename(
3553
3387
  await backupTrackedPaths(
3554
3388
  root,
3555
3389
  matched.map(({ tracked }) => tracked.abs),
@@ -3871,17 +3705,17 @@ function buildDenyRules() {
3871
3705
  }
3872
3706
 
3873
3707
  // src/sync/synced-record.ts
3874
- import path23 from "node:path";
3708
+ import path22 from "node:path";
3875
3709
  var SYNCED_FILE = ".haus-workflow/synced.json";
3876
3710
  var PENDING_FILE = ".haus-workflow/synced.pending.json";
3877
3711
  async function readSyncedRecord(root) {
3878
- return readRecordAt(path23.join(root, SYNCED_FILE));
3712
+ return readRecordAt(path22.join(root, SYNCED_FILE));
3879
3713
  }
3880
3714
  async function readPendingRecord(root) {
3881
- return readRecordAt(path23.join(root, PENDING_FILE));
3715
+ return readRecordAt(path22.join(root, PENDING_FILE));
3882
3716
  }
3883
3717
  async function writePendingRecord(root, rec) {
3884
- await writeJson(path23.join(root, PENDING_FILE), rec);
3718
+ await writeJson(path22.join(root, PENDING_FILE), rec);
3885
3719
  }
3886
3720
  async function readRecordAt(file) {
3887
3721
  const found = await readTextDetailed(file);
@@ -3897,7 +3731,7 @@ async function readRecordAt(file) {
3897
3731
  return typeof checked === "string" ? bad2(checked) : { state: "ok", value: checked };
3898
3732
  }
3899
3733
  async function writeSyncedRecord(root, rec) {
3900
- await writeJson(path23.join(root, SYNCED_FILE), rec);
3734
+ await writeJson(path22.join(root, SYNCED_FILE), rec);
3901
3735
  }
3902
3736
  function bad2(reason) {
3903
3737
  return { state: "unreadable", reason };
@@ -3944,6 +3778,170 @@ function validate2(value) {
3944
3778
  return out;
3945
3779
  }
3946
3780
 
3781
+ // src/claude/project-intent.ts
3782
+ var PROJECT_CONFIG_FILE = "haus.config.json";
3783
+ var PROJECT_CONFIG_REL = `${HAUS_DIR}/${PROJECT_CONFIG_FILE}`;
3784
+ function normalizeIdList(value) {
3785
+ if (!Array.isArray(value)) return [];
3786
+ return [
3787
+ ...new Set(
3788
+ value.filter((entry) => typeof entry === "string" && entry.length > 0)
3789
+ )
3790
+ ];
3791
+ }
3792
+ async function readProjectConfigObject(root) {
3793
+ try {
3794
+ const data = await readJson(hausPath(root, PROJECT_CONFIG_FILE));
3795
+ if (data == null || typeof data !== "object" || Array.isArray(data)) return null;
3796
+ return data;
3797
+ } catch (err) {
3798
+ if (err.code === "ENOENT") return null;
3799
+ warn(
3800
+ `${PROJECT_CONFIG_REL} could not be read (${err instanceof Error ? err.message : String(err)}), treating project intent as unset`
3801
+ );
3802
+ return null;
3803
+ }
3804
+ }
3805
+ function refuseConfig(parserMessage) {
3806
+ error(notValidLine(PROJECT_CONFIG_REL, "JSON", parserMessage));
3807
+ return { refused: true };
3808
+ }
3809
+ async function readConfigToEdit(root) {
3810
+ const read = await readTextDetailed(hausPath(root, PROJECT_CONFIG_FILE));
3811
+ if (read.status === "unreadable") {
3812
+ const linkedMissing = await linkedFileRefusal(root, PROJECT_CONFIG_REL);
3813
+ error(linkedMissing ?? unreadableLine(PROJECT_CONFIG_REL, messageOf(read.error)));
3814
+ return { refused: true };
3815
+ }
3816
+ if (read.status === "missing") return { existing: {} };
3817
+ let value;
3818
+ try {
3819
+ value = JSON.parse(read.text);
3820
+ } catch (err) {
3821
+ return refuseConfig(messageOf(err));
3822
+ }
3823
+ if (!isPlainObject(value)) return refuseConfig(NOT_A_JSON_OBJECT);
3824
+ return { existing: value };
3825
+ }
3826
+ async function checkProjectConfigEditable(root) {
3827
+ const read = await readConfigToEdit(root);
3828
+ if ("refused" in read) return read;
3829
+ const linked = await linkedFileRefusal(root, PROJECT_CONFIG_REL);
3830
+ if (linked !== null) {
3831
+ error(linked);
3832
+ return { refused: true };
3833
+ }
3834
+ return null;
3835
+ }
3836
+ async function updateProjectConfig(root, mutate, opts = {}) {
3837
+ const file = hausPath(root, PROJECT_CONFIG_FILE);
3838
+ const read = await readConfigToEdit(root);
3839
+ if ("refused" in read) return read;
3840
+ const { existing } = read;
3841
+ const next = mutate({ ...existing });
3842
+ const linked = await linkedFileRefusal(root, PROJECT_CONFIG_REL);
3843
+ let written;
3844
+ try {
3845
+ written = await writeJsonRecord(file, next, { dryRun: opts.dryRun === true || linked !== null });
3846
+ } catch (err) {
3847
+ if (!(err instanceof MalformedJsonFileError)) throw err;
3848
+ return refuseConfig(messageOf(err.cause));
3849
+ }
3850
+ if (linked !== null && written !== "unchanged") {
3851
+ error(linked);
3852
+ return { refused: true };
3853
+ }
3854
+ if (written === "unchanged") {
3855
+ return {
3856
+ file: PROJECT_CONFIG_REL,
3857
+ outcome: "unchanged",
3858
+ added: [],
3859
+ removed: [],
3860
+ reRecorded: []
3861
+ };
3862
+ }
3863
+ return {
3864
+ file: PROJECT_CONFIG_REL,
3865
+ outcome: "changed",
3866
+ ...recordDelta(keyRows(existing), keyRows(next))
3867
+ };
3868
+ }
3869
+ function withdrawIncludedIds(existing, ids) {
3870
+ const drop = new Set(ids);
3871
+ return normalizeIdList(existing.includedIds).filter((id) => !drop.has(id));
3872
+ }
3873
+
3874
+ // src/claude/workflow-template.ts
3875
+ import path23 from "node:path";
3876
+ import fs9 from "fs-extra";
3877
+ var WORKFLOW_TEMPLATE_REL = "templates/agentic-workflow-standard.md";
3878
+ async function readWorkflowTemplate(opts = {}) {
3879
+ const file = path23.join(packageRoot(), "packages", opts.templateRel ?? WORKFLOW_TEMPLATE_REL);
3880
+ try {
3881
+ return await fs9.readFile(file, "utf8");
3882
+ } catch {
3883
+ return null;
3884
+ }
3885
+ }
3886
+
3887
+ // src/claude/project-profile.ts
3888
+ var PROFILE_IDS = ["production", "poc"];
3889
+ var DEFAULT_PROFILE = "production";
3890
+ var PROFILES = {
3891
+ production: {
3892
+ workflowTemplateRel: WORKFLOW_TEMPLATE_REL,
3893
+ writesGate: true,
3894
+ writesDecisionsSeed: true,
3895
+ runsDocsPass: true,
3896
+ droppedHookCommands: [],
3897
+ workflowConfig: "standard"
3898
+ },
3899
+ poc: {
3900
+ // Catalog item `haus.agentic-workflow-poc` (catalog ADR-0066); fetched by path for WORKFLOW.md, exactly like the production standard, and kept out of item recommendations by id (Task 3).
3901
+ workflowTemplateRel: "templates/agentic-workflow-poc.md",
3902
+ writesGate: false,
3903
+ writesDecisionsSeed: false,
3904
+ runsDocsPass: false,
3905
+ droppedHookCommands: ["haus decisions guard --from-hook", "haus decisions suggest --from-hook"],
3906
+ workflowConfig: "poc"
3907
+ }
3908
+ };
3909
+ function isProfileId(value) {
3910
+ return typeof value === "string" && PROFILE_IDS.includes(value);
3911
+ }
3912
+ function parseProfile(value) {
3913
+ if (value === void 0 || value === null) return { profile: DEFAULT_PROFILE, malformed: false };
3914
+ if (isProfileId(value)) return { profile: value, malformed: false };
3915
+ return { profile: DEFAULT_PROFILE, malformed: true };
3916
+ }
3917
+ async function readProjectProfile(root) {
3918
+ const data = await readProjectConfigObject(root);
3919
+ const { profile, malformed } = parseProfile(data?.profile);
3920
+ if (malformed) {
3921
+ warn(
3922
+ `${PROJECT_CONFIG_REL}: unknown profile ${JSON.stringify(data?.profile)}: expected one of ${PROFILE_IDS.join(", ")}; treating as ${DEFAULT_PROFILE}`
3923
+ );
3924
+ }
3925
+ return profile;
3926
+ }
3927
+ async function readProjectProfileOr(root, fallback2) {
3928
+ const data = await readProjectConfigObject(root);
3929
+ if (data?.profile === void 0 || data.profile === null) return fallback2;
3930
+ return readProjectProfile(root);
3931
+ }
3932
+ async function writeProjectProfile(root, profile, opts = {}) {
3933
+ return updateProjectConfig(root, (existing) => ({ ...existing, profile }), opts);
3934
+ }
3935
+ function pocLockedMessage() {
3936
+ return `This repo is a PoC (profile "poc" in ${PROJECT_CONFIG_REL}). Production starts from zero in a new repo, with docs/MANUS.md as input (\`/haus-workflow new\` in production mode). To re-run setup here, pass \`haus init --profile poc\`. To leave the PoC profile on purpose, remove the "profile" line from ${PROJECT_CONFIG_REL} by hand. Nothing was written.`;
3937
+ }
3938
+ var SYNC_SESSION_COMMAND = "haus sync --session-hook";
3939
+ function droppedHookCommands(profile, sessionSyncHook) {
3940
+ const dropped = new Set(PROFILES[profile].droppedHookCommands);
3941
+ if (!sessionSyncHook) dropped.add(SYNC_SESSION_COMMAND);
3942
+ return dropped;
3943
+ }
3944
+
3947
3945
  // src/claude/merge-project-settings.ts
3948
3946
  var SETTINGS_FILE = ".claude/settings.json";
3949
3947
  var PROJECT_HOOK_FRAGMENTS = [
@@ -6598,7 +6596,6 @@ async function writeClaudeFilesReport(root, dryRun, opts) {
6598
6596
  root,
6599
6597
  (await projectRouting(root, opts.projectSync, opts.plannedHausJson)).routing,
6600
6598
  dryRun,
6601
- profile,
6602
6599
  opts.quiet
6603
6600
  );
6604
6601
  if (typeof agentsMd === "object" && agentsMd.reason === "lone-begin") {
@@ -10724,7 +10721,7 @@ async function listMarkdownFiles(dir) {
10724
10721
  (entry) => path57.relative(dir, path57.join(entry.parentPath, entry.name)).split(path57.sep).join("/")
10725
10722
  ).sort();
10726
10723
  }
10727
- async function auditDecisionsLayout(root, profile, opts = {}) {
10724
+ async function auditDecisionsLayout(root, profile) {
10728
10725
  const findings = [];
10729
10726
  const primary = path57.join(root, DECISIONS_TRIGGERS.decisionsDir);
10730
10727
  const legacy = path57.join(root, DECISIONS_TRIGGERS.legacyDecisionsDir ?? "docs/adr");
@@ -10766,14 +10763,13 @@ async function auditDecisionsLayout(root, profile, opts = {}) {
10766
10763
  fix: `rename it to NNNN-<slug>.md (haus decisions next-number), or move a note or template out of ${rel}/`
10767
10764
  });
10768
10765
  }
10769
- const importHome = opts.importHome ?? "AGENTS.md";
10770
10766
  const readmePath = path57.join(decisionsDir, "README.md");
10771
10767
  if (!await fs26.pathExists(readmePath)) {
10772
10768
  findings.push({
10773
10769
  level: "advisory",
10774
10770
  line: `- DECISIONS: missing ${rel}/README.md index`,
10775
- sentence: "No decision index for agents to load at session start",
10776
- fix: `create ${rel}/README.md and @import it from ${importHome}`
10771
+ sentence: "No decision index for agents to search before a decision",
10772
+ fix: `create ${rel}/README.md (haus apply --write seeds it)`
10777
10773
  });
10778
10774
  return findings;
10779
10775
  }
@@ -10792,17 +10788,6 @@ async function auditDecisionsLayout(root, profile, opts = {}) {
10792
10788
  });
10793
10789
  }
10794
10790
  }
10795
- const importLine = `@${rel}/README.md`;
10796
- const claude = await readText(path57.join(root, "CLAUDE.md"));
10797
- const agents = importHome === "AGENTS.md" ? await readText(path57.join(root, "AGENTS.md")) : null;
10798
- if ((claude || agents) && !claude?.includes(importLine) && !agents?.includes(importLine)) {
10799
- findings.push({
10800
- level: "advisory",
10801
- line: importHome === "CLAUDE.md" ? `- DECISIONS: CLAUDE.md does not @import ${importLine}` : `- DECISIONS: neither AGENTS.md nor CLAUDE.md @imports ${importLine}`,
10802
- sentence: "Agents may not load the decision index at session start",
10803
- fix: `add ${importLine} to ${importHome}`
10804
- });
10805
- }
10806
10791
  const numbers = await listDecisionNumbers(decisionsDir);
10807
10792
  const dupes = numbers.filter((n, i) => numbers.indexOf(n) !== i);
10808
10793
  if (dupes.length > 0) {
@@ -12306,11 +12291,19 @@ async function runDoctor(options, deps = {}) {
12306
12291
  const actualTargets = [...block.matchAll(importLinePattern)].map((m) => m[1]);
12307
12292
  const expectedTargets = [...expectedImports.matchAll(importLinePattern)].map((m) => m[1]);
12308
12293
  const missingTargets = expectedTargets.filter((t) => !actualTargets.includes(t));
12309
- const foreignTargets2 = actualTargets.filter((t) => !expectedTargets.includes(t));
12310
- if (missingTargets.length > 0 || foreignTargets2.length > 0) {
12294
+ const unexpected = actualTargets.filter((t) => !expectedTargets.includes(t));
12295
+ const retiredTargets = unexpected.filter((t) => RETIRED_IMPORTS.includes(t ?? ""));
12296
+ const foreignTargets2 = unexpected.filter((t) => !RETIRED_IMPORTS.includes(t ?? ""));
12297
+ if (missingTargets.length === 0 && foreignTargets2.length === 0 && retiredTargets.length > 0) {
12298
+ suggest(
12299
+ `- ${file}: haus import block still imports @${retiredTargets.join(", @")}, which haus no longer loads every session (run \`haus apply --write\` to trim it)`,
12300
+ `The haus import block in ${file} still loads the decisions index into every session`,
12301
+ "haus apply --write"
12302
+ );
12303
+ } else if (missingTargets.length > 0 || foreignTargets2.length > 0) {
12311
12304
  const parts = [];
12312
12305
  if (missingTargets.length > 0) parts.push(`missing @${missingTargets.join(", @")}`);
12313
- if (foreignTargets2.length > 0) parts.push(`unexpected @${foreignTargets2.join(", @")}`);
12306
+ if (unexpected.length > 0) parts.push(`unexpected @${unexpected.join(", @")}`);
12314
12307
  flag(
12315
12308
  `- ${file}: haus import block content does not match expected imports (${parts.join("; ")}) (run \`haus apply --write\` to repair)`,
12316
12309
  `The haus import block in ${file} has been altered and no longer imports the expected files`,
@@ -12354,7 +12347,7 @@ async function runDoctor(options, deps = {}) {
12354
12347
  "CLAUDE.md",
12355
12348
  rootClaudeMdContent,
12356
12349
  { begin: BLOCK_BEGIN, end: BLOCK_END },
12357
- preSyncLayout ? importContentFor(profile) : `@${AGENTS_MD_FILE}`
12350
+ preSyncLayout ? IMPORT_CONTENT : `@${AGENTS_MD_FILE}`
12358
12351
  );
12359
12352
  }
12360
12353
  if (!preSyncLayout) {
@@ -12362,10 +12355,10 @@ async function runDoctor(options, deps = {}) {
12362
12355
  AGENTS_MD_FILE,
12363
12356
  await readText(path66.join(root, AGENTS_MD_FILE)),
12364
12357
  AGENTS_SENTINELS,
12365
- importContentFor(profile),
12358
+ IMPORT_CONTENT,
12366
12359
  // The whole block, routing lines included, as apply would write it from the same source
12367
12360
  // (the pinned release in the mirror, else the block's own lines, else the bundled file).
12368
- buildAgentsBlock(profile, (await projectRouting(root, projectSync)).routing)
12361
+ buildAgentsBlock((await projectRouting(root, projectSync)).routing)
12369
12362
  );
12370
12363
  }
12371
12364
  if (!claudeIsAgents && rootClaudeMdContent && rootClaudeMdContent.includes(WORKSPACE_BLOCK_BEGIN) && !rootClaudeMdContent.includes(BLOCK_BEGIN)) {
@@ -12586,9 +12579,7 @@ async function runDoctor(options, deps = {}) {
12586
12579
  } else {
12587
12580
  ok2("- GITIGNORE (haus content): OK (.claude/ and .haus-workflow/ are tracked)");
12588
12581
  }
12589
- for (const finding of await auditDecisionsLayout(root, profile, {
12590
- importHome: preSyncLayout ? "CLAUDE.md" : "AGENTS.md"
12591
- })) {
12582
+ for (const finding of await auditDecisionsLayout(root, profile)) {
12592
12583
  if (finding.level === "ok") ok2(finding.line);
12593
12584
  else suggest(finding.line, finding.sentence, finding.fix);
12594
12585
  }
@@ -31640,10 +31631,10 @@ var WORKSPACE_SETUP_WRITE = "haus workspace setup --write";
31640
31631
  function buildWorkspaceImportBlock(client, members) {
31641
31632
  const memberLines = members.map((m) => `- ${m.name} (${m.path})`);
31642
31633
  const body = [
31643
- "@.haus-workflow/cross-repo-summary.md",
31644
- "",
31645
31634
  `# Workspace: ${client}`,
31646
31635
  "",
31636
+ "Cross-repo summary, read on demand: `.haus-workflow/cross-repo-summary.md`.",
31637
+ "",
31647
31638
  "Member repos:",
31648
31639
  "",
31649
31640
  ...memberLines
@@ -31658,6 +31649,24 @@ function workspaceDocBody(client, members) {
31658
31649
  return `${buildWorkspaceImportBlock(client, members)}
31659
31650
  `;
31660
31651
  }
31652
+ function workspaceDocBeforeAdr0197(client, members) {
31653
+ const memberLines = members.map((m) => `- ${m.name} (${m.path})`);
31654
+ const body = [
31655
+ "@.haus-workflow/cross-repo-summary.md",
31656
+ "",
31657
+ `# Workspace: ${client}`,
31658
+ "",
31659
+ "Member repos:",
31660
+ "",
31661
+ ...memberLines
31662
+ ].join("\n");
31663
+ return `${WORKSPACE_BLOCK_BEGIN}
31664
+
31665
+ ${body}
31666
+
31667
+ ${WORKSPACE_BLOCK_END}
31668
+ `;
31669
+ }
31661
31670
  function workspaceDocBefore371(client, members) {
31662
31671
  const memberLines = members.map((m) => `- ${m.name} (${m.path})`);
31663
31672
  const body = [
@@ -31689,7 +31698,11 @@ ${body}
31689
31698
  `;
31690
31699
  }
31691
31700
  function knownWorkspaceDocBodies(client, members) {
31692
- return [workspaceDocBefore371(client, members), workspaceDocBeforeAdr0030(client, members)];
31701
+ return [
31702
+ workspaceDocBeforeAdr0197(client, members),
31703
+ workspaceDocBefore371(client, members),
31704
+ workspaceDocBeforeAdr0030(client, members)
31705
+ ];
31693
31706
  }
31694
31707
  function refusesWorkspaceClaudeMd(text) {
31695
31708
  return "refused" in injectHausBlock(text, "", WORKSPACE_SENTINELS);