@jawache/flow 0.1.0 → 0.1.1
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/flow.mjs +58 -57
- package/dist/index.mjs +14 -14
- package/dist/packs.mjs +39 -39
- package/dist/types/adapter/claude.d.ts +14 -2
- package/dist/types/adapter/domain.d.ts +17 -0
- package/dist/types/checks/domain.d.ts +29 -9
- package/dist/types/engine/domain.d.ts +3 -0
- package/dist/types/language/domain.d.ts +46 -4
- package/package.json +2 -1
|
@@ -12,7 +12,7 @@ export type BreadcrumbMoment = (typeof BREADCRUMB_MOMENTS)[number];
|
|
|
12
12
|
/** Either vocabulary. `turn-end` is the one word in both. */
|
|
13
13
|
export type Moment = GuardrailMoment | BreadcrumbMoment;
|
|
14
14
|
export declare const GUARDRAIL_MOMENTS: readonly GuardrailMoment[];
|
|
15
|
-
export declare const BREADCRUMB_MOMENTS: readonly ["session", "touch", "turn-end"];
|
|
15
|
+
export declare const BREADCRUMB_MOMENTS: readonly ["session", "touch", "command", "turn-end"];
|
|
16
16
|
export declare const write: "write";
|
|
17
17
|
export declare const command: "command";
|
|
18
18
|
export declare const commit: "commit";
|
|
@@ -40,6 +40,20 @@ export declare const PATH_MOMENTS: readonly ["write", "delete", "commit", "touch
|
|
|
40
40
|
export type PathMoment = (typeof PATH_MOMENTS)[number];
|
|
41
41
|
/** Does this moment carry a path for `on` / `ignore` to narrow? */
|
|
42
42
|
export declare function isPathMoment(m: string): m is PathMoment;
|
|
43
|
+
/**
|
|
44
|
+
* THE SUBJECT A NOTE'S SCOPE IS MATCHED AGAINST — a path at the path moments, and the COMMAND LINE
|
|
45
|
+
* at `command`, which is the one moment where the two kinds of entry are scoped differently.
|
|
46
|
+
*
|
|
47
|
+
* A command GUARDRAIL needs no scope and must not have one: its patterns are its scope, and a rule
|
|
48
|
+
* that could be narrowed one way and match another is a rule whose halves can disagree in silence.
|
|
49
|
+
* A command NOTE is the opposite case — it has no patterns at all, so without `.on(…)` it would show
|
|
50
|
+
* on every shell call in the session, which is the same as showing on none. `.on("npm install*")` is
|
|
51
|
+
* how it says which commands it is about, matched as a glob over the line about to run.
|
|
52
|
+
*/
|
|
53
|
+
export declare const BRIEF_SCOPE_MOMENTS: readonly ["write", "delete", "commit", "touch", "command"];
|
|
54
|
+
export type BriefScopeMoment = (typeof BRIEF_SCOPE_MOMENTS)[number];
|
|
55
|
+
/** Does a scope narrow anything for this KIND of entry at this moment? */
|
|
56
|
+
export declare function isScopable(kind: EntrySpec["kind"], m: string): boolean;
|
|
43
57
|
/**
|
|
44
58
|
* The host-written record of one session × agent, as a classifier sees it.
|
|
45
59
|
*
|
|
@@ -358,7 +372,7 @@ type DeadScope = "flow: every moment this entry fires at carries no path, so .on
|
|
|
358
372
|
* every scope is live. Saying `.on(…)` above `.at(command)` is the same mistake with the words in
|
|
359
373
|
* the other order, and the load's `dead-scope` refusal is what catches it. Both halves, always.
|
|
360
374
|
*/
|
|
361
|
-
type Scoping<At extends Moment, Verb> = [Extract<At,
|
|
375
|
+
type Scoping<At extends Moment, Verb, Scopable extends Moment = PathMoment> = [Extract<At, Scopable>] extends [never] ? (dead: DeadScope) => never : Verb;
|
|
362
376
|
/** Anything a pack may file under an entry name. The one shape `definePack` walks. */
|
|
363
377
|
export interface Sentence<S extends EntrySpec = EntrySpec> {
|
|
364
378
|
readonly spec: S;
|
|
@@ -381,8 +395,8 @@ export interface GuardrailSentence<Spoken extends GuardrailKey = never, At exten
|
|
|
381
395
|
export interface BreadcrumbSentence<Spoken extends BreadcrumbKey = never, At extends BreadcrumbMoment = BreadcrumbMoment> extends Sentence<BreadcrumbSpec> {
|
|
382
396
|
readonly at: Once<Spoken, "at", <M extends BreadcrumbMoment[]>(...moments: M) => BreadcrumbSentence<Spoken | "at", M[number]>>;
|
|
383
397
|
readonly for: Once<Spoken, "for", (...categories: Category[]) => BreadcrumbSentence<Spoken | "for", At>>;
|
|
384
|
-
readonly on: Once<Spoken, "on", Scoping<At, (...globs: string[]) => BreadcrumbSentence<Spoken | "on", At
|
|
385
|
-
readonly ignore: Once<Spoken, "ignore", Scoping<At, (...globs: string[]) => BreadcrumbSentence<Spoken | "ignore", At
|
|
398
|
+
readonly on: Once<Spoken, "on", Scoping<At, (...globs: string[]) => BreadcrumbSentence<Spoken | "on", At>, BriefScopeMoment>>;
|
|
399
|
+
readonly ignore: Once<Spoken, "ignore", Scoping<At, (...globs: string[]) => BreadcrumbSentence<Spoken | "ignore", At>, BriefScopeMoment>>;
|
|
386
400
|
readonly text: Once<Spoken, "text", (text: string) => BreadcrumbSentence<Spoken | "text", At>>;
|
|
387
401
|
readonly file: Once<Spoken, "file", (path: string) => BreadcrumbSentence<Spoken | "file", At>>;
|
|
388
402
|
readonly disabled: Once<Spoken, "disabled", (reason?: string) => BreadcrumbSentence<Spoken | "disabled", At>>;
|
|
@@ -495,6 +509,34 @@ export type Binding = PackBinding | OverrideBinding;
|
|
|
495
509
|
export interface Settings {
|
|
496
510
|
/** Context tokens between re-showings of a breadcrumb. Absent = the engine's own default. */
|
|
497
511
|
readonly driftTokens?: number;
|
|
512
|
+
/**
|
|
513
|
+
* Grammars this repo built itself, for `astGrep` rules whose language has no published package.
|
|
514
|
+
*
|
|
515
|
+
* ast-grep parses five languages out of the box and resolves anything else as an
|
|
516
|
+
* `@ast-grep/lang-<name>` package. A grammar that nobody publishes — astro, vue, svelte — has no
|
|
517
|
+
* third route unless a repo can hand over the tree-sitter library it built, which is what this is.
|
|
518
|
+
* Declared here rather than on the entry because a grammar is a fact about the MACHINE the guard
|
|
519
|
+
* runs on, not about any one rule: two rules on the same language must never be able to resolve
|
|
520
|
+
* it two ways.
|
|
521
|
+
*/
|
|
522
|
+
readonly grammars?: readonly Grammar[];
|
|
523
|
+
}
|
|
524
|
+
/**
|
|
525
|
+
* One hand-built tree-sitter grammar, as `registerDynamicLanguage` wants it.
|
|
526
|
+
*
|
|
527
|
+
* `libraryPath` is a path to a compiled library (`.so` / `.dylib`), relative to the repo root or
|
|
528
|
+
* absolute. It is a BUILD ARTEFACT — machine-specific, never committed — so a repo declaring one
|
|
529
|
+
* carries the recipe that builds it, and the refusal when it is missing names that file.
|
|
530
|
+
*/
|
|
531
|
+
export interface Grammar {
|
|
532
|
+
/** The name an `astGrep` rule spells as its `language`. */
|
|
533
|
+
readonly name: string;
|
|
534
|
+
/** The compiled tree-sitter library, relative to the repo root or absolute. */
|
|
535
|
+
readonly libraryPath: string;
|
|
536
|
+
/** The file extensions the grammar is for — ast-grep wants them, and they document the rule's reach. */
|
|
537
|
+
readonly extensions: readonly string[];
|
|
538
|
+
/** The symbol inside the library. Defaults to ast-grep's own `tree_sitter_<name>`. */
|
|
539
|
+
readonly languageSymbol?: string;
|
|
498
540
|
}
|
|
499
541
|
/** A whole guard, as its config file states it: bindings, in the order they were spoken. */
|
|
500
542
|
export interface FlowConfig {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jawache/flow",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Guardrails and breadcrumbs as code — packs you import, a config that typechecks, one adapter per harness.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -48,6 +48,7 @@
|
|
|
48
48
|
"dependency-cruiser": "^18.1.0"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
|
+
"@ast-grep/lang-python": "^0.0.6",
|
|
51
52
|
"@types/node": "^24.13.4",
|
|
52
53
|
"@vitest/coverage-v8": "4.1.10",
|
|
53
54
|
"commit-and-tag-version": "^13.1.2",
|