@litfamily/litcodex 1.0.7 → 1.0.8
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/README.md +105 -71
- package/dist/install/doctor-render.js +1 -0
- package/dist/install/doctor.js +8 -0
- package/dist/install/types.d.ts +3 -0
- package/marketplace/plugins/litcodex/.codex-plugin/plugin.json +1 -1
- package/marketplace/plugins/litcodex/components/auto-update/package.json +1 -1
- package/marketplace/plugins/litcodex/components/comment-checker/package.json +1 -1
- package/marketplace/plugins/litcodex/components/git-bash/package.json +1 -1
- package/marketplace/plugins/litcodex/components/lit-loop/dist/hook-cli.d.ts +8 -1
- package/marketplace/plugins/litcodex/components/lit-loop/dist/hook-cli.js +36 -4
- package/marketplace/plugins/litcodex/components/lit-loop/dist/jev-hint.d.ts +112 -0
- package/marketplace/plugins/litcodex/components/lit-loop/dist/jev-hint.js +522 -0
- package/marketplace/plugins/litcodex/components/lit-loop/package.json +1 -1
- package/marketplace/plugins/litcodex/components/lsp/package.json +1 -1
- package/marketplace/plugins/litcodex/components/rules/package.json +1 -1
- package/marketplace/plugins/litcodex/components/start-work-continuation/package.json +1 -1
- package/marketplace/plugins/litcodex/components/telemetry/package.json +1 -1
- package/marketplace/plugins/litcodex/components/wikify-knowledge/package.json +1 -1
- package/node_modules/@litcodex/lit-loop/dist/hook-cli.d.ts +8 -1
- package/node_modules/@litcodex/lit-loop/dist/hook-cli.js +36 -4
- package/node_modules/@litcodex/lit-loop/dist/jev-hint.d.ts +112 -0
- package/node_modules/@litcodex/lit-loop/dist/jev-hint.js +522 -0
- package/node_modules/@litcodex/lit-loop/package.json +1 -1
- package/package.json +3 -3
- package/readme-assets/badge-version.svg +1 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type JevHttpClient } from "./jev-hint.js";
|
|
1
2
|
/** Hard cap on stdin to bound memory / ReDoS exposure inside the 5 s Codex hook budget. 8 MB. */
|
|
2
3
|
export declare const MAX_STDIN_BYTES = 8000000;
|
|
3
4
|
/** Machine-readable error envelope emitted to stderr on a NON-zero exit. */
|
|
@@ -14,7 +15,13 @@ export type LitHookErrorCode = "LIT_HOOK_STDIN_INVALID_JSON" | "LIT_HOOK_STDIN_T
|
|
|
14
15
|
* NEVER throws. Writes the camelCase activation line to stdout (empty on no-op), or a LitHookError
|
|
15
16
|
* line to stderr on malformed / oversized stdin.
|
|
16
17
|
*/
|
|
17
|
-
export declare function runUserPromptSubmitHookCli(stdin: NodeJS.ReadableStream, stdout: NodeJS.WritableStream, stderr: NodeJS.WritableStream, repoRoot?: string): Promise<number>;
|
|
18
|
+
export declare function runUserPromptSubmitHookCli(stdin: NodeJS.ReadableStream, stdout: NodeJS.WritableStream, stderr: NodeJS.WritableStream, repoRoot?: string, jev?: JevHookOptions): Promise<number>;
|
|
19
|
+
/** Injectable Jev dependencies; production uses the process environment and built-in `fetch`. */
|
|
20
|
+
export interface JevHookOptions {
|
|
21
|
+
readonly env?: NodeJS.ProcessEnv;
|
|
22
|
+
readonly http?: JevHttpClient;
|
|
23
|
+
readonly skillsRoot?: string;
|
|
24
|
+
}
|
|
18
25
|
/** Enforce lit-plan persistence when a Stop hook event arrives. */
|
|
19
26
|
export declare function runStopPlanPersistenceHookCli(stdin: NodeJS.ReadableStream, stdout: NodeJS.WritableStream, stderr: NodeJS.WritableStream, repoRoot?: string): Promise<number>;
|
|
20
27
|
export declare function runPreToolUseCreateGoalGuardCli(stdin: NodeJS.ReadableStream, stdout: NodeJS.WritableStream, stderr: NodeJS.WritableStream): Promise<number>;
|
|
@@ -5,9 +5,12 @@
|
|
|
5
5
|
// hands the parsed value to the pure engine, and writes the decision. Exit map: any structurally
|
|
6
6
|
// valid event → 0 (no-op writes zero bytes); unparseable or oversized stdin → 2 with a
|
|
7
7
|
// machine-readable LitHookError JSON line on stderr. NEVER calls process.exit (the dispatcher does)
|
|
8
|
-
// and NEVER throws.
|
|
8
|
+
// and NEVER throws. A UserPromptSubmit turn the router leaves alone may carry the opt-in Jev skill
|
|
9
|
+
// hint (./jev-hint.ts) and, once per session while it is on, a plain-text banner; with its switch
|
|
10
|
+
// off, that path makes no request and writes nothing.
|
|
9
11
|
import { isAbsolute } from "node:path";
|
|
10
|
-
import { applyPreToolUseCreateGoalGuard, runUserPromptSubmitHook } from "./codex-hook.js";
|
|
12
|
+
import { applyPreToolUseCreateGoalGuard, isLitUserPromptSubmitInput, runUserPromptSubmitHook } from "./codex-hook.js";
|
|
13
|
+
import { claimJevOnBanner, formatJevHookOutput, jevSwitchState, runJevSkillHint, withJevBanner, } from "./jev-hint.js";
|
|
11
14
|
import { evaluatePlanPersistence, formatStopBlockOutput, recordLitPlanActivation } from "./plan-persistence.js";
|
|
12
15
|
/** Hard cap on stdin to bound memory / ReDoS exposure inside the 5 s Codex hook budget. 8 MB. */
|
|
13
16
|
export const MAX_STDIN_BYTES = 8_000_000;
|
|
@@ -66,7 +69,7 @@ function readStdin(stdin) {
|
|
|
66
69
|
* NEVER throws. Writes the camelCase activation line to stdout (empty on no-op), or a LitHookError
|
|
67
70
|
* line to stderr on malformed / oversized stdin.
|
|
68
71
|
*/
|
|
69
|
-
export async function runUserPromptSubmitHookCli(stdin, stdout, stderr, repoRoot = process.cwd()) {
|
|
72
|
+
export async function runUserPromptSubmitHookCli(stdin, stdout, stderr, repoRoot = process.cwd(), jev = {}) {
|
|
70
73
|
const decoded = await readStdin(stdin);
|
|
71
74
|
if (decoded === null) {
|
|
72
75
|
stderr.write(errorLine("LIT_HOOK_STDIN_TOO_LARGE", TOO_LARGE_MESSAGE));
|
|
@@ -94,10 +97,39 @@ export async function runUserPromptSubmitHookCli(stdin, stdout, stderr, repoRoot
|
|
|
94
97
|
if (scope !== null)
|
|
95
98
|
recordLitPlanActivation(scope.cwd, scope.sessionId);
|
|
96
99
|
}
|
|
97
|
-
if (decision.kind === "inject")
|
|
100
|
+
if (decision.kind === "inject") {
|
|
98
101
|
stdout.write(decision.stdout);
|
|
102
|
+
return 0;
|
|
103
|
+
}
|
|
104
|
+
const hint = await jevHintOutput(parsed, repoRoot, jev);
|
|
105
|
+
if (hint !== "")
|
|
106
|
+
stdout.write(hint);
|
|
99
107
|
return 0;
|
|
100
108
|
}
|
|
109
|
+
/** Optional Jev skill hint for a turn the deterministic router left alone. Never throws. */
|
|
110
|
+
async function jevHintOutput(parsed, repoRoot, options) {
|
|
111
|
+
const env = options.env ?? process.env;
|
|
112
|
+
if (jevSwitchState(env) === "off" || !isLitUserPromptSubmitInput(parsed))
|
|
113
|
+
return "";
|
|
114
|
+
const record = parsed;
|
|
115
|
+
const sessionId = typeof record["session_id"] === "string" ? record["session_id"] : null;
|
|
116
|
+
const cwd = typeof record["cwd"] === "string" && isAbsolute(record["cwd"]) ? record["cwd"] : repoRoot;
|
|
117
|
+
try {
|
|
118
|
+
const banner = claimJevOnBanner(cwd, sessionId, env);
|
|
119
|
+
const result = await runJevSkillHint({
|
|
120
|
+
prompt: parsed.prompt,
|
|
121
|
+
sessionId,
|
|
122
|
+
repoRoot: cwd,
|
|
123
|
+
env,
|
|
124
|
+
...(options.http === undefined ? {} : { http: options.http }),
|
|
125
|
+
...(options.skillsRoot === undefined ? {} : { skillsRoot: options.skillsRoot }),
|
|
126
|
+
});
|
|
127
|
+
return formatJevHookOutput(withJevBanner(result, banner));
|
|
128
|
+
}
|
|
129
|
+
catch {
|
|
130
|
+
return "";
|
|
131
|
+
}
|
|
132
|
+
}
|
|
101
133
|
/** Read `{ session_id, cwd }` from a hook event; `cwd` falls back to `repoRoot` when absent or relative. */
|
|
102
134
|
function hookSessionScope(parsed, repoRoot) {
|
|
103
135
|
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed))
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
export declare const JEV_FLAG_ENV = "LITCODEX_JEV";
|
|
2
|
+
export declare const JEV_KEY_ENV = "TYPESAFE_API_KEY";
|
|
3
|
+
export declare const JEV_ENDPOINT = "https://api.typesafe.ai/v1/systemone";
|
|
4
|
+
export declare const JEV_DEFAULT_MODEL = "jev-1.13.0";
|
|
5
|
+
export declare const JEV_DEFAULT_TIMEOUT_MS = 1500;
|
|
6
|
+
export declare const JEV_MAX_TIMEOUT_MS = 3000;
|
|
7
|
+
export declare const JEV_DEFAULT_MAX_CALLS = 200;
|
|
8
|
+
export declare const JEV_DEFAULT_MIN_CONFIDENCE = 0.35;
|
|
9
|
+
export declare const JEV_MAX_PROMPT_CHARS = 2000;
|
|
10
|
+
export declare const JEV_REDACTION_WINDOW_CHARS = 8000;
|
|
11
|
+
export declare const JEV_MAX_DESCRIPTION_CHARS = 300;
|
|
12
|
+
export declare const JEV_MAX_BODY_BYTES: number;
|
|
13
|
+
export declare const JEV_STATE_DIR = ".litcodex/jev";
|
|
14
|
+
export type JevSwitchState = "off" | "on" | "flag on but TYPESAFE_API_KEY missing";
|
|
15
|
+
/** The doctor/status state. Never reveals the key or its length. */
|
|
16
|
+
export declare function jevSwitchState(env: NodeJS.ProcessEnv): JevSwitchState;
|
|
17
|
+
/**
|
|
18
|
+
* Redact an 8,000-character window (home paths, e-mail addresses, the literal key and token-shaped
|
|
19
|
+
* strings, in that order), then cut to 2,000 characters. A run of 8 or more token characters left at
|
|
20
|
+
* the cut is part of something the cut split, so it becomes `[secret]` too.
|
|
21
|
+
*/
|
|
22
|
+
export declare function redactJevPrompt(prompt: string, key?: string): string;
|
|
23
|
+
export interface JevCatalogEntry {
|
|
24
|
+
readonly id: string;
|
|
25
|
+
readonly description: string;
|
|
26
|
+
}
|
|
27
|
+
/** The installed plugin's `skills/` directory, resolved the same way the mode router finds bodies. */
|
|
28
|
+
export declare function defaultJevSkillsRoot(): string;
|
|
29
|
+
/**
|
|
30
|
+
* This plugin's own skills that the host may load on the model's initiative: every `skills/<id>/SKILL.md`
|
|
31
|
+
* whose frontmatter `name` equals its directory, minus skills whose `agents/openai.yaml` sets
|
|
32
|
+
* `allow_implicit_invocation: false` (those run only on an explicit user invocation).
|
|
33
|
+
*/
|
|
34
|
+
export declare function loadJevCatalog(skillsRoot?: string): JevCatalogEntry[];
|
|
35
|
+
export type JevSkipReason = "slash-command" | "skill-mention" | "routed" | "too-short";
|
|
36
|
+
/** Why this turn gets no Jev request, or null when it is eligible. Pure. */
|
|
37
|
+
export declare function jevSkipReason(prompt: string, catalogIds?: ReadonlySet<string>): JevSkipReason | null;
|
|
38
|
+
export interface JevRequestBody {
|
|
39
|
+
readonly model: string;
|
|
40
|
+
readonly state: string;
|
|
41
|
+
readonly questions: {
|
|
42
|
+
readonly which: {
|
|
43
|
+
readonly type: "choice";
|
|
44
|
+
readonly instructions: string;
|
|
45
|
+
readonly criteria: Readonly<Record<string, string>>;
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
export declare function buildJevRequestBody(model: string, state: string, catalog: readonly JevCatalogEntry[]): JevRequestBody;
|
|
50
|
+
export type JevVerdict = {
|
|
51
|
+
readonly kind: "hint";
|
|
52
|
+
readonly skillId: string;
|
|
53
|
+
readonly confidence: number;
|
|
54
|
+
} | {
|
|
55
|
+
readonly kind: "none";
|
|
56
|
+
readonly confidence: number;
|
|
57
|
+
} | {
|
|
58
|
+
readonly kind: "low-confidence";
|
|
59
|
+
readonly choice: string;
|
|
60
|
+
readonly confidence: number;
|
|
61
|
+
} | {
|
|
62
|
+
readonly kind: "rejected";
|
|
63
|
+
};
|
|
64
|
+
/** Validate an already-parsed response against the ids that were sent. Nothing else is trusted. */
|
|
65
|
+
export declare function judgeJevResponse(parsed: unknown, catalogIds: ReadonlySet<string>, minConfidence: number): JevVerdict;
|
|
66
|
+
export declare function jevHintLine(skillId: string): string;
|
|
67
|
+
/** The opt-in (`LITCODEX_JEV_SHOW=1`) visible line for a hinted turn: skill id and latency only. */
|
|
68
|
+
export declare function jevShowLine(skillId: string, latencyMs: number): string;
|
|
69
|
+
/** Once-per-session awareness banner. Plain text: Codex renders hook systemMessage control characters literally. */
|
|
70
|
+
export declare const JEV_ON_BANNER = "\u2726 Jev skill hint ON";
|
|
71
|
+
export declare function jevFallbackNote(reason: string): string;
|
|
72
|
+
export interface JevHttpRequest {
|
|
73
|
+
readonly method: "POST";
|
|
74
|
+
readonly headers: Readonly<Record<string, string>>;
|
|
75
|
+
readonly body: string;
|
|
76
|
+
readonly signal: AbortSignal;
|
|
77
|
+
}
|
|
78
|
+
export interface JevHttpResponse {
|
|
79
|
+
readonly status: number;
|
|
80
|
+
text(): Promise<string>;
|
|
81
|
+
}
|
|
82
|
+
/** Injected in tests; the default uses the runtime's built-in `fetch`. */
|
|
83
|
+
export type JevHttpClient = (url: string, request: JevHttpRequest) => Promise<JevHttpResponse>;
|
|
84
|
+
export declare const fetchJevHttpClient: JevHttpClient;
|
|
85
|
+
export interface JevHintInput {
|
|
86
|
+
readonly prompt: string;
|
|
87
|
+
readonly sessionId: string | null;
|
|
88
|
+
readonly repoRoot: string;
|
|
89
|
+
readonly env: NodeJS.ProcessEnv;
|
|
90
|
+
readonly http?: JevHttpClient;
|
|
91
|
+
readonly skillsRoot?: string;
|
|
92
|
+
readonly now?: () => number;
|
|
93
|
+
}
|
|
94
|
+
/** A hint sets `additionalContext`, plus `systemMessage` only with `LITCODEX_JEV_SHOW=1`; a note sets `systemMessage`. */
|
|
95
|
+
export interface JevHintResult {
|
|
96
|
+
readonly additionalContext?: string;
|
|
97
|
+
readonly systemMessage?: string;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Decide the optional hint for one UserPromptSubmit turn. Never throws; every failure resolves to at
|
|
101
|
+
* most one visible fallback note per session and otherwise to nothing.
|
|
102
|
+
*/
|
|
103
|
+
export declare function runJevSkillHint(input: JevHintInput): Promise<JevHintResult>;
|
|
104
|
+
/**
|
|
105
|
+
* The once-per-session banner, or null. Only when the hint is fully on (flag and key); it is claimed in
|
|
106
|
+
* the session state before it is shown, so a state write failure shows nothing rather than repeating.
|
|
107
|
+
*/
|
|
108
|
+
export declare function claimJevOnBanner(repoRoot: string, sessionId: string | null, env: NodeJS.ProcessEnv): string | null;
|
|
109
|
+
/** Put the banner (when claimed) on its own line ahead of any other visible Jev line. */
|
|
110
|
+
export declare function withJevBanner(result: JevHintResult, banner: string | null): JevHintResult;
|
|
111
|
+
/** Codex UserPromptSubmit output for a hint and/or visible line; "" when there is nothing to say. */
|
|
112
|
+
export declare function formatJevHookOutput(result: JevHintResult): string;
|