@syv-ai/rulecast 0.1.1 → 0.2.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/chunk-C6C5EER7.js +1301 -0
- package/dist/chunk-RODZRI7B.js +1816 -0
- package/dist/chunk-ZEFEQKG5.js +937 -0
- package/dist/cli.js +41 -19
- package/dist/index.d.ts +5 -771
- package/dist/index.js +13 -39
- package/dist/internal.d.ts +136 -0
- package/dist/internal.js +38 -0
- package/dist/types-2oz2AlwA.d.ts +672 -0
- package/package.json +8 -2
- package/dist/chunk-3HRTZULM.js +0 -3780
package/dist/index.js
CHANGED
|
@@ -1,33 +1,20 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ADAPTERS,
|
|
3
|
-
CONFIG_FILE,
|
|
4
|
-
LlmUnavailableError,
|
|
5
|
-
MANIFEST_FILE,
|
|
6
|
-
MODEL_ALIASES,
|
|
7
|
-
VERSION,
|
|
8
3
|
adapterByName,
|
|
9
4
|
builtinDetectors,
|
|
10
|
-
cacheHome,
|
|
11
|
-
cachedRepos,
|
|
12
|
-
checkDetectors,
|
|
13
|
-
checkableKinds,
|
|
14
5
|
claudeCodeAdapter,
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
6
|
+
createRegistry
|
|
7
|
+
} from "./chunk-C6C5EER7.js";
|
|
8
|
+
import {
|
|
9
|
+
LlmUnavailableError,
|
|
10
|
+
VERSION,
|
|
18
11
|
defaultDetectorSettings,
|
|
19
12
|
emptyDelivery,
|
|
20
|
-
|
|
21
|
-
fixedRepo,
|
|
13
|
+
isDetectorRule,
|
|
22
14
|
memoryCache,
|
|
23
15
|
perRule,
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
readSourceFile,
|
|
27
|
-
renderAgentText,
|
|
28
|
-
resolveModel,
|
|
29
|
-
runPipeline
|
|
30
|
-
} from "./chunk-3HRTZULM.js";
|
|
16
|
+
readSourceFile
|
|
17
|
+
} from "./chunk-ZEFEQKG5.js";
|
|
31
18
|
|
|
32
19
|
// src/testing/adapter-contract.ts
|
|
33
20
|
import assert from "assert/strict";
|
|
@@ -176,7 +163,9 @@ function run(detector, rules, cwd, signal) {
|
|
|
176
163
|
cache: memoryCache(),
|
|
177
164
|
settings: defaultDetectorSettings(),
|
|
178
165
|
cwd,
|
|
179
|
-
signal
|
|
166
|
+
signal,
|
|
167
|
+
// The contract suite is not measuring the clock; a deadline far ahead keeps it out of the way.
|
|
168
|
+
deadlineAt: Date.now() + 6e4
|
|
180
169
|
});
|
|
181
170
|
}
|
|
182
171
|
function assertResultShape(result, ids) {
|
|
@@ -298,30 +287,15 @@ function detectorContract(detector, fixture) {
|
|
|
298
287
|
}
|
|
299
288
|
export {
|
|
300
289
|
ADAPTERS,
|
|
301
|
-
CONFIG_FILE,
|
|
302
290
|
LlmUnavailableError,
|
|
303
|
-
MANIFEST_FILE,
|
|
304
|
-
MODEL_ALIASES,
|
|
305
291
|
VERSION,
|
|
306
292
|
adapterByName,
|
|
307
293
|
adapterContract,
|
|
308
294
|
builtinDetectors,
|
|
309
|
-
cacheHome,
|
|
310
|
-
cachedRepos,
|
|
311
|
-
checkDetectors,
|
|
312
|
-
checkableKinds,
|
|
313
295
|
claudeCodeAdapter,
|
|
314
|
-
compile,
|
|
315
|
-
compileManifest,
|
|
316
296
|
createRegistry,
|
|
317
297
|
detectorContract,
|
|
318
298
|
emptyDelivery,
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
perRule,
|
|
322
|
-
projectStateDir,
|
|
323
|
-
providerByName,
|
|
324
|
-
renderAgentText,
|
|
325
|
-
resolveModel,
|
|
326
|
-
runPipeline
|
|
299
|
+
isDetectorRule,
|
|
300
|
+
perRule
|
|
327
301
|
};
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { n as DetectorRegistry, K as Config, j as CompiledRule, e as Delivery, h as CheckResult, q as DetectorSettings, E as Event, v as LlmProviderName, u as LlmProvider } from './types-2oz2AlwA.js';
|
|
2
|
+
export { N as RuleEntry, P as Stage } from './types-2oz2AlwA.js';
|
|
3
|
+
import 'zod';
|
|
4
|
+
|
|
5
|
+
type Checkout = {
|
|
6
|
+
ok: true;
|
|
7
|
+
dir: string;
|
|
8
|
+
label: string;
|
|
9
|
+
} | {
|
|
10
|
+
ok: false;
|
|
11
|
+
message: string;
|
|
12
|
+
missing: boolean;
|
|
13
|
+
};
|
|
14
|
+
/** Where compile finds a pinned rule repo's files. */
|
|
15
|
+
interface RepoProvider {
|
|
16
|
+
checkout(url: string, rev: string): Promise<Checkout>;
|
|
17
|
+
}
|
|
18
|
+
/** For hooks, which never fetch (spec §4): a repo missing from the cache is reported, not fetched. */
|
|
19
|
+
declare function cachedRepos(home: string): RepoProvider;
|
|
20
|
+
/** For the CLI: fetches repos missing from the cache. */
|
|
21
|
+
declare function fetchingRepos(home: string): RepoProvider;
|
|
22
|
+
/** For try-repo: every repo is `dir`. */
|
|
23
|
+
declare function fixedRepo(dir: string, label: string): RepoProvider;
|
|
24
|
+
|
|
25
|
+
interface Diagnostic {
|
|
26
|
+
/** ".rulecast-config.yaml", ".rulecast-rules.yaml", or "<repo url>@<rev>" for a rule repo. */
|
|
27
|
+
source: string;
|
|
28
|
+
rule: string | null;
|
|
29
|
+
message: string;
|
|
30
|
+
level: "error" | "warning";
|
|
31
|
+
/** What a hook tells the developer to run; default "rulecast validate". Missing repos: "rulecast install". */
|
|
32
|
+
hint?: string;
|
|
33
|
+
}
|
|
34
|
+
interface CompiledProject {
|
|
35
|
+
root: string;
|
|
36
|
+
config: Config;
|
|
37
|
+
rules: CompiledRule[];
|
|
38
|
+
diagnostics: Diagnostic[];
|
|
39
|
+
}
|
|
40
|
+
interface CompileOptions {
|
|
41
|
+
root: string;
|
|
42
|
+
registry: DetectorRegistry;
|
|
43
|
+
repos: RepoProvider;
|
|
44
|
+
/** Config data to compile instead of the project's .rulecast-config.yaml (try-repo). */
|
|
45
|
+
configData?: unknown;
|
|
46
|
+
}
|
|
47
|
+
/** The project config and the manifests of its pinned repos → ready rules plus diagnostics (spec §5). */
|
|
48
|
+
declare function compile(options: CompileOptions): Promise<CompiledProject>;
|
|
49
|
+
/** A manifest on its own (validate, the init catalog): references resolve against `dir`. */
|
|
50
|
+
declare function compileManifest(dir: string, registry: DetectorRegistry): Promise<{
|
|
51
|
+
rules: CompiledRule[];
|
|
52
|
+
diagnostics: Diagnostic[];
|
|
53
|
+
}>;
|
|
54
|
+
|
|
55
|
+
declare const CONFIG_FILE = ".rulecast-config.yaml";
|
|
56
|
+
declare const MANIFEST_FILE = ".rulecast-rules.yaml";
|
|
57
|
+
|
|
58
|
+
interface RenderOptions {
|
|
59
|
+
maxMatchesPerRule: number;
|
|
60
|
+
}
|
|
61
|
+
declare function renderAgentText(delivery: Delivery, options: RenderOptions): string;
|
|
62
|
+
|
|
63
|
+
interface CheckOptions {
|
|
64
|
+
project: CompiledProject;
|
|
65
|
+
registry: DetectorRegistry;
|
|
66
|
+
/** Project settings, as a detector run would get them. */
|
|
67
|
+
settings: DetectorSettings;
|
|
68
|
+
env: Readonly<Record<string, string | undefined>>;
|
|
69
|
+
timeoutMs: number;
|
|
70
|
+
}
|
|
71
|
+
/** A check's answer, and which detector gave it. */
|
|
72
|
+
type KindCheckResult = CheckResult & {
|
|
73
|
+
kind: string;
|
|
74
|
+
};
|
|
75
|
+
/** Detector kinds used by the project's rules whose detector has environment checks. */
|
|
76
|
+
declare function checkableKinds(project: CompiledProject, registry: DetectorRegistry): string[];
|
|
77
|
+
/**
|
|
78
|
+
* Every used detector's own checks (spec §5). Kinds run in parallel; results come back grouped by
|
|
79
|
+
* kind in checkableKinds order, so doctor's output is stable between runs.
|
|
80
|
+
*/
|
|
81
|
+
declare function checkDetectors(options: CheckOptions): Promise<KindCheckResult[]>;
|
|
82
|
+
|
|
83
|
+
type Env = Readonly<Record<string, string | undefined>>;
|
|
84
|
+
/** $RULECAST_HOME, else $XDG_CACHE_HOME/rulecast, else ~/.cache/rulecast. Empty values count as unset. */
|
|
85
|
+
declare function cacheHome(env: Env): string;
|
|
86
|
+
/**
|
|
87
|
+
* <home>/projects/<first 16 hex of sha256(realpath(root))>. Keyed by the real path, so separate checkouts and
|
|
88
|
+
* worktrees of one repository get separate directories and a symlinked path shares its target's.
|
|
89
|
+
*/
|
|
90
|
+
declare function projectStateDir(home: string, root: string): string;
|
|
91
|
+
|
|
92
|
+
interface PipelineOptions {
|
|
93
|
+
/** Compiled by the caller: hooks never fetch rule repos, the CLI does (spec §4). */
|
|
94
|
+
project: CompiledProject;
|
|
95
|
+
/** The project's directory in the cache (spec §12): sessions and detector caches. */
|
|
96
|
+
stateDir: string;
|
|
97
|
+
event: Event;
|
|
98
|
+
registry: DetectorRegistry;
|
|
99
|
+
/** From the adapter; null = unlimited. */
|
|
100
|
+
maxContextChars: number | null;
|
|
101
|
+
/** Recently accessed files the agent re-attaches after compaction (adapter.restoredFiles); reset re-delivers their touch context. */
|
|
102
|
+
restoredFiles?: number;
|
|
103
|
+
/** Detector kinds to skip entirely (run --no-llm). */
|
|
104
|
+
skipDetectorKinds?: ReadonlySet<string>;
|
|
105
|
+
/** Run only these rules (rulecast run RULE_ID); touch rules are unaffected. */
|
|
106
|
+
onlyRules?: ReadonlySet<string>;
|
|
107
|
+
/** verify from an agent's stop: decide block / allow / capReached. Needs a session. */
|
|
108
|
+
stopGate?: boolean;
|
|
109
|
+
/** Debug log sink. */
|
|
110
|
+
log?: (line: string) => void;
|
|
111
|
+
}
|
|
112
|
+
interface PipelineResult {
|
|
113
|
+
delivery: Delivery;
|
|
114
|
+
/** rulecast itself failed: compile diagnostics, detector errors or verify timeouts. */
|
|
115
|
+
failed: boolean;
|
|
116
|
+
/** Detector kinds whose results were dropped at the edit deadline (§13). */
|
|
117
|
+
deadlineMissed: string[];
|
|
118
|
+
}
|
|
119
|
+
declare function runPipeline(options: PipelineOptions): Promise<PipelineResult>;
|
|
120
|
+
|
|
121
|
+
declare const MODEL_ALIASES: readonly string[];
|
|
122
|
+
/**
|
|
123
|
+
* The provider's own name for a model. A name that is not an alias is passed through unchanged, so
|
|
124
|
+
* a new model or a local Ollama tag needs no rulecast release. null: a known alias this provider
|
|
125
|
+
* cannot express, which the detector turns into a per-rule error naming both.
|
|
126
|
+
*/
|
|
127
|
+
declare function resolveModel(model: string, provider: LlmProviderName): string | null;
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* The provider for a configured name. Throws LlmUnavailableError, which spec §14 turns into one
|
|
131
|
+
* warning disabling every llm rule — the guard survives because a config can name a provider a
|
|
132
|
+
* future build has dropped.
|
|
133
|
+
*/
|
|
134
|
+
declare function providerByName(name: LlmProviderName): LlmProvider;
|
|
135
|
+
|
|
136
|
+
export { CONFIG_FILE, type Checkout, type CompileOptions, type CompiledProject, Config, type Diagnostic, type Env, type KindCheckResult, MANIFEST_FILE, MODEL_ALIASES, type PipelineOptions, type PipelineResult, type RepoProvider, cacheHome, cachedRepos, checkDetectors, checkableKinds, compile, compileManifest, fetchingRepos, fixedRepo, projectStateDir, providerByName, renderAgentText, resolveModel, runPipeline };
|
package/dist/internal.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CONFIG_FILE,
|
|
3
|
+
MANIFEST_FILE,
|
|
4
|
+
cacheHome,
|
|
5
|
+
cachedRepos,
|
|
6
|
+
checkDetectors,
|
|
7
|
+
checkableKinds,
|
|
8
|
+
compile,
|
|
9
|
+
compileManifest,
|
|
10
|
+
fetchingRepos,
|
|
11
|
+
fixedRepo,
|
|
12
|
+
projectStateDir,
|
|
13
|
+
runPipeline
|
|
14
|
+
} from "./chunk-RODZRI7B.js";
|
|
15
|
+
import {
|
|
16
|
+
MODEL_ALIASES,
|
|
17
|
+
providerByName,
|
|
18
|
+
renderAgentText,
|
|
19
|
+
resolveModel
|
|
20
|
+
} from "./chunk-ZEFEQKG5.js";
|
|
21
|
+
export {
|
|
22
|
+
CONFIG_FILE,
|
|
23
|
+
MANIFEST_FILE,
|
|
24
|
+
MODEL_ALIASES,
|
|
25
|
+
cacheHome,
|
|
26
|
+
cachedRepos,
|
|
27
|
+
checkDetectors,
|
|
28
|
+
checkableKinds,
|
|
29
|
+
compile,
|
|
30
|
+
compileManifest,
|
|
31
|
+
fetchingRepos,
|
|
32
|
+
fixedRepo,
|
|
33
|
+
projectStateDir,
|
|
34
|
+
providerByName,
|
|
35
|
+
renderAgentText,
|
|
36
|
+
resolveModel,
|
|
37
|
+
runPipeline
|
|
38
|
+
};
|