@hasna/instructions 0.4.39 → 0.4.42

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
@@ -20,14 +20,12 @@ var __toESM = (mod, isNodeMode, target) => {
20
20
  }
21
21
  target = mod != null ? __create(__getProtoOf(mod)) : {};
22
22
  const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
23
- if (mod && typeof mod === "object" || typeof mod === "function") {
24
- for (let key of __getOwnPropNames(mod))
25
- if (!__hasOwnProp.call(to, key))
26
- __defProp(to, key, {
27
- get: __accessProp.bind(mod, key),
28
- enumerable: true
29
- });
30
- }
23
+ for (let key of __getOwnPropNames(mod))
24
+ if (!__hasOwnProp.call(to, key))
25
+ __defProp(to, key, {
26
+ get: __accessProp.bind(mod, key),
27
+ enumerable: true
28
+ });
31
29
  if (canCache)
32
30
  cache.set(mod, to);
33
31
  return to;
@@ -50,7 +48,7 @@ var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
50
48
  var __require = import.meta.require;
51
49
 
52
50
  // ../../node_modules/.bun/commander@13.1.0/node_modules/commander/lib/error.js
53
- var require_error = __commonJS(function(exports) {
51
+ var require_error = __commonJS((exports) => {
54
52
  class CommanderError extends Error {
55
53
  constructor(exitCode, code, message) {
56
54
  super(message);
@@ -74,7 +72,7 @@ var require_error = __commonJS(function(exports) {
74
72
  });
75
73
 
76
74
  // ../../node_modules/.bun/commander@13.1.0/node_modules/commander/lib/argument.js
77
- var require_argument = __commonJS(function(exports) {
75
+ var require_argument = __commonJS((exports) => {
78
76
  var { InvalidArgumentError } = require_error();
79
77
 
80
78
  class Argument {
@@ -153,7 +151,7 @@ var require_argument = __commonJS(function(exports) {
153
151
  });
154
152
 
155
153
  // ../../node_modules/.bun/commander@13.1.0/node_modules/commander/lib/help.js
156
- var require_help = __commonJS(function(exports) {
154
+ var require_help = __commonJS((exports) => {
157
155
  var { humanReadableArgName } = require_argument();
158
156
 
159
157
  class Help {
@@ -503,7 +501,7 @@ ${itemIndentStr}`);
503
501
  });
504
502
 
505
503
  // ../../node_modules/.bun/commander@13.1.0/node_modules/commander/lib/option.js
506
- var require_option = __commonJS(function(exports) {
504
+ var require_option = __commonJS((exports) => {
507
505
  var { InvalidArgumentError } = require_error();
508
506
 
509
507
  class Option {
@@ -681,7 +679,7 @@ var require_option = __commonJS(function(exports) {
681
679
  });
682
680
 
683
681
  // ../../node_modules/.bun/commander@13.1.0/node_modules/commander/lib/suggestSimilar.js
684
- var require_suggestSimilar = __commonJS(function(exports) {
682
+ var require_suggestSimilar = __commonJS((exports) => {
685
683
  var maxDistance = 3;
686
684
  function editDistance(a, b) {
687
685
  if (Math.abs(a.length - b.length) > maxDistance)
@@ -754,7 +752,7 @@ var require_suggestSimilar = __commonJS(function(exports) {
754
752
  });
755
753
 
756
754
  // ../../node_modules/.bun/commander@13.1.0/node_modules/commander/lib/command.js
757
- var require_command = __commonJS(function(exports) {
755
+ var require_command = __commonJS((exports) => {
758
756
  var EventEmitter = __require("events").EventEmitter;
759
757
  var childProcess = __require("child_process");
760
758
  var path = __require("path");
@@ -2064,7 +2062,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
2064
2062
  });
2065
2063
 
2066
2064
  // ../../node_modules/.bun/commander@13.1.0/node_modules/commander/index.js
2067
- var require_commander = __commonJS(function(exports) {
2065
+ var require_commander = __commonJS((exports) => {
2068
2066
  var { Argument } = require_argument();
2069
2067
  var { Command } = require_command();
2070
2068
  var { CommanderError, InvalidArgumentError } = require_error();
@@ -2592,11 +2590,11 @@ var init_configs = __esm(() => {
2592
2590
  // src/lib/template.ts
2593
2591
  var exports_template = {};
2594
2592
  __export(exports_template, {
2595
- extractTemplateVars: () => extractTemplateVars,
2596
- isTemplate: () => isTemplate,
2597
- parseTemplateVars: () => parseTemplateVars,
2593
+ renderTemplatePreview: () => renderTemplatePreview,
2598
2594
  renderTemplate: () => renderTemplate,
2599
- renderTemplatePreview: () => renderTemplatePreview
2595
+ parseTemplateVars: () => parseTemplateVars,
2596
+ isTemplate: () => isTemplate,
2597
+ extractTemplateVars: () => extractTemplateVars
2600
2598
  });
2601
2599
  function parseTemplateVars(content) {
2602
2600
  const names = new Set;
@@ -6956,113 +6954,113 @@ var init_types2 = __esm(() => {
6956
6954
  // ../../node_modules/.bun/zod@3.25.76/node_modules/zod/v3/external.js
6957
6955
  var exports_external = {};
6958
6956
  __export(exports_external, {
6959
- BRAND: () => BRAND,
6960
- DIRTY: () => DIRTY,
6961
- EMPTY_PATH: () => EMPTY_PATH,
6962
- INVALID: () => INVALID,
6963
- NEVER: () => NEVER,
6964
- OK: () => OK,
6965
- ParseStatus: () => ParseStatus,
6966
- Schema: () => ZodType,
6967
- ZodAny: () => ZodAny,
6968
- ZodArray: () => ZodArray,
6969
- ZodBigInt: () => ZodBigInt,
6970
- ZodBoolean: () => ZodBoolean,
6971
- ZodBranded: () => ZodBranded,
6972
- ZodCatch: () => ZodCatch,
6973
- ZodDate: () => ZodDate,
6974
- ZodDefault: () => ZodDefault,
6975
- ZodDiscriminatedUnion: () => ZodDiscriminatedUnion,
6976
- ZodEffects: () => ZodEffects,
6977
- ZodEnum: () => ZodEnum,
6978
- ZodError: () => ZodError,
6979
- ZodFirstPartyTypeKind: () => ZodFirstPartyTypeKind,
6980
- ZodFunction: () => ZodFunction,
6981
- ZodIntersection: () => ZodIntersection,
6982
- ZodIssueCode: () => ZodIssueCode,
6983
- ZodLazy: () => ZodLazy,
6984
- ZodLiteral: () => ZodLiteral,
6985
- ZodMap: () => ZodMap,
6986
- ZodNaN: () => ZodNaN,
6987
- ZodNativeEnum: () => ZodNativeEnum,
6988
- ZodNever: () => ZodNever,
6989
- ZodNull: () => ZodNull,
6990
- ZodNullable: () => ZodNullable,
6991
- ZodNumber: () => ZodNumber,
6992
- ZodObject: () => ZodObject,
6993
- ZodOptional: () => ZodOptional,
6994
- ZodParsedType: () => ZodParsedType,
6995
- ZodPipeline: () => ZodPipeline,
6996
- ZodPromise: () => ZodPromise,
6997
- ZodReadonly: () => ZodReadonly,
6998
- ZodRecord: () => ZodRecord,
6999
- ZodSchema: () => ZodType,
7000
- ZodSet: () => ZodSet,
7001
- ZodString: () => ZodString,
7002
- ZodSymbol: () => ZodSymbol,
7003
- ZodTransformer: () => ZodEffects,
7004
- ZodTuple: () => ZodTuple,
7005
- ZodType: () => ZodType,
7006
- ZodUndefined: () => ZodUndefined,
7007
- ZodUnion: () => ZodUnion,
7008
- ZodUnknown: () => ZodUnknown,
7009
- ZodVoid: () => ZodVoid,
7010
- addIssueToContext: () => addIssueToContext,
7011
- any: () => anyType,
7012
- array: () => arrayType,
7013
- bigint: () => bigIntType,
7014
- boolean: () => booleanType,
7015
- coerce: () => coerce,
7016
- custom: () => custom,
7017
- date: () => dateType,
7018
- datetimeRegex: () => datetimeRegex,
7019
- defaultErrorMap: () => en_default,
7020
- discriminatedUnion: () => discriminatedUnionType,
7021
- effect: () => effectsType,
7022
- enum: () => enumType,
7023
- function: () => functionType,
7024
- getErrorMap: () => getErrorMap,
7025
- getParsedType: () => getParsedType,
7026
- instanceof: () => instanceOfType,
7027
- intersection: () => intersectionType,
7028
- isAborted: () => isAborted,
7029
- isAsync: () => isAsync,
7030
- isDirty: () => isDirty,
7031
- isValid: () => isValid,
7032
- late: () => late,
7033
- lazy: () => lazyType,
7034
- literal: () => literalType,
7035
- makeIssue: () => makeIssue,
7036
- map: () => mapType,
7037
- nan: () => nanType,
7038
- nativeEnum: () => nativeEnumType,
7039
- never: () => neverType,
7040
- null: () => nullType,
7041
- nullable: () => nullableType,
7042
- number: () => numberType,
7043
- object: () => objectType,
7044
- objectUtil: () => objectUtil,
7045
- oboolean: () => oboolean,
7046
- onumber: () => onumber,
7047
- optional: () => optionalType,
7048
- ostring: () => ostring,
7049
- pipeline: () => pipelineType,
7050
- preprocess: () => preprocessType,
7051
- promise: () => promiseType,
7052
- quotelessJson: () => quotelessJson,
7053
- record: () => recordType,
7054
- set: () => setType,
7055
- setErrorMap: () => setErrorMap,
7056
- strictObject: () => strictObjectType,
7057
- string: () => stringType,
7058
- symbol: () => symbolType,
7059
- transformer: () => effectsType,
7060
- tuple: () => tupleType,
7061
- undefined: () => undefinedType,
7062
- union: () => unionType,
7063
- unknown: () => unknownType,
6957
+ void: () => voidType,
7064
6958
  util: () => util,
7065
- void: () => voidType
6959
+ unknown: () => unknownType,
6960
+ union: () => unionType,
6961
+ undefined: () => undefinedType,
6962
+ tuple: () => tupleType,
6963
+ transformer: () => effectsType,
6964
+ symbol: () => symbolType,
6965
+ string: () => stringType,
6966
+ strictObject: () => strictObjectType,
6967
+ setErrorMap: () => setErrorMap,
6968
+ set: () => setType,
6969
+ record: () => recordType,
6970
+ quotelessJson: () => quotelessJson,
6971
+ promise: () => promiseType,
6972
+ preprocess: () => preprocessType,
6973
+ pipeline: () => pipelineType,
6974
+ ostring: () => ostring,
6975
+ optional: () => optionalType,
6976
+ onumber: () => onumber,
6977
+ oboolean: () => oboolean,
6978
+ objectUtil: () => objectUtil,
6979
+ object: () => objectType,
6980
+ number: () => numberType,
6981
+ nullable: () => nullableType,
6982
+ null: () => nullType,
6983
+ never: () => neverType,
6984
+ nativeEnum: () => nativeEnumType,
6985
+ nan: () => nanType,
6986
+ map: () => mapType,
6987
+ makeIssue: () => makeIssue,
6988
+ literal: () => literalType,
6989
+ lazy: () => lazyType,
6990
+ late: () => late,
6991
+ isValid: () => isValid,
6992
+ isDirty: () => isDirty,
6993
+ isAsync: () => isAsync,
6994
+ isAborted: () => isAborted,
6995
+ intersection: () => intersectionType,
6996
+ instanceof: () => instanceOfType,
6997
+ getParsedType: () => getParsedType,
6998
+ getErrorMap: () => getErrorMap,
6999
+ function: () => functionType,
7000
+ enum: () => enumType,
7001
+ effect: () => effectsType,
7002
+ discriminatedUnion: () => discriminatedUnionType,
7003
+ defaultErrorMap: () => en_default,
7004
+ datetimeRegex: () => datetimeRegex,
7005
+ date: () => dateType,
7006
+ custom: () => custom,
7007
+ coerce: () => coerce,
7008
+ boolean: () => booleanType,
7009
+ bigint: () => bigIntType,
7010
+ array: () => arrayType,
7011
+ any: () => anyType,
7012
+ addIssueToContext: () => addIssueToContext,
7013
+ ZodVoid: () => ZodVoid,
7014
+ ZodUnknown: () => ZodUnknown,
7015
+ ZodUnion: () => ZodUnion,
7016
+ ZodUndefined: () => ZodUndefined,
7017
+ ZodType: () => ZodType,
7018
+ ZodTuple: () => ZodTuple,
7019
+ ZodTransformer: () => ZodEffects,
7020
+ ZodSymbol: () => ZodSymbol,
7021
+ ZodString: () => ZodString,
7022
+ ZodSet: () => ZodSet,
7023
+ ZodSchema: () => ZodType,
7024
+ ZodRecord: () => ZodRecord,
7025
+ ZodReadonly: () => ZodReadonly,
7026
+ ZodPromise: () => ZodPromise,
7027
+ ZodPipeline: () => ZodPipeline,
7028
+ ZodParsedType: () => ZodParsedType,
7029
+ ZodOptional: () => ZodOptional,
7030
+ ZodObject: () => ZodObject,
7031
+ ZodNumber: () => ZodNumber,
7032
+ ZodNullable: () => ZodNullable,
7033
+ ZodNull: () => ZodNull,
7034
+ ZodNever: () => ZodNever,
7035
+ ZodNativeEnum: () => ZodNativeEnum,
7036
+ ZodNaN: () => ZodNaN,
7037
+ ZodMap: () => ZodMap,
7038
+ ZodLiteral: () => ZodLiteral,
7039
+ ZodLazy: () => ZodLazy,
7040
+ ZodIssueCode: () => ZodIssueCode,
7041
+ ZodIntersection: () => ZodIntersection,
7042
+ ZodFunction: () => ZodFunction,
7043
+ ZodFirstPartyTypeKind: () => ZodFirstPartyTypeKind,
7044
+ ZodError: () => ZodError,
7045
+ ZodEnum: () => ZodEnum,
7046
+ ZodEffects: () => ZodEffects,
7047
+ ZodDiscriminatedUnion: () => ZodDiscriminatedUnion,
7048
+ ZodDefault: () => ZodDefault,
7049
+ ZodDate: () => ZodDate,
7050
+ ZodCatch: () => ZodCatch,
7051
+ ZodBranded: () => ZodBranded,
7052
+ ZodBoolean: () => ZodBoolean,
7053
+ ZodBigInt: () => ZodBigInt,
7054
+ ZodArray: () => ZodArray,
7055
+ ZodAny: () => ZodAny,
7056
+ Schema: () => ZodType,
7057
+ ParseStatus: () => ParseStatus,
7058
+ OK: () => OK,
7059
+ NEVER: () => NEVER,
7060
+ INVALID: () => INVALID,
7061
+ EMPTY_PATH: () => EMPTY_PATH,
7062
+ DIRTY: () => DIRTY,
7063
+ BRAND: () => BRAND
7066
7064
  });
7067
7065
  var init_external = __esm(() => {
7068
7066
  init_errors();
@@ -11463,16 +11461,50 @@ function indexHeader(tool, profile) {
11463
11461
  ].join(`
11464
11462
  `);
11465
11463
  }
11466
- function buildNativeImportFiles(targetHome, adapter, profile, sources) {
11464
+ function isCompiledClaudeGlobSource(adapter, source, providerVersion) {
11465
+ if (adapter.tool !== "claude")
11466
+ return false;
11467
+ if (providerVersion && !providerVersionSatisfies(providerVersion, CLAUDE_PATHS_RULES_VERSION_RANGE))
11468
+ return false;
11469
+ const compiledBinding = source.provenance?.["profileBinding"];
11470
+ if (!compiledBinding || typeof compiledBinding !== "object")
11471
+ return false;
11472
+ const activation = source.metadata?.["activation"];
11473
+ return activation?.mode === "glob";
11474
+ }
11475
+ function claudeGlobRuleFile(targetHome, index, source) {
11476
+ const globs = source.globs ?? [];
11477
+ if (globs.length === 0)
11478
+ throw new Error(`Claude glob source ${source.id} has no paths.`);
11479
+ const n = String(index + 1).padStart(2, "0");
11480
+ const relativePath = posix2.join("rules", `${n}-${source.normalizedId}.md`);
11481
+ const content = [
11482
+ "---",
11483
+ "paths:",
11484
+ ...globs.map((glob) => ` - ${yamlQuote2(glob)}`),
11485
+ "---",
11486
+ "",
11487
+ sectionForSource(source),
11488
+ ...source.resolvedRules.flatMap((rule) => ["", sectionForRule(source, rule)])
11489
+ ].join(`
11490
+ `);
11491
+ return makeFile(targetHome, relativePath, "rule", content, [source.id, ...source.resolvedRules.map((rule) => rule.id)]);
11492
+ }
11493
+ function buildNativeImportFiles(targetHome, adapter, profile, sources, providerVersion) {
11467
11494
  const indexFile = adapter.indexFile;
11468
- const fragments = sources.flatMap((source, index2) => [
11469
- makeFile(targetHome, fragmentPath(adapter, index2, source), "fragment", sectionForSource(source), [source.id]),
11470
- ...source.resolvedRules.map((rule) => makeFile(targetHome, ruleFragmentPath(adapter, source, rule), "rule", sectionForRule(source, rule), [source.id, rule.id]))
11471
- ]);
11495
+ const fragments = sources.flatMap((source, index2) => {
11496
+ if (isCompiledClaudeGlobSource(adapter, source, providerVersion))
11497
+ return [];
11498
+ return [
11499
+ makeFile(targetHome, fragmentPath(adapter, index2, source), "fragment", sectionForSource(source), [source.id]),
11500
+ ...source.resolvedRules.map((rule) => makeFile(targetHome, ruleFragmentPath(adapter, source, rule), "rule", sectionForRule(source, rule), [source.id, rule.id]))
11501
+ ];
11502
+ });
11503
+ const conditionalRules = sources.flatMap((source, index2) => isCompiledClaudeGlobSource(adapter, source, providerVersion) ? [claudeGlobRuleFile(targetHome, index2, source)] : []);
11472
11504
  const imports = fragments.map((file) => `@${importPath(indexFile, file.relativePath)}`);
11473
11505
  const index = makeFile(targetHome, indexFile, "index", [indexHeader(adapter.tool, profile), ...imports].join(`
11474
11506
  `), sources.map((source) => source.id));
11475
- return [index, ...fragments];
11507
+ return [index, ...fragments, ...conditionalRules];
11476
11508
  }
11477
11509
  function buildFlattenedMarkdownFiles(targetHome, adapter, profile, sources) {
11478
11510
  const content = [
@@ -11660,10 +11692,10 @@ function makeAntigravityRuleFile(targetHome, relativePath, content, sourceIds) {
11660
11692
  }
11661
11693
  return file;
11662
11694
  }
11663
- function buildFiles(targetHome, adapter, profile, sources, providerConfig) {
11695
+ function buildFiles(targetHome, adapter, profile, sources, providerConfig, providerVersion) {
11664
11696
  switch (adapter.mode) {
11665
11697
  case "native-imports":
11666
- return buildNativeImportFiles(targetHome, adapter, profile, sources);
11698
+ return buildNativeImportFiles(targetHome, adapter, profile, sources, providerVersion);
11667
11699
  case "flattened-markdown":
11668
11700
  return buildFlattenedMarkdownFiles(targetHome, adapter, profile, sources);
11669
11701
  case "cursor-mdc":
@@ -11910,7 +11942,7 @@ function planSessionRender(input) {
11910
11942
  if (input.providerConfig && input.tool !== "opencode") {
11911
11943
  throw new Error("Provider base config is supported only for OpenCode session renders.");
11912
11944
  }
11913
- const baseFiles = blocked ? [] : buildFiles(targetHome, adapter, input.profile, orderedSources, input.providerConfig);
11945
+ const baseFiles = blocked ? [] : buildFiles(targetHome, adapter, input.profile, orderedSources, input.providerConfig, input.provider_version);
11914
11946
  const projectContext = blocked ? null : composeProjectContextSessionRender({
11915
11947
  tool: input.tool,
11916
11948
  adapter_mode: adapter.mode,
@@ -12410,7 +12442,7 @@ function asStringArray(value) {
12410
12442
  return [];
12411
12443
  return value.filter((item) => typeof item === "string");
12412
12444
  }
12413
- var ANTIGRAVITY_RULE_FILE_CHAR_LIMIT = 12000, SESSION_RENDERER_OWNER_ID = "instructions-session-renderer", SESSION_RENDER_TOOLS, SESSION_RENDER_PROFILE_ENTRYPOINTS, SESSION_RENDER_OWNED_CONFIG_TARGETS, IDENTITY_EXPORT_AUTHORITY, CODEWITH_PROTECTED_REPLACEMENT_TARGETS, CODEWITH_FLATTENED_ADAPTER, CODEWITH_NATIVE_ADAPTER, SESSION_TOOL_ADAPTERS, SESSION_RENDER_MANAGED_DIRS, SESSION_RENDER_SHARED_MANAGED_DIRS, SESSION_RENDER_EXCLUSIVE_MANAGED_PATHS, SESSION_LAYER_RANK, CANONICAL_IDENTITY_EXPORT_PACKAGES;
12445
+ var ANTIGRAVITY_RULE_FILE_CHAR_LIMIT = 12000, SESSION_RENDERER_OWNER_ID = "instructions-session-renderer", SESSION_RENDER_TOOLS, SESSION_RENDER_PROFILE_ENTRYPOINTS, SESSION_RENDER_OWNED_CONFIG_TARGETS, IDENTITY_EXPORT_AUTHORITY, CODEWITH_PROTECTED_REPLACEMENT_TARGETS, CODEWITH_FLATTENED_ADAPTER, CODEWITH_NATIVE_ADAPTER, SESSION_TOOL_ADAPTERS, SESSION_RENDER_MANAGED_DIRS, SESSION_RENDER_SHARED_MANAGED_DIRS, SESSION_RENDER_EXCLUSIVE_MANAGED_PATHS, SESSION_LAYER_RANK, CLAUDE_PATHS_RULES_VERSION_RANGE = ">=2.1.84", CANONICAL_IDENTITY_EXPORT_PACKAGES;
12414
12446
  var init_session_render = __esm(() => {
12415
12447
  init_global_agent_rules_standard();
12416
12448
  init_codewith_shared_todos_storage_standard();
@@ -12933,7 +12965,6 @@ function planProfileSessionRender(input) {
12933
12965
  });
12934
12966
  const {
12935
12967
  profile_id: _profileId,
12936
- provider_version: _providerVersion,
12937
12968
  configs: _configs,
12938
12969
  bindings: _bindings,
12939
12970
  asset_configs: _assetConfigs,
@@ -13103,7 +13134,12 @@ var init_instruction_graph = __esm(() => {
13103
13134
  init_asset_plan();
13104
13135
  COMMON_FALLBACKS = ["fail", "flatten", "promote-always", "omit"];
13105
13136
  DEFAULT_PROVIDER_CAPABILITIES = Object.freeze({
13106
- claude: capability("claude", ">=1.0.0", "native-import", "CLAUDE.md @ imports", { native_imports: true, asset_surface: "code" }),
13137
+ claude: capability("claude", ">=1.0.0", "native-import", "CLAUDE.md @ imports plus path-gated rules", {
13138
+ activation_modes: ["always", "glob"],
13139
+ native_imports: true,
13140
+ conditional_artifacts: true,
13141
+ asset_surface: "code"
13142
+ }),
13107
13143
  codex: capability("codex", ">=0.1.0", "flattened", "AGENTS.md", { asset_surface: "cli" }),
13108
13144
  cursor: capability("cursor", ">=1.0.0", "cursor-rule", ".cursor/rules/*.mdc", { activation_modes: ["always", "glob"], conditional_artifacts: true, asset_surface: "ide" }),
13109
13145
  opencode: capability("opencode", ">=1.0.0", "managed-fragment", "opencode.json instructions", { provider_variant: "v1-instructions", session_surface: "opencode-config-instructions" }),
@@ -14059,13 +14095,13 @@ var init_session_render_ownership = __esm(() => {
14059
14095
  // src/lib/apply.ts
14060
14096
  var exports_apply = {};
14061
14097
  __export(exports_apply, {
14062
- applyConfig: () => applyConfig,
14063
- applyConfigs: () => applyConfigs,
14064
- applyConfigsWithReport: () => applyConfigsWithReport,
14065
- expandPath: () => expandPath,
14066
- getConfigHome: () => getConfigHome,
14098
+ previewConfigs: () => previewConfigs,
14067
14099
  normalizeTargetPath: () => normalizeTargetPath,
14068
- previewConfigs: () => previewConfigs
14100
+ getConfigHome: () => getConfigHome,
14101
+ expandPath: () => expandPath,
14102
+ applyConfigsWithReport: () => applyConfigsWithReport,
14103
+ applyConfigs: () => applyConfigs,
14104
+ applyConfig: () => applyConfig
14069
14105
  });
14070
14106
  import { existsSync as existsSync7, mkdirSync as mkdirSync3, readFileSync as readFileSync6, realpathSync as realpathSync2, writeFileSync as writeFileSync2 } from "fs";
14071
14107
  import { basename as basename4, dirname as dirname4, join as join10, resolve as resolve7 } from "path";
@@ -14592,18 +14628,18 @@ var init_sync_dir = __esm(() => {
14592
14628
  // src/lib/sync.ts
14593
14629
  var exports_sync = {};
14594
14630
  __export(exports_sync, {
14595
- CLAUDE_PROMPT_OUTPUTS: () => CLAUDE_PROMPT_OUTPUTS,
14596
- KNOWN_CONFIGS: () => KNOWN_CONFIGS,
14597
- PROJECT_CONFIG_FILES: () => PROJECT_CONFIG_FILES,
14598
- detectAgent: () => detectAgent,
14599
- detectCategory: () => detectCategory,
14600
- detectFormat: () => detectFormat,
14601
- diffConfig: () => diffConfig,
14602
- syncFromDir: () => syncFromDir,
14603
- syncKnown: () => syncKnown,
14604
- syncProject: () => syncProject,
14631
+ syncToDisk: () => syncToDisk,
14605
14632
  syncToDir: () => syncToDir,
14606
- syncToDisk: () => syncToDisk
14633
+ syncProject: () => syncProject,
14634
+ syncKnown: () => syncKnown,
14635
+ syncFromDir: () => syncFromDir,
14636
+ diffConfig: () => diffConfig,
14637
+ detectFormat: () => detectFormat,
14638
+ detectCategory: () => detectCategory,
14639
+ detectAgent: () => detectAgent,
14640
+ PROJECT_CONFIG_FILES: () => PROJECT_CONFIG_FILES,
14641
+ KNOWN_CONFIGS: () => KNOWN_CONFIGS,
14642
+ CLAUDE_PROMPT_OUTPUTS: () => CLAUDE_PROMPT_OUTPUTS
14607
14643
  });
14608
14644
  import { existsSync as existsSync9, readdirSync as readdirSync2, readFileSync as readFileSync8 } from "fs";
14609
14645
  import { basename as basename5, extname as extname3, join as join12 } from "path";
@@ -17551,21 +17587,24 @@ function planFileResult(plan, file, targetHome, previousHashes, previousManifest
17551
17587
  function assertNotSilentManagedWipeout(plan, results) {
17552
17588
  if (plan.allowEmptySources)
17553
17589
  return;
17554
- const managedDir = plan.adapter.managedDir;
17555
- const underManagedDir = (relativePath) => relativePath === managedDir || relativePath.startsWith(`${managedDir}/`);
17556
- const staleDeletions = results.filter((result) => result.action === "delete" && underManagedDir(result.relativePath));
17590
+ const staleDeletions = results.filter((result) => result.action === "delete" && isPlanManagedFile(plan, result.relativePath, result.role));
17557
17591
  if (staleDeletions.length === 0)
17558
17592
  return;
17559
- const managedRetained = results.some((result) => result.action !== "delete" && underManagedDir(result.relativePath));
17593
+ const managedRetained = results.some((result) => result.action !== "delete" && isPlanManagedFile(plan, result.relativePath, result.role));
17560
17594
  if (managedRetained)
17561
17595
  return;
17562
- throw new SessionApplyError(`Session render plan for ${plan.tool} (${plan.adapter.mode}) would delete ${staleDeletions.length} ` + `previously managed file(s) under "${managedDir}" and create or update none there: ` + `${staleDeletions.map((result) => result.relativePath).join(", ")}. ` + "Pass --allow-empty-sources only for explicit empty renders.");
17596
+ throw new SessionApplyError(`Session render plan for ${plan.tool} (${plan.adapter.mode}) would delete ${staleDeletions.length} ` + "previously managed file(s) and create or update none: " + `${staleDeletions.map((result) => result.relativePath).join(", ")}. ` + "Pass --allow-empty-sources only for explicit empty renders.");
17597
+ }
17598
+ function isPlanManagedFile(plan, relativePath, role) {
17599
+ const managedDir = plan.adapter.managedDir;
17600
+ if (relativePath === managedDir || relativePath.startsWith(`${managedDir}/`))
17601
+ return true;
17602
+ return plan.tool === "claude" && role === "rule" && relativePath.startsWith("rules/");
17563
17603
  }
17564
17604
  function planStaleFileResults(plan, targetHome, previousManifest, currentRelativePaths, options) {
17565
17605
  if (!previousManifest)
17566
17606
  return [];
17567
- const managedPrefix = `${plan.adapter.managedDir}/`;
17568
- return previousManifest.files.filter((file) => !currentRelativePaths.has(file.relativePath)).filter((file) => file.relativePath === plan.adapter.managedDir || file.relativePath.startsWith(managedPrefix)).map((file) => planStaleFileResult(file, targetHome, options)).filter((result) => result !== null);
17607
+ return previousManifest.files.filter((file) => !currentRelativePaths.has(file.relativePath)).filter((file) => isPlanManagedFile(plan, file.relativePath, file.role)).map((file) => planStaleFileResult(file, targetHome, options)).filter((result) => result !== null);
17569
17608
  }
17570
17609
  function planStaleFileResult(file, targetHome, options) {
17571
17610
  const target = resolveManifestRelativePath(file.relativePath, targetHome);