@vibe-agent-toolkit/cli 0.2.0-rc.8 â 0.2.0-rc.9
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/commands/audit/provenance.d.ts.map +1 -1
- package/dist/commands/audit/provenance.js +4 -3
- package/dist/commands/audit/provenance.js.map +1 -1
- package/dist/commands/build.d.ts.map +1 -1
- package/dist/commands/build.js +2 -1
- package/dist/commands/build.js.map +1 -1
- package/dist/commands/cache/clear.d.ts +17 -3
- package/dist/commands/cache/clear.d.ts.map +1 -1
- package/dist/commands/cache/clear.js +17 -3
- package/dist/commands/cache/clear.js.map +1 -1
- package/dist/commands/cache/index.d.ts.map +1 -1
- package/dist/commands/cache/index.js +19 -10
- package/dist/commands/cache/index.js.map +1 -1
- package/dist/commands/claude/context.d.ts +2 -2
- package/dist/commands/claude/context.js +4 -4
- package/dist/commands/claude/context.js.map +1 -1
- package/dist/commands/claude/index.d.ts +12 -11
- package/dist/commands/claude/index.d.ts.map +1 -1
- package/dist/commands/claude/index.js +14 -16
- package/dist/commands/claude/index.js.map +1 -1
- package/dist/commands/claude/marketplace/git-publish.d.ts.map +1 -1
- package/dist/commands/claude/marketplace/git-publish.js +19 -10
- package/dist/commands/claude/marketplace/git-publish.js.map +1 -1
- package/dist/commands/claude/marketplace/validate.js +2 -2
- package/dist/commands/claude/marketplace/validate.js.map +1 -1
- package/dist/commands/claude/org/skills.js +8 -8
- package/dist/commands/claude/org/skills.js.map +1 -1
- package/dist/commands/claude/plugin/build.d.ts.map +1 -1
- package/dist/commands/claude/plugin/build.js +11 -21
- package/dist/commands/claude/plugin/build.js.map +1 -1
- package/dist/commands/claude/plugin/plugin-files.js +3 -3
- package/dist/commands/claude/plugin/plugin-files.js.map +1 -1
- package/dist/commands/consistency-check.d.ts +11 -5
- package/dist/commands/consistency-check.d.ts.map +1 -1
- package/dist/commands/consistency-check.js +113 -78
- package/dist/commands/consistency-check.js.map +1 -1
- package/dist/commands/resources/check-progress.d.ts +6 -0
- package/dist/commands/resources/check-progress.d.ts.map +1 -1
- package/dist/commands/resources/check-progress.js +10 -2
- package/dist/commands/resources/check-progress.js.map +1 -1
- package/dist/commands/resources/check.d.ts +182 -203
- package/dist/commands/resources/check.d.ts.map +1 -1
- package/dist/commands/resources/check.js +272 -248
- package/dist/commands/resources/check.js.map +1 -1
- package/dist/commands/resources/index.d.ts.map +1 -1
- package/dist/commands/resources/index.js +140 -23
- package/dist/commands/resources/index.js.map +1 -1
- package/dist/commands/resources/query.d.ts +2 -2
- package/dist/commands/resources/query.d.ts.map +1 -1
- package/dist/commands/resources/query.js +20 -10
- package/dist/commands/resources/query.js.map +1 -1
- package/dist/commands/skill/test/run.js +3 -3
- package/dist/commands/skill/test/run.js.map +1 -1
- package/dist/commands/skills/build.d.ts +34 -21
- package/dist/commands/skills/build.d.ts.map +1 -1
- package/dist/commands/skills/build.js +99 -50
- package/dist/commands/skills/build.js.map +1 -1
- package/dist/commands/skills/skill-discovery.d.ts +15 -13
- package/dist/commands/skills/skill-discovery.d.ts.map +1 -1
- package/dist/commands/skills/skill-discovery.js +23 -4
- package/dist/commands/skills/skill-discovery.js.map +1 -1
- package/dist/commands/validate.d.ts.map +1 -1
- package/dist/commands/validate.js +31 -8
- package/dist/commands/validate.js.map +1 -1
- package/dist/commands/verify.d.ts +10 -4
- package/dist/commands/verify.d.ts.map +1 -1
- package/dist/commands/verify.js +92 -65
- package/dist/commands/verify.js.map +1 -1
- package/dist/report-schemas.d.ts.map +1 -1
- package/dist/report-schemas.js +0 -2
- package/dist/report-schemas.js.map +1 -1
- package/dist/skill-resolution/classify.js +2 -2
- package/dist/skill-resolution/classify.js.map +1 -1
- package/dist/skill-resolution/resolve-skill-reference.d.ts.map +1 -1
- package/dist/skill-resolution/resolve-skill-reference.js +48 -52
- package/dist/skill-resolution/resolve-skill-reference.js.map +1 -1
- package/dist/utils/claude-context-lens.d.ts +34 -0
- package/dist/utils/claude-context-lens.d.ts.map +1 -0
- package/dist/utils/claude-context-lens.js +39 -0
- package/dist/utils/claude-context-lens.js.map +1 -0
- package/dist/utils/projection-lenses.d.ts +98 -0
- package/dist/utils/projection-lenses.d.ts.map +1 -0
- package/dist/utils/projection-lenses.js +203 -0
- package/dist/utils/projection-lenses.js.map +1 -0
- package/dist/utils/projection-query.d.ts +38 -14
- package/dist/utils/projection-query.d.ts.map +1 -1
- package/dist/utils/projection-query.js +78 -17
- package/dist/utils/projection-query.js.map +1 -1
- package/dist/utils/projection-store.d.ts +61 -42
- package/dist/utils/projection-store.d.ts.map +1 -1
- package/dist/utils/projection-store.js +155 -59
- package/dist/utils/projection-store.js.map +1 -1
- package/dist/utils/relation-limits.d.ts +50 -0
- package/dist/utils/relation-limits.d.ts.map +1 -0
- package/dist/utils/relation-limits.js +50 -0
- package/dist/utils/relation-limits.js.map +1 -0
- package/dist/utils/skill-discovery.d.ts.map +1 -1
- package/dist/utils/skill-discovery.js +2 -1
- package/dist/utils/skill-discovery.js.map +1 -1
- package/dist/utils/skill-packaging-config.d.ts +38 -3
- package/dist/utils/skill-packaging-config.d.ts.map +1 -1
- package/dist/utils/skill-packaging-config.js +28 -3
- package/dist/utils/skill-packaging-config.js.map +1 -1
- package/package.json +16 -16
- package/schemas/resources-check.json +43 -0
- package/dist/commands/claude/budget.d.ts +0 -269
- package/dist/commands/claude/budget.d.ts.map +0 -1
- package/dist/commands/claude/budget.js +0 -507
- package/dist/commands/claude/budget.js.map +0 -1
- package/dist/utils/context-budget-issues.d.ts +0 -108
- package/dist/utils/context-budget-issues.d.ts.map +0 -1
- package/dist/utils/context-budget-issues.js +0 -280
- package/dist/utils/context-budget-issues.js.map +0 -1
- package/schemas/claude-budget.json +0 -197
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolve-skill-reference.js","sourceRoot":"","sources":["../../src/skill-resolution/resolve-skill-reference.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;A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,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC;IAClD,CAAC;IACD,IAAI,KAAK,CAAC,KAAK,KAAK,eAAe;QAAE,OAAO,mBAAmB,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IAC1E,OAAO,eAAe,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AACnC,CAAC;AAED,KAAK,UAAU,cAAc,CAAC,IAAY,EAAE,UAAkB,EAAE,KAAyB;IACvF,MAAM,eAAe,GAAG,CAAC,MAAM,2BAA2B,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC,IAAI,EAAE,CAAC;IACxF,MAAM,EAAE,YAAY,EAAE,eAAe,EAAE,GAAG,wBAAwB,CAAC,IAAI,EAAE,UAAU,EAAE,KAAK,CAAC,CAAC;IAC5F,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,UAAU,EAAE,UAAU,EAAE,KAAK,CAAC,UAAU,EAAE,eAAe,EAAE,YAAY,EAAE,eAAe,EAAE,CAAC;AAC/H,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Evaluating the always-loaded context chain over a tree, so SQL can ask what
|
|
3
|
+
* the harness loads where.
|
|
4
|
+
*
|
|
5
|
+
* ðĻ **This lens POPULATES. It is the only one that does, and that is the whole
|
|
6
|
+
* reason lens evaluation had to become lazy.** Its relations cannot be derived
|
|
7
|
+
* from the projection the query lane already holds, so it runs the real lane â
|
|
8
|
+
* a second population, which is why `projection-lenses.ts` evaluates a lens only
|
|
9
|
+
* when a statement names its relations. Why that is not a choice, and why the
|
|
10
|
+
* second population is a store hit rather than a competitor for the resources
|
|
11
|
+
* lane's entry: `docs/architecture/zones.md` §2, "The claude-context lens
|
|
12
|
+
* POPULATES".
|
|
13
|
+
*/
|
|
14
|
+
import { type ClaudeContextRelations, type PopulationCache } from '@vibe-agent-toolkit/resources';
|
|
15
|
+
import type { Logger } from './logger.js';
|
|
16
|
+
/**
|
|
17
|
+
* Populate the Claude-context lane and flatten its chains into the two
|
|
18
|
+
* relations.
|
|
19
|
+
*
|
|
20
|
+
* @param options - The run
|
|
21
|
+
* @param options.root - Absolute corpus root. Rooted HERE and nowhere else: a
|
|
22
|
+
* chain is a property of a position in the tree, and a population rooted at a
|
|
23
|
+
* subdirectory computes one against a corpus whose ancestors are missing
|
|
24
|
+
* @param options.logger - Where blob-stage refusals go (stderr, so a parseable
|
|
25
|
+
* document on stdout stays parseable)
|
|
26
|
+
* @param options.cache - The run's projection store, or undefined to re-derive
|
|
27
|
+
* @returns The rows, ready for `writeDerived`
|
|
28
|
+
*/
|
|
29
|
+
export declare function evaluateClaudeContextLens(options: {
|
|
30
|
+
root: string;
|
|
31
|
+
logger: Logger;
|
|
32
|
+
cache: PopulationCache | undefined;
|
|
33
|
+
}): Promise<ClaudeContextRelations>;
|
|
34
|
+
//# sourceMappingURL=claude-context-lens.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"claude-context-lens.d.ts","sourceRoot":"","sources":["../../src/utils/claude-context-lens.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAGL,KAAK,sBAAsB,EAC3B,KAAK,eAAe,EACrB,MAAM,+BAA+B,CAAC;AAIvC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAG1C;;;;;;;;;;;;GAYG;AACH,wBAAsB,yBAAyB,CAAC,OAAO,EAAE;IACvD,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,eAAe,GAAG,SAAS,CAAC;CACpC,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAQlC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Evaluating the always-loaded context chain over a tree, so SQL can ask what
|
|
3
|
+
* the harness loads where.
|
|
4
|
+
*
|
|
5
|
+
* ðĻ **This lens POPULATES. It is the only one that does, and that is the whole
|
|
6
|
+
* reason lens evaluation had to become lazy.** Its relations cannot be derived
|
|
7
|
+
* from the projection the query lane already holds, so it runs the real lane â
|
|
8
|
+
* a second population, which is why `projection-lenses.ts` evaluates a lens only
|
|
9
|
+
* when a statement names its relations. Why that is not a choice, and why the
|
|
10
|
+
* second population is a store hit rather than a competitor for the resources
|
|
11
|
+
* lane's entry: `docs/architecture/zones.md` §2, "The claude-context lens
|
|
12
|
+
* POPULATES".
|
|
13
|
+
*/
|
|
14
|
+
import { buildClaudeContextPopulation, claudeContextRelations, } from '@vibe-agent-toolkit/resources';
|
|
15
|
+
import { gitTrackerForProjectRoot } from '../commands/audit/distributed-tree.js';
|
|
16
|
+
import { populationWiring } from './population-wiring.js';
|
|
17
|
+
/**
|
|
18
|
+
* Populate the Claude-context lane and flatten its chains into the two
|
|
19
|
+
* relations.
|
|
20
|
+
*
|
|
21
|
+
* @param options - The run
|
|
22
|
+
* @param options.root - Absolute corpus root. Rooted HERE and nowhere else: a
|
|
23
|
+
* chain is a property of a position in the tree, and a population rooted at a
|
|
24
|
+
* subdirectory computes one against a corpus whose ancestors are missing
|
|
25
|
+
* @param options.logger - Where blob-stage refusals go (stderr, so a parseable
|
|
26
|
+
* document on stdout stays parseable)
|
|
27
|
+
* @param options.cache - The run's projection store, or undefined to re-derive
|
|
28
|
+
* @returns The rows, ready for `writeDerived`
|
|
29
|
+
*/
|
|
30
|
+
export async function evaluateClaudeContextLens(options) {
|
|
31
|
+
const { root, logger, cache } = options;
|
|
32
|
+
const gitTracker = await gitTrackerForProjectRoot(root);
|
|
33
|
+
const projection = await buildClaudeContextPopulation({
|
|
34
|
+
root,
|
|
35
|
+
...populationWiring(logger, gitTracker, cache, root),
|
|
36
|
+
});
|
|
37
|
+
return claudeContextRelations(projection);
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=claude-context-lens.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"claude-context-lens.js","sourceRoot":"","sources":["../../src/utils/claude-context-lens.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EACL,4BAA4B,EAC5B,sBAAsB,GAGvB,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EAAE,wBAAwB,EAAE,MAAM,uCAAuC,CAAC;AAGjF,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE1D;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,KAAK,UAAU,yBAAyB,CAAC,OAI/C;IACC,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC;IACxC,MAAM,UAAU,GAAG,MAAM,wBAAwB,CAAC,IAAI,CAAC,CAAC;IACxD,MAAM,UAAU,GAAG,MAAM,4BAA4B,CAAC;QACpD,IAAI;QACJ,GAAG,gBAAgB,CAAC,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,IAAI,CAAC;KACrD,CAAC,CAAC;IACH,OAAO,sBAAsB,CAAC,UAAU,CAAC,CAAC;AAC5C,CAAC"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which lenses a run evaluates, and when it does NOT â the selection that keeps
|
|
3
|
+
* the derived relations affordable.
|
|
4
|
+
*
|
|
5
|
+
* ðĻ **The selector over-selects on purpose: a FALSE NEGATIVE fails a run that
|
|
6
|
+
* had an answer.** A lens skipped when its relation is named leaves that
|
|
7
|
+
* relation ABSENT from the run's database, so the statement is refused with
|
|
8
|
+
* `no such table` â loud rather than wrong, because the refusal is SQLite's and
|
|
9
|
+
* does not depend on this scan. The cost that forced the selection, the rules
|
|
10
|
+
* that keep it fail-safe, and why the registry lives in the CLI rather than in a
|
|
11
|
+
* population are in
|
|
12
|
+
* `docs/architecture/zones.md` §2, "A lens is evaluated only when a statement
|
|
13
|
+
* names one of its relations".
|
|
14
|
+
*/
|
|
15
|
+
import { type DerivedTableName, type PopulationCache, type Projection } from '@vibe-agent-toolkit/resources';
|
|
16
|
+
import type { Logger } from './logger.js';
|
|
17
|
+
/**
|
|
18
|
+
* The rows one lens evaluation produced, keyed by `DERIVED_TABLES`' own keys.
|
|
19
|
+
*
|
|
20
|
+
* Structurally `projection-sqlite`'s `DerivedRows`, spelled here so every lens
|
|
21
|
+
* states its output in terms of the RELATION REGISTRY rather than of a storage
|
|
22
|
+
* backend. `writeDerived` accepts it unchanged.
|
|
23
|
+
*/
|
|
24
|
+
export type LensRows = {
|
|
25
|
+
readonly [Name in DerivedTableName]?: readonly Record<string, unknown>[];
|
|
26
|
+
};
|
|
27
|
+
/** Everything a lens may read while evaluating. */
|
|
28
|
+
export interface LensEvaluationInput {
|
|
29
|
+
/** The resources-lane projection the run already populated. */
|
|
30
|
+
readonly projection: Projection;
|
|
31
|
+
/** Absolute corpus root, for a lens that must populate a lane of its own. */
|
|
32
|
+
readonly root: string;
|
|
33
|
+
/** Where a lens's own blob-stage refusals go â stderr. */
|
|
34
|
+
readonly logger: Logger;
|
|
35
|
+
/** The run's projection store, so a lens's own population can hit it. */
|
|
36
|
+
readonly cache: PopulationCache | undefined;
|
|
37
|
+
}
|
|
38
|
+
/** One lens: the relations it owns, and how to produce their rows. */
|
|
39
|
+
export interface ProjectionLens {
|
|
40
|
+
/** How the lens names itself in `lensesEvaluated` and in a refusal. */
|
|
41
|
+
readonly name: string;
|
|
42
|
+
/**
|
|
43
|
+
* Every relation this lens produces, by registry key.
|
|
44
|
+
*
|
|
45
|
+
* â Disjoint from every other lens's. Two lenses claiming one relation would
|
|
46
|
+
* make "was it evaluated" unanswerable, and the second `writeDerived` would
|
|
47
|
+
* CLEAR the first's rows â `writeDerived` replaces a relation's contents.
|
|
48
|
+
*/
|
|
49
|
+
readonly relations: readonly DerivedTableName[];
|
|
50
|
+
/**
|
|
51
|
+
* Produce the rows.
|
|
52
|
+
*
|
|
53
|
+
* @param input - The projection, the root, and the run's oracles
|
|
54
|
+
* @returns Every relation this lens owns â all of them, every time, because
|
|
55
|
+
* omitting one leaves its previous contents in place
|
|
56
|
+
*/
|
|
57
|
+
readonly evaluate: (input: LensEvaluationInput) => Promise<LensRows> | LensRows;
|
|
58
|
+
}
|
|
59
|
+
/** The authored-link lens: `lens_contexts`, `edges`, `edge_resolutions`. */
|
|
60
|
+
export declare const AUTHORED_LINK_LENS: ProjectionLens;
|
|
61
|
+
/** The always-loaded context lens: `claude_context_chains`, `claude_context_loads`. */
|
|
62
|
+
export declare const CLAUDE_CONTEXT_LENS: ProjectionLens;
|
|
63
|
+
/** Every lens the query lane can evaluate, in evaluation order. */
|
|
64
|
+
export declare const PROJECTION_LENSES: readonly ProjectionLens[];
|
|
65
|
+
/**
|
|
66
|
+
* The SQL names of a lens's relations. Read off `DERIVED_TABLES` rather than
|
|
67
|
+
* restated: the SQL name and the registry key are deliberately different
|
|
68
|
+
* vocabularies (`edgeResolutions` is spelled `edge_resolutions`), so a second
|
|
69
|
+
* copy here would be a rename waiting to be missed.
|
|
70
|
+
*
|
|
71
|
+
* @param lens - The lens
|
|
72
|
+
* @returns Its relations as SQL spells them
|
|
73
|
+
*/
|
|
74
|
+
export declare function lensRelationNames(lens: ProjectionLens): readonly string[];
|
|
75
|
+
/**
|
|
76
|
+
* The lenses a run has to evaluate, given the statements it declared.
|
|
77
|
+
*
|
|
78
|
+
* @param statements - Every statement the run may ask, or `undefined` when the
|
|
79
|
+
* caller cannot enumerate them. â `undefined` selects EVERY lens â see the
|
|
80
|
+
* header on why the fail-safe direction is not negotiable
|
|
81
|
+
* @returns The lenses to evaluate, in {@link PROJECTION_LENSES} order
|
|
82
|
+
*/
|
|
83
|
+
export declare function lensesNamedBy(statements: readonly string[] | undefined): readonly ProjectionLens[];
|
|
84
|
+
/**
|
|
85
|
+
* Evaluate one lens and hand back its rows, refusing any that are not exactly
|
|
86
|
+
* the relations it declares.
|
|
87
|
+
*
|
|
88
|
+
* `LensRows` makes every relation optional, so a lens that forgot one compiles â
|
|
89
|
+
* and `writeDerived` would leave that relation empty, a table that reads as a
|
|
90
|
+
* healthy tree. Checked here because this is the one place every lens passes.
|
|
91
|
+
*
|
|
92
|
+
* @param lens - The lens
|
|
93
|
+
* @param input - What it may read
|
|
94
|
+
* @returns Its rows
|
|
95
|
+
* @throws Error When the rows omit a declared relation or carry an undeclared one
|
|
96
|
+
*/
|
|
97
|
+
export declare function evaluateLens(lens: ProjectionLens, input: LensEvaluationInput): Promise<LensRows>;
|
|
98
|
+
//# sourceMappingURL=projection-lenses.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"projection-lenses.d.ts","sourceRoot":"","sources":["../../src/utils/projection-lenses.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAkB,KAAK,gBAAgB,EAAE,KAAK,eAAe,EAAE,KAAK,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAI7H,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAE1C;;;;;;GAMG;AACH,MAAM,MAAM,QAAQ,GAAG;IACrB,QAAQ,EAAE,IAAI,IAAI,gBAAgB,CAAC,CAAC,EAAE,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE;CACzE,CAAC;AAEF,mDAAmD;AACnD,MAAM,WAAW,mBAAmB;IAClC,+DAA+D;IAC/D,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC;IAChC,6EAA6E;IAC7E,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,0DAA0D;IAC1D,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,yEAAyE;IACzE,QAAQ,CAAC,KAAK,EAAE,eAAe,GAAG,SAAS,CAAC;CAC7C;AAED,sEAAsE;AACtE,MAAM,WAAW,cAAc;IAC7B,uEAAuE;IACvE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB;;;;;;OAMG;IACH,QAAQ,CAAC,SAAS,EAAE,SAAS,gBAAgB,EAAE,CAAC;IAChD;;;;;;OAMG;IACH,QAAQ,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,mBAAmB,KAAK,OAAO,CAAC,QAAQ,CAAC,GAAG,QAAQ,CAAC;CACjF;AAED,4EAA4E;AAC5E,eAAO,MAAM,kBAAkB,EAAE,cAIhC,CAAC;AAEF,uFAAuF;AACvF,eAAO,MAAM,mBAAmB,EAAE,cAIjC,CAAC;AAEF,mEAAmE;AACnE,eAAO,MAAM,iBAAiB,EAAE,SAAS,cAAc,EAGtD,CAAC;AAEF;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,cAAc,GAAG,SAAS,MAAM,EAAE,CAEzE;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,UAAU,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,GAAG,SAAS,cAAc,EAAE,CAMlG;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,YAAY,CAChC,IAAI,EAAE,cAAc,EACpB,KAAK,EAAE,mBAAmB,GACzB,OAAO,CAAC,QAAQ,CAAC,CAYnB"}
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which lenses a run evaluates, and when it does NOT â the selection that keeps
|
|
3
|
+
* the derived relations affordable.
|
|
4
|
+
*
|
|
5
|
+
* ðĻ **The selector over-selects on purpose: a FALSE NEGATIVE fails a run that
|
|
6
|
+
* had an answer.** A lens skipped when its relation is named leaves that
|
|
7
|
+
* relation ABSENT from the run's database, so the statement is refused with
|
|
8
|
+
* `no such table` â loud rather than wrong, because the refusal is SQLite's and
|
|
9
|
+
* does not depend on this scan. The cost that forced the selection, the rules
|
|
10
|
+
* that keep it fail-safe, and why the registry lives in the CLI rather than in a
|
|
11
|
+
* population are in
|
|
12
|
+
* `docs/architecture/zones.md` §2, "A lens is evaluated only when a statement
|
|
13
|
+
* names one of its relations".
|
|
14
|
+
*/
|
|
15
|
+
import { DERIVED_TABLES } from '@vibe-agent-toolkit/resources';
|
|
16
|
+
import { evaluateClaudeContextLens } from './claude-context-lens.js';
|
|
17
|
+
import { evaluateAuthoredLenses } from './edge-lens-evaluation.js';
|
|
18
|
+
/** The authored-link lens: `lens_contexts`, `edges`, `edge_resolutions`. */
|
|
19
|
+
export const AUTHORED_LINK_LENS = {
|
|
20
|
+
name: 'authored-link',
|
|
21
|
+
relations: ['lensContexts', 'edges', 'edgeResolutions'],
|
|
22
|
+
evaluate: ({ projection }) => evaluateAuthoredLenses(projection),
|
|
23
|
+
};
|
|
24
|
+
/** The always-loaded context lens: `claude_context_chains`, `claude_context_loads`. */
|
|
25
|
+
export const CLAUDE_CONTEXT_LENS = {
|
|
26
|
+
name: 'claude-context',
|
|
27
|
+
relations: ['claudeContextChains', 'claudeContextLoads'],
|
|
28
|
+
evaluate: ({ root, logger, cache }) => evaluateClaudeContextLens({ root, logger, cache }),
|
|
29
|
+
};
|
|
30
|
+
/** Every lens the query lane can evaluate, in evaluation order. */
|
|
31
|
+
export const PROJECTION_LENSES = [
|
|
32
|
+
AUTHORED_LINK_LENS,
|
|
33
|
+
CLAUDE_CONTEXT_LENS,
|
|
34
|
+
];
|
|
35
|
+
/**
|
|
36
|
+
* The SQL names of a lens's relations. Read off `DERIVED_TABLES` rather than
|
|
37
|
+
* restated: the SQL name and the registry key are deliberately different
|
|
38
|
+
* vocabularies (`edgeResolutions` is spelled `edge_resolutions`), so a second
|
|
39
|
+
* copy here would be a rename waiting to be missed.
|
|
40
|
+
*
|
|
41
|
+
* @param lens - The lens
|
|
42
|
+
* @returns Its relations as SQL spells them
|
|
43
|
+
*/
|
|
44
|
+
export function lensRelationNames(lens) {
|
|
45
|
+
return lens.relations.map((name) => DERIVED_TABLES[name].name);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* The lenses a run has to evaluate, given the statements it declared.
|
|
49
|
+
*
|
|
50
|
+
* @param statements - Every statement the run may ask, or `undefined` when the
|
|
51
|
+
* caller cannot enumerate them. â `undefined` selects EVERY lens â see the
|
|
52
|
+
* header on why the fail-safe direction is not negotiable
|
|
53
|
+
* @returns The lenses to evaluate, in {@link PROJECTION_LENSES} order
|
|
54
|
+
*/
|
|
55
|
+
export function lensesNamedBy(statements) {
|
|
56
|
+
if (statements === undefined)
|
|
57
|
+
return PROJECTION_LENSES;
|
|
58
|
+
const readable = statements.map((sql) => wordsIn(withoutCommentsAndLiterals(sql)));
|
|
59
|
+
return PROJECTION_LENSES.filter((lens) => lensRelationNames(lens).some((relation) => readable.some((words) => namesRelation(words, relation))));
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Evaluate one lens and hand back its rows, refusing any that are not exactly
|
|
63
|
+
* the relations it declares.
|
|
64
|
+
*
|
|
65
|
+
* `LensRows` makes every relation optional, so a lens that forgot one compiles â
|
|
66
|
+
* and `writeDerived` would leave that relation empty, a table that reads as a
|
|
67
|
+
* healthy tree. Checked here because this is the one place every lens passes.
|
|
68
|
+
*
|
|
69
|
+
* @param lens - The lens
|
|
70
|
+
* @param input - What it may read
|
|
71
|
+
* @returns Its rows
|
|
72
|
+
* @throws Error When the rows omit a declared relation or carry an undeclared one
|
|
73
|
+
*/
|
|
74
|
+
export async function evaluateLens(lens, input) {
|
|
75
|
+
const rows = await lens.evaluate(input);
|
|
76
|
+
const declared = lens.relations;
|
|
77
|
+
const missing = declared.filter((name) => !Object.hasOwn(rows, name));
|
|
78
|
+
const undeclared = Object.keys(rows).filter((name) => !declared.includes(name));
|
|
79
|
+
if (missing.length > 0 || undeclared.length > 0) {
|
|
80
|
+
throw new Error(`Lens "${lens.name}" must produce exactly [${declared.join(', ')}];`
|
|
81
|
+
+ ` missing [${missing.join(', ')}], undeclared [${undeclared.join(', ')}]`);
|
|
82
|
+
}
|
|
83
|
+
return rows;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Blank out the parts of a statement that cannot name a table: line comments,
|
|
87
|
+
* block comments and single-quoted string literals. Quoted IDENTIFIERS
|
|
88
|
+
* (`"edges"`, `[edges]`, backticked) are deliberately left alone â those ARE
|
|
89
|
+
* table references, spelled differently. Replaced with spaces rather than
|
|
90
|
+
* removed, so a block comment between `FROM` and `edges` cannot let the two run
|
|
91
|
+
* together.
|
|
92
|
+
*
|
|
93
|
+
* @param sql - The statement
|
|
94
|
+
* @returns The statement with every non-code span blanked
|
|
95
|
+
*/
|
|
96
|
+
function withoutCommentsAndLiterals(sql) {
|
|
97
|
+
let out = '';
|
|
98
|
+
let index = 0;
|
|
99
|
+
while (index < sql.length) {
|
|
100
|
+
const end = spanEnd(sql, index);
|
|
101
|
+
if (end === undefined) {
|
|
102
|
+
out += sql.charAt(index);
|
|
103
|
+
index += 1;
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
const span = sql.slice(index, end);
|
|
107
|
+
out += QUOTED_IDENTIFIER_CLOSERS.has(span.charAt(0)) ? span : ' '.repeat(span.length);
|
|
108
|
+
index = end;
|
|
109
|
+
}
|
|
110
|
+
return out;
|
|
111
|
+
}
|
|
112
|
+
/** The characters that open a quoted identifier, and the one that closes each. */
|
|
113
|
+
const QUOTED_IDENTIFIER_CLOSERS = new Map([['"', '"'], ['[', ']'], ['`', '`']]);
|
|
114
|
+
/** Every quoted span's opener and closer: the identifiers, plus `'` for a literal. */
|
|
115
|
+
const QUOTE_CLOSERS = new Map([...QUOTED_IDENTIFIER_CLOSERS, ["'", "'"]]);
|
|
116
|
+
/**
|
|
117
|
+
* Where a span starting at `start` ends: a line comment, a block comment, a
|
|
118
|
+
* single-quoted literal â or a quoted IDENTIFIER, consumed only so it can be
|
|
119
|
+
* handed back unblanked.
|
|
120
|
+
*
|
|
121
|
+
* â Quoted identifiers MUST be consumed by this same scan even though their
|
|
122
|
+
* contents stay code, and the reason is the whole of this function. SQLite gives
|
|
123
|
+
* `'`, `--` and `/*` no meaning inside `"âĶ"`, `[âĶ]` or `` `âĶ` ``. A scanner that
|
|
124
|
+
* skips those spans lets a character inside one open a literal or a comment that
|
|
125
|
+
* SQLite never opened, desynchronises, and blanks a span of REAL SQL â taking the
|
|
126
|
+
* relation name with it. The statement then reads an EMPTY relation and answers 0
|
|
127
|
+
* instead of being refused, which for a declared check is a silent exit 0: a gate
|
|
128
|
+
* that cannot fail.
|
|
129
|
+
*
|
|
130
|
+
* Scanning left to right is what keeps the spans mutually exclusive: a comment
|
|
131
|
+
* marker inside a literal is never looked at, nor a quote inside a comment.
|
|
132
|
+
*
|
|
133
|
+
* @param sql - The statement
|
|
134
|
+
* @param start - Where to look
|
|
135
|
+
* @returns The index just past the span, or undefined when none opens here
|
|
136
|
+
*/
|
|
137
|
+
function spanEnd(sql, start) {
|
|
138
|
+
const pair = sql.slice(start, start + 2);
|
|
139
|
+
if (pair === '--') {
|
|
140
|
+
const newline = sql.indexOf('\n', start);
|
|
141
|
+
return newline === -1 ? sql.length : newline;
|
|
142
|
+
}
|
|
143
|
+
if (pair === '/*') {
|
|
144
|
+
const close = sql.indexOf('*/', start + 2);
|
|
145
|
+
return close === -1 ? undefined : close + 2;
|
|
146
|
+
}
|
|
147
|
+
const closer = QUOTE_CLOSERS.get(sql.charAt(start));
|
|
148
|
+
return closer === undefined ? undefined : quotedEnd(sql, start, closer);
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Where a quoted span ends. A doubled closer (`''`, `""`, two backticks) is an
|
|
152
|
+
* escaped one; `[âĶ]` has no escape. Left unterminated, the span ends at the last
|
|
153
|
+
* doubled closer instead â what the single pattern this replaced did by
|
|
154
|
+
* backtracking.
|
|
155
|
+
*
|
|
156
|
+
* @param sql - The statement
|
|
157
|
+
* @param start - The opening quote
|
|
158
|
+
* @param closer - The character that closes it
|
|
159
|
+
* @returns The index just past the span, or undefined when it never closes
|
|
160
|
+
*/
|
|
161
|
+
function quotedEnd(sql, start, closer) {
|
|
162
|
+
let fallback;
|
|
163
|
+
let from = start + 1;
|
|
164
|
+
for (;;) {
|
|
165
|
+
const close = sql.indexOf(closer, from);
|
|
166
|
+
if (close === -1)
|
|
167
|
+
return fallback;
|
|
168
|
+
if (closer === ']' || sql.charAt(close + 1) !== closer)
|
|
169
|
+
return close + 1;
|
|
170
|
+
fallback = close + 1;
|
|
171
|
+
from = close + 2;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Every whole word in a statement, lowercased.
|
|
176
|
+
*
|
|
177
|
+
* Relation names are `[a-z_]` only and `_` is a word character, so membership in
|
|
178
|
+
* this set answers exactly what a `\b`-anchored search would: `my_edges`
|
|
179
|
+
* tokenizes whole and never answers for `edges`. One pass per statement, rather
|
|
180
|
+
* than one pattern per relation, and no `RegExp` built from a variable.
|
|
181
|
+
*
|
|
182
|
+
* @param sql - The statement, already stripped of comments and literals
|
|
183
|
+
* @returns Its identifier-character runs, lowercased
|
|
184
|
+
*/
|
|
185
|
+
function wordsIn(sql) {
|
|
186
|
+
return new Set((sql.match(IDENTIFIER_RUNS) ?? []).map((word) => word.toLowerCase()));
|
|
187
|
+
}
|
|
188
|
+
/** Runs of identifier characters â SQL's word boundaries, the `\b` equivalent. */
|
|
189
|
+
const IDENTIFIER_RUNS = /[a-z0-9_]+/gi;
|
|
190
|
+
/**
|
|
191
|
+
* Does a statement's word set name this relation?
|
|
192
|
+
*
|
|
193
|
+
* Case-folds the relation as well as the words: a registry name spelled with an
|
|
194
|
+
* uppercase letter would otherwise miss every statement silently.
|
|
195
|
+
*
|
|
196
|
+
* @param words - The statement's words, from {@link wordsIn}
|
|
197
|
+
* @param relation - The relation's SQL name
|
|
198
|
+
* @returns True when the statement could be reading that relation
|
|
199
|
+
*/
|
|
200
|
+
function namesRelation(words, relation) {
|
|
201
|
+
return words.has(relation.toLowerCase());
|
|
202
|
+
}
|
|
203
|
+
//# sourceMappingURL=projection-lenses.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"projection-lenses.js","sourceRoot":"","sources":["../../src/utils/projection-lenses.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAE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O,IAAI,GAAG,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,eAAe,CAAC,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC;AACvF,CAAC;AAED,kFAAkF;AAClF,MAAM,eAAe,GAAG,cAAc,CAAC;AAEvC;;;;;;;;;GASG;AACH,SAAS,aAAa,CAAC,KAA0B,EAAE,QAAgB;IACjE,OAAO,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC,CAAC;AAC3C,CAAC"}
|
|
@@ -45,6 +45,7 @@
|
|
|
45
45
|
* closure also puts the legible-failure wrapper on the single path that can
|
|
46
46
|
* throw, so no command can forget it.
|
|
47
47
|
*/
|
|
48
|
+
import { type Projection } from '@vibe-agent-toolkit/resources';
|
|
48
49
|
import type { Logger } from './logger.js';
|
|
49
50
|
/** Where the POPULATION a statement ran against came from. */
|
|
50
51
|
export type PopulationOrigin = 'derived' | 'store';
|
|
@@ -128,15 +129,33 @@ export interface ProjectionProvenance {
|
|
|
128
129
|
*/
|
|
129
130
|
readonly populationMs: number;
|
|
130
131
|
/**
|
|
131
|
-
*
|
|
132
|
+
* The lenses this run evaluated, by name, in evaluation order.
|
|
133
|
+
*
|
|
134
|
+
* ð **Published because "which lenses ran" became a DECISION, and an
|
|
135
|
+
* unpublished decision is one nobody can check.** Without it an empty derived
|
|
136
|
+
* relation is ambiguous â no rows, or no evaluation? This is the tell, in the
|
|
137
|
+
* same family as {@link population}, and what makes a `lensSecs` of `0`
|
|
138
|
+
* legible rather than alarming.
|
|
139
|
+
*
|
|
140
|
+
* â ïļ Not the only guard: a relation no evaluated lens produced does not
|
|
141
|
+
* EXIST in the run's database, so a statement naming it is refused by SQLite
|
|
142
|
+
* (see {@link withQueriedProjection}). This field explains a cheap run rather
|
|
143
|
+
* than excusing a blind one.
|
|
144
|
+
*/
|
|
145
|
+
readonly lensesEvaluated: readonly string[];
|
|
146
|
+
/**
|
|
147
|
+
* What EVALUATING THE LENSES cost, separately from populating the tree.
|
|
132
148
|
*
|
|
133
149
|
* Separate because the two answer different questions and a reader must be
|
|
134
150
|
* able to tell them apart. Population is work every verb pays and the store
|
|
135
|
-
* can make cheap; this is work the *
|
|
136
|
-
*
|
|
137
|
-
*
|
|
138
|
-
*
|
|
139
|
-
*
|
|
151
|
+
* can make cheap; this is work the *derived relations* cost, and a store hit
|
|
152
|
+
* does NOT make an authored-link evaluation cheaper â it is a pass over the
|
|
153
|
+
* served rows just as over derived ones. Folded into `populationMs` it would
|
|
154
|
+
* look like the store getting worse.
|
|
155
|
+
*
|
|
156
|
+
* â ïļ **Not an unconditional cost.** A run whose statements name no derived
|
|
157
|
+
* relation evaluates nothing and reports `0`; {@link lensesEvaluated} says
|
|
158
|
+
* which lenses the number covers.
|
|
140
159
|
*
|
|
141
160
|
* â ïļ **DISJOINT from `populationMs`, and that is enforced by where the
|
|
142
161
|
* population clock stops, not by convention.** It shipped overlapping: the
|
|
@@ -146,9 +165,9 @@ export interface ProjectionProvenance {
|
|
|
146
165
|
* a reader comparing a served run against a derived one is the whole reason
|
|
147
166
|
* they are two fields.
|
|
148
167
|
*
|
|
149
|
-
* â ïļ Published rather than merely measured, because
|
|
150
|
-
*
|
|
151
|
-
*
|
|
168
|
+
* â ïļ Published rather than merely measured, because a cost that is invisible
|
|
169
|
+
* is the one nobody can argue with. It is the evidence the selection above
|
|
170
|
+
* rests on, and the evidence any future flag would rest on.
|
|
152
171
|
*/
|
|
153
172
|
readonly lensMs: number;
|
|
154
173
|
}
|
|
@@ -182,7 +201,7 @@ export interface PopulationExtent {
|
|
|
182
201
|
*
|
|
183
202
|
* ðŠĪ Realizations rather than any other count, because every alternative
|
|
184
203
|
* fails to reach zero on the case that matters: `roots` always holds exactly
|
|
185
|
-
* one row (the invariant thrown for below), so a total over all
|
|
204
|
+
* one row (the invariant thrown for below), so a total over all thirteen tables
|
|
186
205
|
* is never 0; `blobs` is content-keyed and deduped, so it counts parse REACH
|
|
187
206
|
* and already has its own guard in `onBlobPopulation`; and `resources` counts
|
|
188
207
|
* identities, which a corpus can legitimately have none of while enumerating
|
|
@@ -252,16 +271,21 @@ export declare function assertQueriesCompile(statements: readonly PreflightState
|
|
|
252
271
|
* @param options.preflight - Every statement this run intends to ask, compiled
|
|
253
272
|
* against the empty schema BEFORE the population starts. See
|
|
254
273
|
* {@link assertQueriesCompile}
|
|
255
|
-
* @param
|
|
256
|
-
*
|
|
257
|
-
* it
|
|
274
|
+
* @param options.statements - Every statement this run may ask, for LENS
|
|
275
|
+
* SELECTION only â never compiled, never bound, and deliberately separate from
|
|
276
|
+
* `preflight`. â Omitting it evaluates EVERY lens, which is the correct answer
|
|
277
|
+
* and the expensive one
|
|
278
|
+
* @param work - Given the asker, where its rows came from, how much of the tree
|
|
279
|
+
* they cover, and the ROWS THEMSELVES. The store is open for exactly this call
|
|
280
|
+
* and closed however it ends
|
|
258
281
|
* @returns Whatever `work` returned
|
|
259
282
|
*/
|
|
260
283
|
export declare function withQueriedProjection<T>(options: {
|
|
261
284
|
root: string;
|
|
262
285
|
logger: Logger;
|
|
263
286
|
preflight?: readonly PreflightStatement[];
|
|
264
|
-
|
|
287
|
+
statements?: readonly string[];
|
|
288
|
+
}, work: (ask: AskProjection, provenance: ProjectionProvenance, extent: PopulationExtent, projection: Projection) => Promise<T> | T): Promise<T>;
|
|
265
289
|
/**
|
|
266
290
|
* Turn a rejected statement into a message that names the surface it missed.
|
|
267
291
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"projection-query.d.ts","sourceRoot":"","sources":["../../src/utils/projection-query.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;
|
|
1
|
+
{"version":3,"file":"projection-query.d.ts","sourceRoot":"","sources":["../../src/utils/projection-query.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;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