@hasna/instructions 0.4.39 → 0.4.43

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.
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=apply-unchanged-snapshot-bloat.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apply-unchanged-snapshot-bloat.test.d.ts","sourceRoot":"","sources":["../../src/cli/apply-unchanged-snapshot-bloat.test.ts"],"names":[],"mappings":""}
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";
@@ -14246,7 +14282,7 @@ async function applyPreparedConfig(config, opts) {
14246
14282
  changed: outputResults.some((output) => output.changed)
14247
14283
  };
14248
14284
  }
14249
- if (!opts.dryRun) {
14285
+ if (!opts.dryRun && result.changed) {
14250
14286
  await store.updateConfig(config.id, { synced_at: new Date().toISOString() });
14251
14287
  }
14252
14288
  return result;
@@ -14527,14 +14563,15 @@ async function syncFromDir(dir, opts = {}) {
14527
14563
  continue;
14528
14564
  }
14529
14565
  const targetPath = file.replace(home, "~");
14566
+ const redacted = redactContent(content, redactFormatForTarget(targetPath, detectFormat(file)));
14530
14567
  const existing = allConfigs.find((c) => c.target_path === targetPath);
14531
14568
  if (!existing) {
14532
14569
  if (!opts.dryRun)
14533
- await store.createConfig({ name: relative4(absDir, file), category: detectCategory(file), agent: detectAgent(file), target_path: targetPath, format: detectFormat(file), content });
14570
+ await store.createConfig({ name: relative4(absDir, file), category: detectCategory(file), agent: detectAgent(file), target_path: targetPath, format: detectFormat(file), content: redacted.content });
14534
14571
  result.added++;
14535
- } else if (existing.content !== content) {
14572
+ } else if (existing.content !== redacted.content) {
14536
14573
  if (!opts.dryRun)
14537
- await store.updateConfig(existing.id, { content });
14574
+ await store.updateConfig(existing.id, { content: redacted.content });
14538
14575
  result.updated++;
14539
14576
  } else {
14540
14577
  result.unchanged++;
@@ -14586,24 +14623,25 @@ var init_sync_dir = __esm(() => {
14586
14623
  init_config_store();
14587
14624
  init_apply();
14588
14625
  init_sync();
14626
+ init_redact();
14589
14627
  SKIP = [".db", ".db-shm", ".db-wal", ".log", ".lock", ".DS_Store", "node_modules", ".git"];
14590
14628
  });
14591
14629
 
14592
14630
  // src/lib/sync.ts
14593
14631
  var exports_sync = {};
14594
14632
  __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,
14633
+ syncToDisk: () => syncToDisk,
14605
14634
  syncToDir: () => syncToDir,
14606
- syncToDisk: () => syncToDisk
14635
+ syncProject: () => syncProject,
14636
+ syncKnown: () => syncKnown,
14637
+ syncFromDir: () => syncFromDir,
14638
+ diffConfig: () => diffConfig,
14639
+ detectFormat: () => detectFormat,
14640
+ detectCategory: () => detectCategory,
14641
+ detectAgent: () => detectAgent,
14642
+ PROJECT_CONFIG_FILES: () => PROJECT_CONFIG_FILES,
14643
+ KNOWN_CONFIGS: () => KNOWN_CONFIGS,
14644
+ CLAUDE_PROMPT_OUTPUTS: () => CLAUDE_PROMPT_OUTPUTS
14607
14645
  });
14608
14646
  import { existsSync as existsSync9, readdirSync as readdirSync2, readFileSync as readFileSync8 } from "fs";
14609
14647
  import { basename as basename5, extname as extname3, join as join12 } from "path";
@@ -14807,7 +14845,7 @@ async function syncKnown(opts = {}) {
14807
14845
  continue;
14808
14846
  }
14809
14847
  const fmt = known.format ?? detectFormat(abs);
14810
- const redacted = redactContent(rawContent, fmt);
14848
+ const redacted = redactContent(rawContent, redactFormatForTarget(abs, fmt));
14811
14849
  const machineAware = templateizeMachineContent(redacted.content, machine);
14812
14850
  const content = machineAware.content;
14813
14851
  const isTemplate2 = redacted.isTemplate || machineAware.changed;
@@ -17551,21 +17589,24 @@ function planFileResult(plan, file, targetHome, previousHashes, previousManifest
17551
17589
  function assertNotSilentManagedWipeout(plan, results) {
17552
17590
  if (plan.allowEmptySources)
17553
17591
  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));
17592
+ const staleDeletions = results.filter((result) => result.action === "delete" && isPlanManagedFile(plan, result.relativePath, result.role));
17557
17593
  if (staleDeletions.length === 0)
17558
17594
  return;
17559
- const managedRetained = results.some((result) => result.action !== "delete" && underManagedDir(result.relativePath));
17595
+ const managedRetained = results.some((result) => result.action !== "delete" && isPlanManagedFile(plan, result.relativePath, result.role));
17560
17596
  if (managedRetained)
17561
17597
  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.");
17598
+ 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.");
17599
+ }
17600
+ function isPlanManagedFile(plan, relativePath, role) {
17601
+ const managedDir = plan.adapter.managedDir;
17602
+ if (relativePath === managedDir || relativePath.startsWith(`${managedDir}/`))
17603
+ return true;
17604
+ return plan.tool === "claude" && role === "rule" && relativePath.startsWith("rules/");
17563
17605
  }
17564
17606
  function planStaleFileResults(plan, targetHome, previousManifest, currentRelativePaths, options) {
17565
17607
  if (!previousManifest)
17566
17608
  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);
17609
+ 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
17610
  }
17570
17611
  function planStaleFileResult(file, targetHome, options) {
17571
17612
  const target = resolveManifestRelativePath(file.relativePath, targetHome);
@@ -18625,7 +18666,7 @@ async function getConfigsStatus(store = resolveConfigStore(), options = {}) {
18625
18666
  let unredactedSecretFindings = 0;
18626
18667
  let knownTargets = 0;
18627
18668
  for (const config of fileConfigs) {
18628
- unredactedSecretFindings += scanSecrets(config.content, config.format).length;
18669
+ unredactedSecretFindings += scanSecrets(config.content, redactFormatForTarget(config.target_path ?? "", config.format)).length;
18629
18670
  if (isRetiredOrUnsupportedConfigAgent(config.agent))
18630
18671
  continue;
18631
18672
  if (!config.target_path)
@@ -18637,7 +18678,7 @@ async function getConfigsStatus(store = resolveConfigStore(), options = {}) {
18637
18678
  continue;
18638
18679
  }
18639
18680
  const disk = readFileSync13(targetPath, "utf-8");
18640
- const { content: redactedDisk } = redactContent(disk, config.format);
18681
+ const { content: redactedDisk } = redactContent(disk, redactFormatForTarget(config.target_path, config.format));
18641
18682
  if (redactedDisk !== config.content) {
18642
18683
  driftedTargets += 1;
18643
18684
  }
@@ -19215,7 +19256,8 @@ program.command("add <path>").description("Ingest a file into the config DB").op
19215
19256
  process.exit(1);
19216
19257
  }
19217
19258
  const rawContent = readFileSync15(abs, "utf-8");
19218
- const fmt = detectFormat(abs);
19259
+ const storedFmt = detectFormat(abs);
19260
+ const fmt = redactFormatForTarget(abs, storedFmt);
19219
19261
  const { content, redacted, isTemplate: isTemplate2 } = redactContent(rawContent, fmt);
19220
19262
  const targetPath = abs.startsWith(homedir10()) ? abs.replace(homedir10(), "~") : abs;
19221
19263
  const name = opts.name || filePath.split("/").pop();
@@ -19249,7 +19291,7 @@ program.command("add <path>").description("Ingest a file into the config DB").op
19249
19291
  }
19250
19292
  config = await store.updateConfig(target.id, {
19251
19293
  content,
19252
- format: fmt,
19294
+ format: storedFmt,
19253
19295
  is_template: (opts.template ?? false) || isTemplate2,
19254
19296
  ...opts.category ? { category: opts.category } : {},
19255
19297
  ...opts.agent ? { agent: opts.agent } : {}
@@ -19270,7 +19312,7 @@ program.command("add <path>").description("Ingest a file into the config DB").op
19270
19312
  category: opts.category ?? detectCategory(abs),
19271
19313
  agent: opts.agent ?? detectAgent(abs),
19272
19314
  target_path: opts.kind === "reference" ? null : targetPath,
19273
- format: fmt,
19315
+ format: storedFmt,
19274
19316
  content,
19275
19317
  is_template: (opts.template ?? false) || isTemplate2
19276
19318
  });
@@ -20021,6 +20063,22 @@ snapshotCmd.command("restore <config> <snapshot-id>").description("Restore a con
20021
20063
  process.exit(1);
20022
20064
  }
20023
20065
  });
20066
+ snapshotCmd.command("prune <config>").description("Delete old snapshots, keeping the N most recent").option("--keep <n>", "number of most-recent snapshots to keep (default 10)").action(async (configId, opts) => {
20067
+ try {
20068
+ const store = resolveConfigStore();
20069
+ const c = await store.getConfig(configId);
20070
+ const keep = opts.keep === undefined ? 10 : Number(opts.keep);
20071
+ if (!Number.isInteger(keep) || keep < 1) {
20072
+ console.error(chalk.red(`--keep must be a positive integer (got: ${opts.keep})`));
20073
+ process.exit(1);
20074
+ }
20075
+ const removed = await store.pruneSnapshots(c.id, keep);
20076
+ console.log(chalk.green("\u2713") + ` Pruned ${removed} snapshot(s), keeping the ${keep} most recent for ${c.slug}`);
20077
+ } catch (e) {
20078
+ console.error(chalk.red(formatCliError(e)));
20079
+ process.exit(1);
20080
+ }
20081
+ });
20024
20082
  var templateCmd = program.command("template").description("Work with template configs");
20025
20083
  templateCmd.command("vars <id>").description("Show template variables").action(async (id) => {
20026
20084
  try {
@@ -20127,7 +20185,7 @@ program.command("scan [id]").description("Scan configs for secrets. Defaults to
20127
20185
  for (let i = 0;i < configs.length; i += BATCH) {
20128
20186
  const batch = configs.slice(i, i + BATCH);
20129
20187
  for (const c of batch) {
20130
- const fmt = c.format;
20188
+ const fmt = redactFormatForTarget(c.target_path ?? "", c.format);
20131
20189
  const secrets = scanSecrets(c.content, fmt);
20132
20190
  if (secrets.length === 0)
20133
20191
  continue;
@@ -20429,7 +20487,7 @@ Stored configs (${allConfigs.length}):`));
20429
20487
  pass(`${validCount}/${allConfigs.length} valid syntax`);
20430
20488
  let secretCount = 0;
20431
20489
  for (const c of allConfigs) {
20432
- const found = scanSecrets(c.content, c.format);
20490
+ const found = scanSecrets(c.content, redactFormatForTarget(c.target_path ?? "", c.format));
20433
20491
  secretCount += found.length;
20434
20492
  }
20435
20493
  secretCount === 0 ? pass("No unredacted secrets") : fail2(`${secretCount} unredacted secret(s) \u2014 run \`configs scan --fix\``);
@@ -20633,7 +20691,7 @@ program.command("report").description("Summary of stored configs, drift, and eco
20633
20691
  continue;
20634
20692
  }
20635
20693
  const disk = readFileSync15(abs, "utf-8");
20636
- const { content: redactedDisk } = redactContent(disk, c.format);
20694
+ const { content: redactedDisk } = redactContent(disk, redactFormatForTarget(c.target_path, c.format));
20637
20695
  if (redactedDisk !== c.content)
20638
20696
  drifted++;
20639
20697
  }
@@ -7,7 +7,6 @@ export interface ServerDataBackendEnvKeys {
7
7
  databaseUrlKeys: string[];
8
8
  }
9
9
  export declare function serverDataBackendEnvKeys(name: string): ServerDataBackendEnvKeys;
10
- export declare function assertNoLegacyStorageMode(name: string, env?: Env): void;
11
10
  export interface ServerDataBackendResolution {
12
11
  backend: ServerDataBackend;
13
12
  source: string;
@@ -1 +1 @@
1
- {"version":3,"file":"backend.d.ts","sourceRoot":"","sources":["../../../src/generated/storage-kit/backend.ts"],"names":[],"mappings":"AAaA,eAAO,MAAM,oBAAoB,mCAAoC,CAAC;AACtE,MAAM,MAAM,iBAAiB,GAAG,CAAC,OAAO,oBAAoB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEtE,MAAM,MAAM,GAAG,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;AAErD,sEAAsE;AACtE,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE7C;AAED,MAAM,WAAW,wBAAwB;IACvC,eAAe,EAAE,MAAM,EAAE,CAAC;CAC3B;AAED,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,MAAM,GAAG,wBAAwB,CAK/E;AA+BD,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,GAAE,GAAiB,GAAG,IAAI,CASpF;AAED,MAAM,WAAW,2BAA2B;IAC1C,OAAO,EAAE,iBAAiB,CAAC;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,kBAAkB,EAAE,OAAO,CAAC;IAC5B,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAC;CAClC;AAED,wBAAgB,wBAAwB,CACtC,IAAI,EAAE,MAAM,EACZ,GAAG,GAAE,GAAiB,GACrB,2BAA2B,CAiB7B;AAED,8EAA8E;AAC9E,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,GAAE,GAAiB,GAAG,MAAM,GAAG,IAAI,CAItF"}
1
+ {"version":3,"file":"backend.d.ts","sourceRoot":"","sources":["../../../src/generated/storage-kit/backend.ts"],"names":[],"mappings":"AAaA,eAAO,MAAM,oBAAoB,mCAAoC,CAAC;AACtE,MAAM,MAAM,iBAAiB,GAAG,CAAC,OAAO,oBAAoB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEtE,MAAM,MAAM,GAAG,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;AAErD,sEAAsE;AACtE,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE7C;AAED,MAAM,WAAW,wBAAwB;IACvC,eAAe,EAAE,MAAM,EAAE,CAAC;CAC3B;AAED,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,MAAM,GAAG,wBAAwB,CAK/E;AAcD,MAAM,WAAW,2BAA2B;IAC1C,OAAO,EAAE,iBAAiB,CAAC;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,kBAAkB,EAAE,OAAO,CAAC;IAC5B,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAC;CAClC;AAED,wBAAgB,wBAAwB,CACtC,IAAI,EAAE,MAAM,EACZ,GAAG,GAAE,GAAiB,GACrB,2BAA2B,CAgB7B;AAED,8EAA8E;AAC9E,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,GAAE,GAAiB,GAAG,MAAM,GAAG,IAAI,CAGtF"}