@savvy-web/silk-effects 9.4.1 → 9.5.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.
@@ -1,5 +1,7 @@
1
1
  import { readCache, writeCache } from "./cache.js";
2
2
  import { Effect } from "effect";
3
+ import { resolve } from "node:path";
4
+ import { Git } from "@effected/git";
3
5
  import { ChildProcess, ChildProcessSpawner } from "effect/process";
4
6
 
5
7
  //#region src/commitlint/hook/diagnostics/open-issues.ts
@@ -16,8 +18,26 @@ import { ChildProcess, ChildProcessSpawner } from "effect/process";
16
18
  * @internal
17
19
  */
18
20
  const ISSUES_CACHE_TTL_SECONDS = 600;
19
- /** Relative path under CLAUDE_PROJECT_DIR where the open-issues cache lives. */
21
+ /** Relative path under the project root where the open-issues cache lives. */
20
22
  const ISSUES_CACHE_RELATIVE_PATH = ".claude/cache/issues.json";
23
+ /**
24
+ * Resolve the absolute open-issues cache path.
25
+ *
26
+ * @remarks
27
+ * The root is `CLAUDE_PROJECT_DIR` when set, otherwise the git repository
28
+ * root of `cwd`, and only outside any repository `cwd` itself. Falling back
29
+ * straight to `cwd` left a stray cache under whichever package directory a
30
+ * hook happened to run from (savvy-web/systems#762).
31
+ */
32
+ function resolveIssuesCachePath(options = {}) {
33
+ const cwd = options.cwd ?? process.cwd();
34
+ const projectDir = "projectDir" in options ? options.projectDir : process.env.CLAUDE_PROJECT_DIR;
35
+ return Effect.gen(function* () {
36
+ if (projectDir) return resolve(projectDir, ISSUES_CACHE_RELATIVE_PATH);
37
+ const root = yield* (yield* Git).repoRoot(cwd).pipe(Effect.orElseSucceed(() => cwd));
38
+ return resolve(root, ISSUES_CACHE_RELATIVE_PATH);
39
+ });
40
+ }
21
41
  function readOpenIssuesFromCache(cachePath, ttlSeconds = 600) {
22
42
  return readCache(cachePath, ttlSeconds);
23
43
  }
@@ -59,4 +79,4 @@ function readOrFetchOpenIssues(cachePath) {
59
79
  }
60
80
 
61
81
  //#endregion
62
- export { ISSUES_CACHE_RELATIVE_PATH, fetchAndCacheOpenIssues, readOpenIssuesFromCache, readOrFetchOpenIssues };
82
+ export { ISSUES_CACHE_RELATIVE_PATH, fetchAndCacheOpenIssues, readOpenIssuesFromCache, readOrFetchOpenIssues, resolveIssuesCachePath };
@@ -17,7 +17,7 @@ import { HookSilencer } from "./hook/silence-logger.js";
17
17
  import { inferTicketId, readBranchInfo } from "./hook/diagnostics/branch.js";
18
18
  import { readCache, writeCache } from "./hook/diagnostics/cache.js";
19
19
  import { parseHuskyConfigPath, readCommitlintConfigPath } from "./hook/diagnostics/commitlint-config.js";
20
- import { ISSUES_CACHE_RELATIVE_PATH, fetchAndCacheOpenIssues, readOpenIssuesFromCache, readOrFetchOpenIssues } from "./hook/diagnostics/open-issues.js";
20
+ import { ISSUES_CACHE_RELATIVE_PATH, fetchAndCacheOpenIssues, readOpenIssuesFromCache, readOrFetchOpenIssues, resolveIssuesCachePath } from "./hook/diagnostics/open-issues.js";
21
21
  import { detectFromLockfiles, detectPackageManager, parsePackageManagerField } from "./hook/diagnostics/package-manager.js";
22
22
  import { buildSigningDiagnostic, parseGpgKeyExpiry, readSigningDiagnostic } from "./hook/diagnostics/signing.js";
23
23
  import { closesTrailerRule, hasClosingTrailer } from "./hook/rules/closes-trailer.js";
@@ -99,6 +99,7 @@ var commitlint_exports = /* @__PURE__ */ __exportAll({
99
99
  readOpenIssuesFromCache: () => readOpenIssuesFromCache,
100
100
  readOrFetchOpenIssues: () => readOrFetchOpenIssues,
101
101
  readSigningDiagnostic: () => readSigningDiagnostic,
102
+ resolveIssuesCachePath: () => resolveIssuesCachePath,
102
103
  sessionStartContext: () => sessionStartContext,
103
104
  signingFlagConflictRule: () => signingFlagConflictRule,
104
105
  softWrapRule: () => softWrapRule,
@@ -141,4 +142,4 @@ var CommitlintConfig = class {
141
142
  };
142
143
 
143
144
  //#endregion
144
- export { COMMIT_TYPES, COMMIT_TYPE_DEFINITIONS, CommitlintConfig, CommitlintConfig as default, DCO_SIGNOFF_TEXT, ERROR_EXPLANATIONS, ERROR_SUGGESTIONS, HookSilencer, ISSUES_CACHE_RELATIVE_PATH, PostToolUseEnvelope, PreToolUseEnvelope, SessionStartEnvelope, TDD_SCOPE_PATTERN, TDD_STATES, TYPE_EMOJIS, TYPE_EMOJIS_UNICODE, buildSigningDiagnostic, closesTrailerRule, commitlint_exports, createPromptConfig, createTypeEnum, defaultPromptConfig, detectDCO, detectFromLockfiles, detectPackageManager, detectScopes, emojiPromptConfig, fetchAndCacheOpenIssues, forbiddenContentRule, format, getExplanation, getSuggestion, getTypeEmoji, hasClosingTrailer, inferTicketId, parseBashCommand, parseGpgKeyExpiry, parseHuskyConfigPath, parsePackageManagerField, partitionHits, planLeakageRule, postToolUseAdvise, preToolUseAdvise, preToolUseAllow, preToolUseDeny, preToolUseSilent, prompter, readBranchInfo, readCache, readCommitlintConfigPath, readOpenIssuesFromCache, readOrFetchOpenIssues, readSigningDiagnostic, sessionStartContext, signingFlagConflictRule, softWrapRule, staticConfig, verbosityRule, writeCache };
145
+ export { COMMIT_TYPES, COMMIT_TYPE_DEFINITIONS, CommitlintConfig, CommitlintConfig as default, DCO_SIGNOFF_TEXT, ERROR_EXPLANATIONS, ERROR_SUGGESTIONS, HookSilencer, ISSUES_CACHE_RELATIVE_PATH, PostToolUseEnvelope, PreToolUseEnvelope, SessionStartEnvelope, TDD_SCOPE_PATTERN, TDD_STATES, TYPE_EMOJIS, TYPE_EMOJIS_UNICODE, buildSigningDiagnostic, closesTrailerRule, commitlint_exports, createPromptConfig, createTypeEnum, defaultPromptConfig, detectDCO, detectFromLockfiles, detectPackageManager, detectScopes, emojiPromptConfig, fetchAndCacheOpenIssues, forbiddenContentRule, format, getExplanation, getSuggestion, getTypeEmoji, hasClosingTrailer, inferTicketId, parseBashCommand, parseGpgKeyExpiry, parseHuskyConfigPath, parsePackageManagerField, partitionHits, planLeakageRule, postToolUseAdvise, preToolUseAdvise, preToolUseAllow, preToolUseDeny, preToolUseSilent, prompter, readBranchInfo, readCache, readCommitlintConfigPath, readOpenIssuesFromCache, readOrFetchOpenIssues, readSigningDiagnostic, resolveIssuesCachePath, sessionStartContext, signingFlagConflictRule, softWrapRule, staticConfig, verbosityRule, writeCache };
package/index.d.ts CHANGED
@@ -6766,8 +6766,21 @@ interface OpenIssue {
6766
6766
  title: string;
6767
6767
  }
6768
6768
  declare const ISSUES_CACHE_TTL_SECONDS = 600;
6769
- /** Relative path under CLAUDE_PROJECT_DIR where the open-issues cache lives. */
6769
+ /** Relative path under the project root where the open-issues cache lives. */
6770
6770
  declare const ISSUES_CACHE_RELATIVE_PATH = ".claude/cache/issues.json";
6771
+ /**
6772
+ * Resolve the absolute open-issues cache path.
6773
+ *
6774
+ * @remarks
6775
+ * The root is `CLAUDE_PROJECT_DIR` when set, otherwise the git repository
6776
+ * root of `cwd`, and only outside any repository `cwd` itself. Falling back
6777
+ * straight to `cwd` left a stray cache under whichever package directory a
6778
+ * hook happened to run from (savvy-web/systems#762).
6779
+ */
6780
+ declare function resolveIssuesCachePath(options?: {
6781
+ readonly cwd?: string;
6782
+ readonly projectDir?: string | undefined;
6783
+ }): Effect.Effect<string, never, Git>;
6771
6784
  declare function readOpenIssuesFromCache(cachePath: string, ttlSeconds?: number): Effect.Effect<OpenIssue[] | null>;
6772
6785
  declare function fetchAndCacheOpenIssues(cachePath: string): Effect.Effect<OpenIssue[] | null, never, ChildProcessSpawner.ChildProcessSpawner>;
6773
6786
  declare function readOrFetchOpenIssues(cachePath: string): Effect.Effect<OpenIssue[] | null, never, ChildProcessSpawner.ChildProcessSpawner>;
@@ -6901,7 +6914,7 @@ declare const VERBOSITY_LINE_THRESHOLD = 12;
6901
6914
  declare const VERBOSITY_WORD_THRESHOLD = 150;
6902
6915
  declare const verbosityRule: Rule<VerbosityInput, never>;
6903
6916
  declare namespace index_d_exports$1 {
6904
- export { BranchInfo, COMMIT_TYPES, COMMIT_TYPE_DEFINITIONS, ClosesTrailerCtx, ClosesTrailerInput, CommitType, CommitTypeDefinition, CommitlintConfig, CommitlintPlugin, CommitlintUserConfig, ConfigOptions, DCO_SIGNOFF_TEXT, DEFAULT_BODY_MAX_LINE_LENGTH, ERROR_EXPLANATIONS, ERROR_SUGGESTIONS, ForbiddenContentInput, FormatterResult, HookOutput, RuleSeverity$1 as HookRuleSeverity, HookSilencer, ISSUES_CACHE_RELATIVE_PATH, ISSUES_CACHE_TTL_SECONDS, Inquirer, LintOutcome, LockfilePresence, OpenIssue, PackageManager$1 as PackageManager, ParsedCommit, ParsedKind, PlanLeakageInput, PostToolUseEnvelope, PostToolUseEnvelope as PostToolUseEnvelopeType, PreToolUseEnvelope, PreToolUseEnvelope as PreToolUseEnvelopeType, PromptConfig, PromptConfigOptions, PromptQuestion, PromptSettings, PrompterOptions, Question, RawSigningInputs, ReleaseFormat, ResolvedPromptConfig, Rule, RuleApplicability, RuleConfigTuple, RuleHit, RuleResult, RuleSeverity, RulesConfig, SessionStartEnvelope, SessionStartEnvelope as SessionStartEnvelopeType, SigningDiagnostic, SigningFlagCtx, SigningFlagInput, SoftWrapInput, TDD_SCOPE_PATTERN, TDD_STATES, TYPE_EMOJIS, TYPE_EMOJIS_UNICODE, TypeEnumEntry, VERBOSITY_LINE_THRESHOLD, VERBOSITY_WORD_THRESHOLD, VerbosityInput, buildSigningDiagnostic, closesTrailerRule, createPromptConfig, createTypeEnum, CommitlintConfig as default, defaultPromptConfig, detectDCO, detectFromLockfiles, detectPackageManager, detectScopes, emojiPromptConfig, fetchAndCacheOpenIssues, forbiddenContentRule, format, getExplanation, getSuggestion, getTypeEmoji, hasClosingTrailer, inferTicketId, parseBashCommand, parseGpgKeyExpiry, parseHuskyConfigPath, parsePackageManagerField, partitionHits, planLeakageRule, postToolUseAdvise, preToolUseAdvise, preToolUseAllow, preToolUseDeny, preToolUseSilent, prompter, readBranchInfo, readCache, readCommitlintConfigPath, readOpenIssuesFromCache, readOrFetchOpenIssues, readSigningDiagnostic, sessionStartContext, signingFlagConflictRule, softWrapRule, staticConfig, verbosityRule, writeCache };
6917
+ export { BranchInfo, COMMIT_TYPES, COMMIT_TYPE_DEFINITIONS, ClosesTrailerCtx, ClosesTrailerInput, CommitType, CommitTypeDefinition, CommitlintConfig, CommitlintPlugin, CommitlintUserConfig, ConfigOptions, DCO_SIGNOFF_TEXT, DEFAULT_BODY_MAX_LINE_LENGTH, ERROR_EXPLANATIONS, ERROR_SUGGESTIONS, ForbiddenContentInput, FormatterResult, HookOutput, RuleSeverity$1 as HookRuleSeverity, HookSilencer, ISSUES_CACHE_RELATIVE_PATH, ISSUES_CACHE_TTL_SECONDS, Inquirer, LintOutcome, LockfilePresence, OpenIssue, PackageManager$1 as PackageManager, ParsedCommit, ParsedKind, PlanLeakageInput, PostToolUseEnvelope, PostToolUseEnvelope as PostToolUseEnvelopeType, PreToolUseEnvelope, PreToolUseEnvelope as PreToolUseEnvelopeType, PromptConfig, PromptConfigOptions, PromptQuestion, PromptSettings, PrompterOptions, Question, RawSigningInputs, ReleaseFormat, ResolvedPromptConfig, Rule, RuleApplicability, RuleConfigTuple, RuleHit, RuleResult, RuleSeverity, RulesConfig, SessionStartEnvelope, SessionStartEnvelope as SessionStartEnvelopeType, SigningDiagnostic, SigningFlagCtx, SigningFlagInput, SoftWrapInput, TDD_SCOPE_PATTERN, TDD_STATES, TYPE_EMOJIS, TYPE_EMOJIS_UNICODE, TypeEnumEntry, VERBOSITY_LINE_THRESHOLD, VERBOSITY_WORD_THRESHOLD, VerbosityInput, buildSigningDiagnostic, closesTrailerRule, createPromptConfig, createTypeEnum, CommitlintConfig as default, defaultPromptConfig, detectDCO, detectFromLockfiles, detectPackageManager, detectScopes, emojiPromptConfig, fetchAndCacheOpenIssues, forbiddenContentRule, format, getExplanation, getSuggestion, getTypeEmoji, hasClosingTrailer, inferTicketId, parseBashCommand, parseGpgKeyExpiry, parseHuskyConfigPath, parsePackageManagerField, partitionHits, planLeakageRule, postToolUseAdvise, preToolUseAdvise, preToolUseAllow, preToolUseDeny, preToolUseSilent, prompter, readBranchInfo, readCache, readCommitlintConfigPath, readOpenIssuesFromCache, readOrFetchOpenIssues, readSigningDiagnostic, resolveIssuesCachePath, sessionStartContext, signingFlagConflictRule, softWrapRule, staticConfig, verbosityRule, writeCache };
6905
6918
  }
6906
6919
  /**
6907
6920
  * Dynamic commitlint configuration factory.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@savvy-web/silk-effects",
3
- "version": "9.4.1",
3
+ "version": "9.5.0",
4
4
  "private": false,
5
5
  "description": "Shared Effect library for Silk Suite conventions",
6
6
  "homepage": "https://github.com/savvy-web/systems/tree/main/packages/silk-effects",
@@ -41,7 +41,7 @@
41
41
  "@effected/glob": "^0.10.0",
42
42
  "@effected/jsonc": "^0.15.1",
43
43
  "@effected/markdown": "^0.15.1",
44
- "@effected/package-json": "^0.20.0",
44
+ "@effected/package-json": "^0.20.1",
45
45
  "@effected/toml": "^0.11.1",
46
46
  "@effected/walker": "^0.15.0",
47
47
  "@effected/yaml": "^0.19.1",