@r_masseater/masseater-utils 0.10.2 → 0.11.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/plugin-kit.d.mts +7 -1
- package/dist/plugin-kit.mjs +31 -1
- package/dist/plugin-kit.mjs.map +1 -1
- package/package.json +1 -1
- package/skills/add-scroll-chip-row/SKILL.md +9 -5
- package/skills/assert-exported-telemetry/SKILL.md +9 -5
- package/skills/build-tauri-app/SKILL.md +9 -5
- package/skills/find-cache-folder/SKILL.md +7 -4
- package/skills/import-custom-format/SKILL.md +10 -6
- package/skills/name-stack-resources/SKILL.md +8 -5
- package/skills/read-hook-input/SKILL.md +8 -4
- package/skills/read-node-ecosystem/SKILL.md +13 -9
- package/skills/run-effect-main/SKILL.md +9 -6
- package/skills/share-types-with-rust/SKILL.md +18 -14
- package/skills/trace-workers/SKILL.md +14 -11
- package/skills/use-model-server/SKILL.md +9 -5
- package/skills/write-actions-steps/SKILL.md +10 -6
package/dist/plugin-kit.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Effect, FileSystem, Path, Schema } from "effect";
|
|
1
|
+
import { Effect, FileSystem, Option, Path, Schema } from "effect";
|
|
2
2
|
import { Option as Option$1 } from "effect/Option";
|
|
3
3
|
import { a as readHookInput, i as blockHook, n as runHookWith, o as writeHookOutput, r as HookBlocked, s as Platform, t as runHook } from "./index-CgNig8WC.mjs";
|
|
4
4
|
declare const CacheRootError_base: Schema.Class<CacheRootError, Schema.TaggedStruct<"CacheRootError", {
|
|
@@ -77,6 +77,12 @@ declare const HistoryTooLarge_base: Schema.Class<HistoryTooLarge, Schema.TaggedS
|
|
|
77
77
|
}>;
|
|
78
78
|
export declare class HistoryTooLarge extends HistoryTooLarge_base {}
|
|
79
79
|
export declare const fitState: (messages: readonly Message[], calls: readonly ToolCall[], options: FitOptions) => Effect.Effect<FittedState, HistoryTooLarge>;
|
|
80
|
+
export declare const ownerCommand: (prompt: string, commands: readonly string[]) => Option.Option<string>;
|
|
81
|
+
export declare const ownerSwitch: (prompt: string, commands: readonly string[]) => Option.Option<boolean>;
|
|
82
|
+
/** @internal */
|
|
83
|
+
export declare const switchSession: (directory: string, session: string, on: boolean) => Effect.Effect<void, import("effect/PlatformError").PlatformError, FileSystem.FileSystem | Path.Path>;
|
|
84
|
+
/** @internal */
|
|
85
|
+
export declare const sessionSwitchedOn: (directory: string, session: string) => Effect.Effect<boolean, never, FileSystem.FileSystem | Path.Path>;
|
|
80
86
|
interface InstalledPlugin {
|
|
81
87
|
readonly id: string;
|
|
82
88
|
readonly installPath: string;
|
package/dist/plugin-kit.mjs
CHANGED
|
@@ -316,6 +316,36 @@ const fitState = (messages, calls, options) => {
|
|
|
316
316
|
onFailure: (last) => Effect.fail(HistoryTooLarge.make({ reason: `history too large for Jev (~${String(last.tokens)} tokens after truncation, limit ${String(options.maxStateTokens)})` }))
|
|
317
317
|
});
|
|
318
318
|
};
|
|
319
|
+
// src/shared/lib/owner-command.ts
|
|
320
|
+
const OWNER_BODIES = [/<message\b[^>]*\bfrom="human"[^>]*\btrust="principal"[^>]*>(?<body>[\s\S]*?)<\/message>/gu, /<cited\b[^>]*\bauthor="user"[^>]*>(?<body>[\s\S]*?)<\/cited>/gu];
|
|
321
|
+
const bodiesOf = (prompt) => pipe(OWNER_BODIES, Array.flatMap((pattern) => Array.fromIterable(pipe(prompt, String$1.matchAll(pattern)))), Array.map((found) => pipe(Option.fromUndefinedOr(found.groups), Option.flatMap((groups) => Option.fromUndefinedOr(groups["body"])))), Array.getSomes);
|
|
322
|
+
const argumentsAfter = (text) => (command) => pipe(Option.some(String$1.trimStart(text)), Option.filter(String$1.startsWith(command)), Option.map((typed) => String$1.slice(command.length)(typed)), Option.filter((rest) => String$1.isEmpty(rest) || /^\s/u.test(rest)), Option.map(String$1.trim));
|
|
323
|
+
const typedIn = (commands) => (text) => Array.findFirst(commands, argumentsAfter(text));
|
|
324
|
+
const ownerBody = (commands) => (prompt) => pipe(bodiesOf(prompt), Array.map(typedIn(commands)), Array.getSomes, Array.last);
|
|
325
|
+
const ownerCommand = (prompt, commands) => Option.orElse(typedIn(commands)(prompt), () => ownerBody(commands)(prompt));
|
|
326
|
+
// src/shared/lib/session-switch.ts
|
|
327
|
+
const OFF = "disable";
|
|
328
|
+
const turnsOn = (args) => !pipe(String$1.split(args, /\s+/u), Array.head, Option.exists((word) => word === OFF));
|
|
329
|
+
const ownerSwitch = (prompt, commands) => Option.map(ownerCommand(prompt, commands), turnsOn);
|
|
330
|
+
const markerOf = Effect.fn("markerOf")(function* markerOf(directory, session) {
|
|
331
|
+
const path = yield* Path.Path;
|
|
332
|
+
return path.join(directory, path.basename(session));
|
|
333
|
+
});
|
|
334
|
+
/** @internal */
|
|
335
|
+
const switchSession = Effect.fn("switchSession")(function* switchSession(directory, session, on) {
|
|
336
|
+
const fs = yield* FileSystem.FileSystem;
|
|
337
|
+
const marker = yield* markerOf(directory, session);
|
|
338
|
+
if (!on) return yield* fs.remove(marker, { force: true });
|
|
339
|
+
yield* fs.makeDirectory(directory, { recursive: true });
|
|
340
|
+
return yield* fs.writeFileString(marker, "");
|
|
341
|
+
});
|
|
342
|
+
/** @internal */
|
|
343
|
+
const sessionSwitchedOn = Effect.fn("sessionSwitchedOn")(function* sessionSwitchedOn(directory, session) {
|
|
344
|
+
const fs = yield* FileSystem.FileSystem;
|
|
345
|
+
if (String$1.isEmpty(session)) return false;
|
|
346
|
+
const marker = yield* markerOf(directory, session);
|
|
347
|
+
return yield* fs.exists(marker).pipe(Effect.orElseSucceed(() => false));
|
|
348
|
+
});
|
|
319
349
|
// src/shared/lib/installed-plugins.ts
|
|
320
350
|
const InstalledEntry = Schema.Struct({
|
|
321
351
|
installPath: Schema.String,
|
|
@@ -375,6 +405,6 @@ const stateFor = (backend, state) => {
|
|
|
375
405
|
if (!backend.textState) return state;
|
|
376
406
|
return pipe(Record.toEntries(state), Array.map(sectionOf), Array.join("\n\n"));
|
|
377
407
|
};
|
|
378
|
-
export { CACHE_DIRECTORY_NAME, CacheRootError, HistoryTooLarge, HookBlocked, blockHook, cacheRootEffect, cacheRootOf, collectToolCalls, estimateTokens, fitState, installedPlugins, isRecord, jevBackend, parseJson, placeOf, readHookInput, runHook, runHookWith, stateFor, writeHookOutput };
|
|
408
|
+
export { CACHE_DIRECTORY_NAME, CacheRootError, HistoryTooLarge, HookBlocked, blockHook, cacheRootEffect, cacheRootOf, collectToolCalls, estimateTokens, fitState, installedPlugins, isRecord, jevBackend, ownerCommand, ownerSwitch, parseJson, placeOf, readHookInput, runHook, runHookWith, sessionSwitchedOn, stateFor, switchSession, writeHookOutput };
|
|
379
409
|
|
|
380
410
|
//# sourceMappingURL=plugin-kit.mjs.map
|
package/dist/plugin-kit.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin-kit.mjs","names":["taggedError","taggedError","Arr","RecordSchema","StringSchema","ONE","encodeJson","Str","Arr","Rec","ONE","Str","Arr","Num","ONE","Arr","Num","Str","Arr","Rec","Arr","Str","Rec","Arr"],"sources":["../src/features/run-main/model/hook-io.ts","../src/features/run-main/model/run-hook.ts","../src/shared/lib/cache.ts","../src/shared/lib/record.ts","../src/features/fit-history/model/calls.ts","../src/shared/lib/tokens.ts","../src/features/fit-history/model/fitting.ts","../src/features/fit-history/model/state.ts","../src/shared/lib/installed-plugins.ts","../src/shared/lib/jev-backend.ts"],"sourcesContent":["import { Effect, Runtime, Schema, Stdio, Stream } from \"effect\";\n\nconst EXIT_BLOCKING = 2;\n\nconst taggedError = Schema.TaggedError;\n\n/** @internal */\nexport class HookBlocked extends taggedError<HookBlocked, { readonly brand: unique symbol }>()(\n \"HookBlocked\",\n { reason: Schema.String },\n) {\n public override readonly [Runtime.errorExitCode] = EXIT_BLOCKING;\n public override readonly [Runtime.errorReported] = false;\n}\n\n/** @internal */\nexport const isHookBlocked = Schema.is(HookBlocked);\n\n/** @internal */\nexport const blockHook = (reason: string): Effect.Effect<never, HookBlocked> =>\n Effect.fail(HookBlocked.make({ reason }));\n\n/** @internal */\nexport const readStdin: Effect.Effect<string, never, Stdio.Stdio> = Effect.gen(\n function* readStdin() {\n const stdio = yield* Stdio.Stdio;\n return yield* stdio.stdin.pipe(Stream.decodeText, Stream.mkString, Effect.orDie);\n },\n);\n\n/** @internal */\nexport const readHookInput = <Codec extends Schema.Top>(\n schema: Codec,\n): Effect.Effect<Codec[\"Type\"], Schema.SchemaError, Stdio.Stdio | Codec[\"DecodingServices\"]> =>\n Effect.gen(function* read() {\n const text = yield* readStdin;\n const json = Schema.fromJsonString(schema);\n return yield* Schema.decodeEffect(json)(text);\n });\n\n/** @internal */\nexport const writeStdout = (text: string): Effect.Effect<void, never, Stdio.Stdio> =>\n Effect.gen(function* toStdout() {\n const stdio = yield* Stdio.Stdio;\n yield* Stream.make(text).pipe(Stream.run(stdio.stdout()), Effect.orDie);\n });\n\n/** @internal */\nexport const writeStderr = (text: string): Effect.Effect<void, never, Stdio.Stdio> =>\n Effect.gen(function* toStderr() {\n const stdio = yield* Stdio.Stdio;\n yield* Stream.make(text).pipe(Stream.run(stdio.stderr()), Effect.orDie);\n });\n\n/** @internal */\nexport const writeHookOutput =\n <Codec extends Schema.Top>(schema: Codec) =>\n (value: Codec[\"Type\"]): Effect.Effect<void, never, Stdio.Stdio | Codec[\"EncodingServices\"]> =>\n Schema.encodeEffect(Schema.fromJsonString(schema))(value).pipe(\n Effect.orDie,\n Effect.flatMap(writeStdout),\n );\n","import { Cause, Effect, Layer, Option } from \"effect\";\nimport type { Stdio } from \"effect\";\n\nimport { isHookBlocked, writeStderr } from \"./hook-io.ts\";\nimport type { HookBlocked } from \"./hook-io.ts\";\nimport { runMainWith } from \"./run-main.ts\";\nimport type { Platform, Run } from \"./run-main.ts\";\n\nconst blockedIn = <Failure>(cause: Cause.Cause<Failure>): Option.Option<HookBlocked> =>\n Cause.findErrorOption(cause).pipe(\n Option.filter((error): error is Failure & HookBlocked => isHookBlocked(error)),\n );\n\nconst reportBlocked = <Failure>(\n cause: Cause.Cause<Failure>,\n): Effect.Effect<void, never, Stdio.Stdio> =>\n Option.match(blockedIn(cause), {\n onNone: () => Effect.void,\n onSome: (blocked) => writeStderr(`${blocked.reason}\\n`),\n });\n\n/** @internal */\nexport const runHookWith =\n <Provided, LayerFailure>({\n serviceName,\n services,\n }: Readonly<{\n serviceName: string;\n services: Layer.Layer<Provided, LayerFailure, Platform>;\n }>): Run<Provided> =>\n (program) => {\n runMainWith({ serviceName, services })(program.pipe(Effect.tapCause(reportBlocked)));\n };\n\n/** @internal */\nexport const runHook = (serviceName: string): Run<never> =>\n runHookWith({ serviceName, services: Layer.empty });\n","import { Array as Arr, Config, Effect, Option, Schema, pipe } from \"effect\";\n\nconst taggedError = Schema.TaggedError;\n\nexport class CacheRootError extends taggedError<\n CacheRootError,\n { readonly brand: unique symbol }\n>()(\"CacheRootError\", { message: Schema.String }) {}\n\nconst SEPARATOR = \"/\";\nexport const CACHE_DIRECTORY_NAME = \".cache\";\n\nconst variable = (name: string): Effect.Effect<Option.Option<string>> =>\n Config.option(Config.NonEmptyString(name)).pipe(Effect.orElseSucceed(Option.none));\n\nconst baseDirectory: Effect.Effect<Option.Option<string>> = Effect.gen(function* baseDirectory() {\n const cacheHome = yield* variable(\"XDG_CACHE_HOME\");\n const home = yield* variable(\"HOME\");\n const profile = yield* variable(\"USERPROFILE\");\n return pipe(\n cacheHome,\n Option.orElse(() =>\n pipe(\n Option.orElse(home, () => profile),\n Option.map((directory) => `${directory}${SEPARATOR}${CACHE_DIRECTORY_NAME}`),\n ),\n ),\n );\n});\n\nexport const cacheRootEffect = (\n segments: readonly string[],\n): Effect.Effect<string, CacheRootError> =>\n baseDirectory.pipe(\n Effect.flatMap(\n Option.match({\n onNone: () => Effect.fail(CacheRootError.make({ message: \"set XDG_CACHE_HOME or HOME\" })),\n onSome: (base) => Effect.succeed(pipe([base, ...segments], Arr.join(SEPARATOR))),\n }),\n ),\n );\n\nexport const cacheRootOf = (segments: readonly string[]): Promise<string> =>\n Effect.runPromise(cacheRootEffect(segments));\n","import type { Option } from \"effect/Option\";\nimport {\n Record as RecordSchema,\n String as StringSchema,\n Unknown,\n decodeOption,\n fromJsonString,\n is,\n} from \"effect/Schema\";\n\nexport const isRecord = is(RecordSchema(StringSchema, Unknown));\n\nexport const parseJson = (text: string): Option<unknown> =>\n decodeOption(fromJsonString(Unknown))(text);\n","import { Array as Arr, Option, Record as Rec, Schema, String as Str, pipe } from \"effect\";\n\nimport type { HistoryEntry, HistoryToolCall, Message, ToolCall } from \"./types.ts\";\n\nconst FIRST = 0;\nconst ONE = 1;\nconst ELLIPSIS = \"…\";\nconst VALUE_CHARS = 200;\nconst COMPACT_INPUT_CHARS = 60;\nconst SPACES = /\\s+/gu;\nconst encodeJson = Schema.encodeOption(Schema.fromJsonString(Schema.Unknown));\n\nexport const jsonOf = (value: unknown): Option.Option<string> => encodeJson(value);\n\nexport const truncate = (text: string, limit: number): string => {\n if (Str.length(text) <= limit) {\n return text;\n }\n return `${Str.slice(FIRST, Math.max(FIRST, limit - ONE))(text)}${ELLIPSIS}`;\n};\n\nexport const isPinned = (index: number, total: number, preserveRecentMessages: number): boolean =>\n index === FIRST || index >= total - preserveRecentMessages;\n\ninterface Found {\n readonly index: number;\n readonly chars: number;\n readonly isError: boolean;\n}\n\nconst resultsOf = (messages: readonly Message[]): ReadonlyMap<string, Found> =>\n new Map(\n pipe(\n messages,\n Arr.flatMap((message, index) =>\n pipe(\n message.toolResults,\n Arr.map(\n (result) =>\n [\n result.tool_use_id,\n { index, chars: Str.length(result.text), isError: result.isError },\n ] as const,\n ),\n ),\n ),\n ),\n );\n\nexport const collectToolCalls = (\n messages: readonly Message[],\n preserveRecentMessages: number,\n): readonly ToolCall[] => {\n const results = resultsOf(messages);\n const pinned = (index: number): boolean =>\n isPinned(index, messages.length, preserveRecentMessages);\n return pipe(\n messages,\n Arr.flatMap((message, callIndex) =>\n pipe(\n message.toolUses,\n Arr.flatMap((tool) =>\n pipe(\n Option.fromUndefinedOr(results.get(tool.tool_use_id)),\n Option.map((found) => ({ tool, callIndex, found })),\n Option.toArray,\n ),\n ),\n ),\n ),\n Arr.map(({ tool, callIndex, found }, index) => ({\n id: `t${String(index + ONE)}`,\n tool_use_id: tool.tool_use_id,\n tool: tool.tool,\n input: tool.input,\n callIndex,\n resultIndex: found.index,\n resultChars: found.chars,\n isError: found.isError,\n pinned: pinned(callIndex) || pinned(found.index),\n })),\n );\n};\n\nexport const inputText = (input: Readonly<Record<string, unknown>>, limit: number): string =>\n truncate(\n Option.getOrElse(jsonOf(input), () => \"[unserializable input]\"),\n limit,\n );\n\nconst outcomeOf = (call: ToolCall): string => {\n if (call.isError) {\n return \"error\";\n }\n return \"ok\";\n};\n\nconst resultNote = (call: ToolCall): string =>\n `${outcomeOf(call)}, ${String(call.resultChars)} chars (omitted)`;\n\nconst valueText = ([key, value]: readonly [string, unknown]): string => {\n const text = pipe(\n Option.liftPredicate(value, (raw): raw is string => typeof raw === \"string\"),\n Option.getOrElse(() => inputText({ [key]: value }, VALUE_CHARS)),\n );\n return `${key}=${Str.replaceAll(SPACES, \" \")(text)}`;\n};\n\nexport const compactCall = (call: ToolCall): string => {\n const input = pipe(Rec.toEntries(call.input), Arr.map(valueText), Arr.join(\" \"));\n return `${call.id} ${call.tool} ${truncate(input, COMPACT_INPUT_CHARS)} → ${outcomeOf(call)} ${String(call.resultChars)}ch`;\n};\n\nexport const callsByMessage = (\n calls: readonly ToolCall[],\n): ReadonlyMap<number, readonly ToolCall[]> =>\n new Map(\n pipe(\n calls,\n Arr.groupBy((call) => String(call.callIndex)),\n Rec.toEntries,\n Arr.map(([index, own]) => [Number(index), own] as const),\n ),\n );\n\nconst historyCallOf =\n (inputChars: number) =>\n (call: ToolCall): HistoryToolCall => ({\n id: call.id,\n tool: call.tool,\n input: inputText(call.input, inputChars),\n result: resultNote(call),\n });\n\nexport const historyEntries = (\n messages: readonly Message[],\n calls: readonly ToolCall[],\n inputChars: number,\n): readonly HistoryEntry[] => {\n const byMessage = callsByMessage(calls);\n return pipe(\n messages,\n Arr.flatMap((message, index): readonly HistoryEntry[] => {\n const own = Option.getOrElse(Option.fromUndefinedOr(byMessage.get(index)), () => []);\n const toolCalls = pipe(own, Arr.map(historyCallOf(inputChars)));\n const entry = { index, role: message.role, text: message.text };\n if (Arr.isReadonlyArrayNonEmpty(toolCalls)) {\n return [{ ...entry, tool_calls: toolCalls }];\n }\n if (Str.isEmpty(Str.trim(message.text))) {\n return [];\n }\n return [entry];\n }),\n );\n};\n","import { Array as Arr, Number as Num, Option, String as Str, pipe } from \"effect\";\n\nconst PIECES = /(?<alpha>[A-Za-z]+)|(?<digits>\\d+)|(?<other>[^\\sA-Za-z\\d])/gu;\nconst DIGITS_PER_TOKEN = 2;\nconst LETTERS_PER_TOKEN = 6;\nconst SYMBOL_TOKENS = 0.9;\nconst ONE = 1;\n\nconst groupOf = (match: RegExpMatchArray, key: string): Option.Option<string> =>\n pipe(\n Option.fromUndefinedOr(match.groups),\n Option.flatMap((groups) => Option.fromUndefinedOr(groups[key])),\n );\n\nconst pieceTokens = (match: RegExpMatchArray): number =>\n pipe(\n groupOf(match, \"digits\"),\n Option.map((digits) => Str.length(digits) / DIGITS_PER_TOKEN),\n Option.orElse(() =>\n Option.map(\n groupOf(match, \"alpha\"),\n (alpha) => ONE + Math.floor((Str.length(alpha) - ONE) / LETTERS_PER_TOKEN),\n ),\n ),\n Option.getOrElse(() => SYMBOL_TOKENS),\n );\n\nconst matchesOf = (pattern: RegExp, text: string): readonly RegExpMatchArray[] =>\n Arr.fromIterable(Str.matchAll(pattern)(text));\n\nexport const estimateTokens = (text: string): number => {\n const pieces = pipe(matchesOf(PIECES, text), Arr.map(pieceTokens));\n return Math.ceil(Num.sumAll(pieces));\n};\n","import { Array as Arr, Number as Num, Option, pipe } from \"effect\";\n\nimport { estimateTokens } from \"#/shared/lib/tokens.ts\";\n\nimport { isPinned, jsonOf } from \"./calls.ts\";\nimport type {\n CompactionState,\n FitOptions,\n FittedState,\n HistoryEntry,\n Message,\n ToolCall,\n} from \"./types.ts\";\n\nconst ONE = 1;\nconst NONE = 0;\n\nexport const entryTokens = (entry: HistoryEntry): number =>\n estimateTokens(Option.getOrElse(jsonOf(entry), () => \"\")) + ONE;\n\nexport interface Fitting {\n readonly history: readonly Option.Option<HistoryEntry>[];\n readonly perEntry: readonly number[];\n readonly tokens: number;\n}\n\nexport interface Plan {\n readonly messages: readonly Message[];\n readonly calls: readonly ToolCall[];\n readonly options: FitOptions;\n readonly stateOf: (history: readonly HistoryEntry[]) => CompactionState;\n readonly baseTokens: number;\n readonly byMessage: ReadonlyMap<number, readonly ToolCall[]>;\n}\n\nexport type Change = (entry: HistoryEntry) => Option.Option<Option.Option<HistoryEntry>>;\n\nexport const fittingOf = (plan: Plan, history: readonly HistoryEntry[]): Fitting => {\n const perEntry = pipe(history, Arr.map(entryTokens));\n return {\n history: pipe(history, Arr.map(Option.some)),\n perEntry,\n tokens: plan.baseTokens + Num.sumAll(perEntry),\n };\n};\n\nexport const kept = (fitting: Fitting): readonly HistoryEntry[] => Arr.getSomes(fitting.history);\n\nexport const fits = (plan: Plan, fitting: Fitting): boolean =>\n fitting.tokens <= plan.options.maxStateTokens;\n\nexport const fitted = (plan: Plan, fitting: Fitting, stage: string): FittedState => ({\n state: plan.stateOf(kept(fitting)),\n tokens: fitting.tokens,\n stage,\n});\n\nexport const pinnedEntry = (plan: Plan, entry: HistoryEntry): boolean =>\n isPinned(entry.index, plan.messages.length, plan.options.preserveRecentMessages);\n\nconst orderOf = (plan: Plan, fitting: Fitting): readonly number[] => {\n const present = pipe(\n fitting.history,\n Arr.flatMap((entry, index) =>\n pipe(\n entry,\n Option.map((value) => [index, pinnedEntry(plan, value)] as const),\n Option.toArray,\n ),\n ),\n );\n const loose = pipe(\n present,\n Arr.filter(([, pinned]) => !pinned),\n );\n const pinned = pipe(\n present,\n Arr.filter(([, isPinnedEntry]) => isPinnedEntry),\n );\n return pipe(\n [...loose, ...pinned],\n Arr.map(([index]) => index),\n );\n};\n\ninterface Step {\n readonly index: number;\n readonly entry: Option.Option<HistoryEntry>;\n readonly tokens: number;\n}\n\nconst stepOf =\n (fitting: Fitting, change: Change) =>\n (index: number): Option.Option<Step> =>\n pipe(\n Option.flatten(Option.fromUndefinedOr(fitting.history[index])),\n Option.flatMap(change),\n Option.map((entry) => ({\n index,\n entry,\n tokens: Option.match(entry, { onNone: () => NONE, onSome: entryTokens }),\n })),\n );\n\nconst applied = (fitting: Fitting, steps: readonly Step[]): Fitting => {\n const byIndex = new Map(\n pipe(\n steps,\n Arr.map((step) => [step.index, step] as const),\n ),\n );\n const pick = <Value>(index: number, value: Value, of: (step: Step) => Value): Value =>\n Option.match(Option.fromUndefinedOr(byIndex.get(index)), { onNone: () => value, onSome: of });\n const history = pipe(\n fitting.history,\n Arr.map((entry, index) => pick(index, entry, (step) => step.entry)),\n );\n const perEntry = pipe(\n fitting.perEntry,\n Arr.map((tokens, index) => pick(index, tokens, (step) => step.tokens)),\n );\n const delta = Num.sumAll(\n pipe(\n steps,\n Arr.map(\n (step) => step.tokens - Option.getOrElse(Arr.get(fitting.perEntry, step.index), () => NONE),\n ),\n ),\n );\n return { history, perEntry, tokens: fitting.tokens + delta };\n};\n\nexport const staged = (\n plan: Plan,\n fitting: Fitting,\n change: Change,\n): readonly [Fitting, boolean] => {\n const steps = pipe(\n orderOf(plan, fitting),\n Arr.flatMap((index) => Option.toArray(stepOf(fitting, change)(index))),\n );\n const totals = pipe(\n steps,\n Arr.scan(\n fitting.tokens,\n (tokens, step) =>\n tokens + step.tokens - Option.getOrElse(Arr.get(fitting.perEntry, step.index), () => NONE),\n ),\n Arr.drop(ONE),\n );\n return Option.match(\n Arr.findFirstIndex(totals, (tokens) => tokens <= plan.options.maxStateTokens),\n {\n onNone: () => [applied(fitting, steps), false] as const,\n onSome: (at) => [applied(fitting, Arr.take(steps, at + ONE)), true] as const,\n },\n );\n};\n","import {\n Array as Arr,\n Effect,\n Option,\n Predicate,\n Result,\n Schema,\n String as Str,\n pipe,\n} from \"effect\";\n\nimport { estimateTokens } from \"#/shared/lib/tokens.ts\";\n\nimport { callsByMessage, compactCall, historyEntries, jsonOf, truncate } from \"./calls.ts\";\nimport { fits, fitted, fittingOf, kept, pinnedEntry, staged } from \"./fitting.ts\";\nimport type { Change, Fitting, Plan } from \"./fitting.ts\";\nimport type {\n CompactionState,\n FitOptions,\n FittedState,\n HistoryEntry,\n HistoryToolCall,\n Message,\n ToolCall,\n} from \"./types.ts\";\n\nexport const STATE_CONTEXT =\n \"A coding assistant conversation is being compacted to free context. `history` is the whole conversation so far, oldest first; tool outputs are replaced by a short `result` note and long texts may be abridged. Each question asks whether one tool call, or the full output of that call, still needs to stay in the history verbatim. Whatever is not kept is deleted permanently, but the assistant can always re-run a tool or re-read a file.\";\n\nconst taggedError = Schema.TaggedError;\n\nexport class HistoryTooLarge extends taggedError<\n HistoryTooLarge,\n { readonly brand: unique symbol }\n>()(\"HistoryTooLarge\", { reason: Schema.String }) {}\n\nconst FULL_INPUT_CHARS = 1000;\nconst SHORT_INPUT_CHARS = 200;\nconst SHORTEST_INPUT_CHARS = 60;\nconst SHORTER_INPUT_CHARS = [SHORT_INPUT_CHARS, SHORTEST_INPUT_CHARS] as const;\nconst TEXT_HEAD = 400;\nconst TEXT_TAIL = 150;\nconst ABRIDGE_MARGIN = 40;\nconst RECENT_GOALS = 3;\nconst GOAL_CHARS = 500;\nconst ONE = 1;\n\nconst abridge = (text: string): string => {\n const omitted = Str.length(text) - TEXT_HEAD - TEXT_TAIL;\n return `${Str.takeLeft(TEXT_HEAD)(text)}\\n[… ${String(omitted)} chars omitted …]\\n${Str.takeRight(TEXT_TAIL)(text)}`;\n};\n\nexport const goalFromMessages = (messages: readonly Message[]): string =>\n pipe(\n messages,\n Arr.filter(\n (message) =>\n message.role === \"user\" &&\n Str.isNonEmpty(Str.trim(message.text)) &&\n Arr.isReadonlyArrayEmpty(message.toolResults),\n ),\n Arr.takeRight(RECENT_GOALS),\n Arr.map((message) => truncate(message.text, GOAL_CHARS)),\n Arr.join(\"\\n\"),\n );\n\nconst abridgeText: Change = (entry: HistoryEntry) =>\n Option.liftPredicate(\n Option.some({ ...entry, text: abridge(entry.text) }),\n () => Str.length(entry.text) > TEXT_HEAD + TEXT_TAIL + ABRIDGE_MARGIN,\n );\n\nconst collapseText =\n (plan: Plan): Change =>\n (entry: HistoryEntry) => {\n const original = pipe(\n Arr.get(plan.messages, entry.index),\n Option.map((message) => Str.length(message.text)),\n Option.getOrElse(() => Str.length(entry.text)),\n );\n return Option.liftPredicate(\n Option.some({ ...entry, text: `[… ${String(original)} chars omitted …]` }),\n () => !pinnedEntry(plan, entry) && Str.isNonEmpty(entry.text),\n );\n };\n\nconst compactCalls =\n (plan: Plan): Change =>\n (entry: HistoryEntry) =>\n pipe(\n Option.fromUndefinedOr(plan.byMessage.get(entry.index)),\n Option.filter(() => !pinnedEntry(plan, entry)),\n Option.map((own) => Option.some({ ...entry, tool_calls: pipe(own, Arr.map(compactCall)) })),\n );\n\nconst leaveOut =\n (plan: Plan): Change =>\n (entry: HistoryEntry) =>\n Option.liftPredicate(\n Option.none<HistoryEntry>(),\n () => !pinnedEntry(plan, entry) && Predicate.isUndefined(entry.tool_calls),\n );\n\nconst callsOf = (entry: HistoryEntry): readonly (HistoryToolCall | string)[] =>\n Option.getOrElse(Option.fromUndefinedOr(entry.tool_calls), () => []);\n\nconst stringCalls = (entry: HistoryEntry): readonly string[] =>\n pipe(callsOf(entry), Arr.filter(Predicate.isString));\n\nconst foldable = (plan: Plan, entry: HistoryEntry): boolean =>\n !pinnedEntry(plan, entry) &&\n Str.isEmpty(entry.text) &&\n pipe(Arr.head(callsOf(entry)), Option.exists(Predicate.isString));\n\nconst mergedRun = (group: Arr.NonEmptyReadonlyArray<HistoryEntry>): HistoryEntry => {\n const first = Arr.headNonEmpty(group);\n if (group.length === ONE) {\n return first;\n }\n return { ...first, tool_calls: pipe(group, Arr.flatMap(stringCalls)) };\n};\n\nconst mergeRuns = (plan: Plan, history: readonly HistoryEntry[]): readonly HistoryEntry[] => {\n if (!Arr.isReadonlyArrayNonEmpty(history)) {\n return [];\n }\n return pipe(\n Arr.groupWith(\n history,\n (left, right) => foldable(plan, left) && foldable(plan, right) && left.role === right.role,\n ),\n Arr.map(mergedRun),\n );\n};\n\ntype Staged = readonly [Fitting, boolean];\n\ntype Stage = readonly [string, (fitting: Fitting) => Staged];\n\nconst rebuilt = (plan: Plan, inputChars: number) => (): readonly [Fitting, boolean] => {\n const fitting = fittingOf(plan, historyEntries(plan.messages, plan.calls, inputChars));\n return [fitting, fits(plan, fitting)];\n};\n\nconst stagesOf = (plan: Plan): readonly Stage[] => [\n ...pipe(\n SHORTER_INPUT_CHARS,\n Arr.map((limit): Stage => [`inputs<=${String(limit)}`, rebuilt(plan, limit)]),\n ),\n [\"texts abridged\", (fitting): Staged => staged(plan, fitting, abridgeText)],\n [\"old messages collapsed\", (fitting): Staged => staged(plan, fitting, collapseText(plan))],\n [\"old calls compacted\", (fitting): Staged => staged(plan, fitting, compactCalls(plan))],\n [\"old messages left out\", (fitting): Staged => staged(plan, fitting, leaveOut(plan))],\n [\n \"old calls merged\",\n (fitting): Staged => {\n const merged = fittingOf(plan, mergeRuns(plan, kept(fitting)));\n return [merged, fits(plan, merged)];\n },\n ],\n];\n\nconst throughStages = (\n plan: Plan,\n fitting: Fitting,\n stages: readonly Stage[],\n): Result.Result<FittedState, Fitting> =>\n Option.match(Arr.head(stages), {\n onNone: () => Result.fail(fitting),\n onSome: ([name, run]) => {\n const [next, done] = run(fitting);\n if (done) {\n return Result.succeed(fitted(plan, next, name));\n }\n return throughStages(plan, next, Arr.drop(stages, ONE));\n },\n });\n\nconst jsonText = (value: unknown): string => Option.getOrElse(jsonOf(value), () => \"\");\n\nconst planOf = (\n messages: readonly Message[],\n calls: readonly ToolCall[],\n options: FitOptions,\n): Plan => {\n const goal = pipe(\n Option.liftPredicate(options.goal, Str.isNonEmpty),\n Option.getOrElse(() => goalFromMessages(messages)),\n );\n const stateOf = (history: readonly HistoryEntry[]): CompactionState => ({\n context: STATE_CONTEXT,\n goal,\n history,\n });\n return {\n messages,\n calls,\n options,\n stateOf,\n baseTokens: estimateTokens(jsonText(stateOf([]))),\n byMessage: callsByMessage(calls),\n };\n};\n\nexport const fitState = (\n messages: readonly Message[],\n calls: readonly ToolCall[],\n options: FitOptions,\n): Effect.Effect<FittedState, HistoryTooLarge> => {\n const plan = planOf(messages, calls, options);\n const full = fittingOf(plan, historyEntries(messages, calls, FULL_INPUT_CHARS));\n if (fits(plan, full)) {\n return Effect.succeed(fitted(plan, full, \"full\"));\n }\n return Result.match(throughStages(plan, full, stagesOf(plan)), {\n onSuccess: Effect.succeed,\n onFailure: (last) =>\n Effect.fail(\n HistoryTooLarge.make({\n reason: `history too large for Jev (~${String(last.tokens)} tokens after truncation, limit ${String(options.maxStateTokens)})`,\n }),\n ),\n });\n};\n","import { Array as Arr, Effect, FileSystem, Path, Record as Rec, Schema, pipe } from \"effect\";\n\nconst InstalledEntry = Schema.Struct({\n installPath: Schema.String,\n version: Schema.Unknown,\n gitCommitSha: Schema.Unknown,\n});\nconst InstalledPlugins = Schema.Struct({\n plugins: Schema.Record(Schema.String, Schema.Array(InstalledEntry)),\n});\nconst decodeInstalled = Schema.decodeUnknownEffect(Schema.fromJsonString(InstalledPlugins));\n\nexport interface InstalledPlugin {\n readonly id: string;\n readonly installPath: string;\n readonly version: unknown;\n readonly sha: unknown;\n}\n\nconst flattened = (installed: typeof InstalledPlugins.Type): readonly InstalledPlugin[] =>\n pipe(\n Rec.toEntries(installed.plugins),\n Arr.flatMap(([id, entries]) =>\n pipe(\n entries,\n Arr.map((entry) => ({\n id,\n installPath: entry.installPath,\n version: entry.version,\n sha: entry.gitCommitSha,\n })),\n ),\n ),\n );\n\n/** @internal */\nexport const installedPlugins = Effect.fn(\"installedPlugins\")(function* installedPlugins(\n home: string,\n) {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const file = path.join(home, \".claude\", \"plugins\", \"installed_plugins.json\");\n return yield* fs.readFileString(file).pipe(\n Effect.flatMap(decodeInstalled),\n Effect.map(flattened),\n Effect.orElseSucceed((): readonly InstalledPlugin[] => []),\n );\n});\n","import {\n Array as Arr,\n Option,\n Predicate,\n Record as Rec,\n Schema,\n String as Str,\n pipe,\n} from \"effect\";\n\nexport type Place = \"ci\" | \"cloud\" | \"local\";\n\nexport interface Origin {\n readonly place: Place;\n readonly project: string;\n readonly hook: string;\n readonly sessionId: string;\n}\n\nexport interface JevSettings {\n readonly openRouterKey: string;\n readonly openRouterModel: string;\n readonly allowTraining: boolean;\n readonly attribution: Readonly<Record<string, string>>;\n}\n\nexport interface JevBackend {\n readonly apiKey: string;\n readonly baseURL: string;\n readonly model: string;\n readonly extra: Readonly<Record<string, unknown>>;\n readonly headers: Readonly<Record<string, string>>;\n readonly textState: boolean;\n}\n\nexport interface PlaceEnv {\n readonly githubActions: string;\n readonly remote: string;\n}\n\nexport type JevState = Readonly<Record<string, string>>;\n\nconst DEFAULT_OPENROUTER_MODEL = \"respan/span-01-lite\";\nconst TEXT_STATE_PREFIX = \"respan/\";\nconst encodeJson = Schema.encodeOption(Schema.fromJsonString(Schema.Unknown));\n\nexport const placeOf = (env: PlaceEnv): Place => {\n if (env.githubActions === \"true\") {\n return \"ci\";\n }\n if (env.remote === \"true\") {\n return \"cloud\";\n }\n return \"local\";\n};\n\nconst dataCollection = (allowTraining: boolean): string => {\n if (allowTraining) {\n return \"allow\";\n }\n return \"deny\";\n};\n\nexport const jevBackend = (settings: JevSettings, origin: Origin): JevBackend => {\n const model = pipe(\n Option.liftPredicate(settings.openRouterModel, Str.isNonEmpty),\n Option.getOrElse(() => DEFAULT_OPENROUTER_MODEL),\n );\n const session = pipe(\n Option.liftPredicate(origin.sessionId, Str.isNonEmpty),\n Option.match({ onNone: () => ({}), onSome: (id) => ({ session_id: id }) }),\n );\n return {\n apiKey: settings.openRouterKey,\n baseURL: \"https://openrouter.ai/api\",\n model,\n extra: {\n provider: { data_collection: dataCollection(settings.allowTraining) },\n user: `${origin.place}:${origin.project}:${origin.hook}`,\n ...session,\n },\n headers: settings.attribution,\n textState: Str.startsWith(TEXT_STATE_PREFIX)(model),\n };\n};\n\nconst sectionOf = ([key, value]: readonly [string, unknown]): string => {\n const text = pipe(\n Option.liftPredicate(value, Predicate.isString),\n Option.orElse(() => encodeJson(value)),\n Option.getOrElse(() => \"\"),\n );\n return `## ${key}\\n${text}`;\n};\n\nexport const stateFor = (backend: JevBackend, state: JevState): JevState | string => {\n if (!backend.textState) {\n return state;\n }\n return pipe(Rec.toEntries(state), Arr.map(sectionOf), Arr.join(\"\\n\\n\"));\n};\n"],"mappings":";;;;AAEA,MAAM,gBAAgB;AAEtB,MAAMA,gBAAc,OAAO;;AAG3B,IAAa,cAAb,cAAiCA,cAA4D,CAAC,CAC5F,eACA,EAAE,QAAQ,OAAO,OAAO,CAC1B,CAAC,CAAC;CACA,CAA0B,QAAQ,iBAAiB;CACnD,CAA0B,QAAQ,iBAAiB;AACrD;;AAGA,MAAa,gBAAgB,OAAO,GAAG,WAAW;;AAGlD,MAAa,aAAa,WACxB,OAAO,KAAK,YAAY,KAAK,EAAE,OAAO,CAAC,CAAC;;AAG1C,MAAa,YAAuD,OAAO,IACzE,UAAU,YAAY;CAEpB,OAAO,QAAO,OADO,MAAM,MAAA,CACP,MAAM,KAAK,OAAO,YAAY,OAAO,UAAU,OAAO,KAAK;AACjF,CACF;;AAGA,MAAa,iBACX,WAEA,OAAO,IAAI,UAAU,OAAO;CAC1B,MAAM,OAAO,OAAO;CACpB,MAAM,OAAO,OAAO,eAAe,MAAM;CACzC,OAAO,OAAO,OAAO,aAAa,IAAI,CAAC,CAAC,IAAI;AAC9C,CAAC;;AAGH,MAAa,eAAe,SAC1B,OAAO,IAAI,UAAU,WAAW;CAC9B,MAAM,QAAQ,OAAO,MAAM;CAC3B,OAAO,OAAO,KAAK,I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ET,OAAO;AACT;AAEA,MAAa,cAAc,UAAuB,WAA+B;CAC/E,MAAM,QAAQ,KACZ,OAAO,cAAc,SAAS,iBAAiBC,SAAI,UAAU,GAC7D,OAAO,gBAAgB,wBAAwB,CACjD;CACA,MAAM,UAAU,KACd,OAAO,cAAc,OAAO,WAAWA,SAAI,UAAU,GACrD,OAAO,MAAM;EAAE,eAAe,CAAC;EAAI,SAAS,QAAQ,EAAE,YAAY,GAAG;CAAG,CAAC,CAC3E;CACA,OAAO;EACL,QAAQ,SAAS;EACjB,SAAS;EACT;EACA,OAAO;GACL,UAAU,EAAE,iBAAiB,eAAe,SAAS,aAAa,EAAE;GACpE,MAAM,GAAG,OAAO,MAAM,GAAG,OAAO,QAAQ,GAAG,OAAO;GAClD,GAAG;EACL;EACA,SAAS,SAAS;EAClB,WAAWA,SAAI,WAAW,iBAAiB,CAAC,CAAC,KAAK;CACpD;AACF;AAEA,MAAM,aAAa,CAAC,KAAK,WAA+C;CAMtE,OAAO,MAAM,IAAI,IALJ,KACX,OAAO,cAAc,OAAO,UAAU,QAAQ,GAC9C,OAAO,aAAa,WAAW,KAAK,CAAC,GACrC,OAAO,gBAAgB,EAAE,CAEH;AAC1B;AAEA,MAAa,YAAY,SAAqB,UAAuC;CACnF,IAAI,CAAC,QAAQ,WACX,OAAO;CAET,OAAO,KAAKC,OAAI,UAAU,KAAK,GAAGC,MAAI,IAAI,SAAS,GAAGA,MAAI,KAAK,MAAM,CAAC;AACxE"}
|
|
1
|
+
{"version":3,"file":"plugin-kit.mjs","names":["taggedError","taggedError","Arr","RecordSchema","StringSchema","ONE","encodeJson","Str","Arr","Rec","ONE","Str","Arr","Num","ONE","Arr","Num","Str","Arr","Arr","Str","Str","Arr","Rec","Arr","Str","Rec","Arr"],"sources":["../src/features/run-main/model/hook-io.ts","../src/features/run-main/model/run-hook.ts","../src/shared/lib/cache.ts","../src/shared/lib/record.ts","../src/features/fit-history/model/calls.ts","../src/shared/lib/tokens.ts","../src/features/fit-history/model/fitting.ts","../src/features/fit-history/model/state.ts","../src/shared/lib/owner-command.ts","../src/shared/lib/session-switch.ts","../src/shared/lib/installed-plugins.ts","../src/shared/lib/jev-backend.ts"],"sourcesContent":["import { Effect, Runtime, Schema, Stdio, Stream } from \"effect\";\n\nconst EXIT_BLOCKING = 2;\n\nconst taggedError = Schema.TaggedError;\n\n/** @internal */\nexport class HookBlocked extends taggedError<HookBlocked, { readonly brand: unique symbol }>()(\n \"HookBlocked\",\n { reason: Schema.String },\n) {\n public override readonly [Runtime.errorExitCode] = EXIT_BLOCKING;\n public override readonly [Runtime.errorReported] = false;\n}\n\n/** @internal */\nexport const isHookBlocked = Schema.is(HookBlocked);\n\n/** @internal */\nexport const blockHook = (reason: string): Effect.Effect<never, HookBlocked> =>\n Effect.fail(HookBlocked.make({ reason }));\n\n/** @internal */\nexport const readStdin: Effect.Effect<string, never, Stdio.Stdio> = Effect.gen(\n function* readStdin() {\n const stdio = yield* Stdio.Stdio;\n return yield* stdio.stdin.pipe(Stream.decodeText, Stream.mkString, Effect.orDie);\n },\n);\n\n/** @internal */\nexport const readHookInput = <Codec extends Schema.Top>(\n schema: Codec,\n): Effect.Effect<Codec[\"Type\"], Schema.SchemaError, Stdio.Stdio | Codec[\"DecodingServices\"]> =>\n Effect.gen(function* read() {\n const text = yield* readStdin;\n const json = Schema.fromJsonString(schema);\n return yield* Schema.decodeEffect(json)(text);\n });\n\n/** @internal */\nexport const writeStdout = (text: string): Effect.Effect<void, never, Stdio.Stdio> =>\n Effect.gen(function* toStdout() {\n const stdio = yield* Stdio.Stdio;\n yield* Stream.make(text).pipe(Stream.run(stdio.stdout()), Effect.orDie);\n });\n\n/** @internal */\nexport const writeStderr = (text: string): Effect.Effect<void, never, Stdio.Stdio> =>\n Effect.gen(function* toStderr() {\n const stdio = yield* Stdio.Stdio;\n yield* Stream.make(text).pipe(Stream.run(stdio.stderr()), Effect.orDie);\n });\n\n/** @internal */\nexport const writeHookOutput =\n <Codec extends Schema.Top>(schema: Codec) =>\n (value: Codec[\"Type\"]): Effect.Effect<void, never, Stdio.Stdio | Codec[\"EncodingServices\"]> =>\n Schema.encodeEffect(Schema.fromJsonString(schema))(value).pipe(\n Effect.orDie,\n Effect.flatMap(writeStdout),\n );\n","import { Cause, Effect, Layer, Option } from \"effect\";\nimport type { Stdio } from \"effect\";\n\nimport { isHookBlocked, writeStderr } from \"./hook-io.ts\";\nimport type { HookBlocked } from \"./hook-io.ts\";\nimport { runMainWith } from \"./run-main.ts\";\nimport type { Platform, Run } from \"./run-main.ts\";\n\nconst blockedIn = <Failure>(cause: Cause.Cause<Failure>): Option.Option<HookBlocked> =>\n Cause.findErrorOption(cause).pipe(\n Option.filter((error): error is Failure & HookBlocked => isHookBlocked(error)),\n );\n\nconst reportBlocked = <Failure>(\n cause: Cause.Cause<Failure>,\n): Effect.Effect<void, never, Stdio.Stdio> =>\n Option.match(blockedIn(cause), {\n onNone: () => Effect.void,\n onSome: (blocked) => writeStderr(`${blocked.reason}\\n`),\n });\n\n/** @internal */\nexport const runHookWith =\n <Provided, LayerFailure>({\n serviceName,\n services,\n }: Readonly<{\n serviceName: string;\n services: Layer.Layer<Provided, LayerFailure, Platform>;\n }>): Run<Provided> =>\n (program) => {\n runMainWith({ serviceName, services })(program.pipe(Effect.tapCause(reportBlocked)));\n };\n\n/** @internal */\nexport const runHook = (serviceName: string): Run<never> =>\n runHookWith({ serviceName, services: Layer.empty });\n","import { Array as Arr, Config, Effect, Option, Schema, pipe } from \"effect\";\n\nconst taggedError = Schema.TaggedError;\n\nexport class CacheRootError extends taggedError<\n CacheRootError,\n { readonly brand: unique symbol }\n>()(\"CacheRootError\", { message: Schema.String }) {}\n\nconst SEPARATOR = \"/\";\nexport const CACHE_DIRECTORY_NAME = \".cache\";\n\nconst variable = (name: string): Effect.Effect<Option.Option<string>> =>\n Config.option(Config.NonEmptyString(name)).pipe(Effect.orElseSucceed(Option.none));\n\nconst baseDirectory: Effect.Effect<Option.Option<string>> = Effect.gen(function* baseDirectory() {\n const cacheHome = yield* variable(\"XDG_CACHE_HOME\");\n const home = yield* variable(\"HOME\");\n const profile = yield* variable(\"USERPROFILE\");\n return pipe(\n cacheHome,\n Option.orElse(() =>\n pipe(\n Option.orElse(home, () => profile),\n Option.map((directory) => `${directory}${SEPARATOR}${CACHE_DIRECTORY_NAME}`),\n ),\n ),\n );\n});\n\nexport const cacheRootEffect = (\n segments: readonly string[],\n): Effect.Effect<string, CacheRootError> =>\n baseDirectory.pipe(\n Effect.flatMap(\n Option.match({\n onNone: () => Effect.fail(CacheRootError.make({ message: \"set XDG_CACHE_HOME or HOME\" })),\n onSome: (base) => Effect.succeed(pipe([base, ...segments], Arr.join(SEPARATOR))),\n }),\n ),\n );\n\nexport const cacheRootOf = (segments: readonly string[]): Promise<string> =>\n Effect.runPromise(cacheRootEffect(segments));\n","import type { Option } from \"effect/Option\";\nimport {\n Record as RecordSchema,\n String as StringSchema,\n Unknown,\n decodeOption,\n fromJsonString,\n is,\n} from \"effect/Schema\";\n\nexport const isRecord = is(RecordSchema(StringSchema, Unknown));\n\nexport const parseJson = (text: string): Option<unknown> =>\n decodeOption(fromJsonString(Unknown))(text);\n","import { Array as Arr, Option, Record as Rec, Schema, String as Str, pipe } from \"effect\";\n\nimport type { HistoryEntry, HistoryToolCall, Message, ToolCall } from \"./types.ts\";\n\nconst FIRST = 0;\nconst ONE = 1;\nconst ELLIPSIS = \"…\";\nconst VALUE_CHARS = 200;\nconst COMPACT_INPUT_CHARS = 60;\nconst SPACES = /\\s+/gu;\nconst encodeJson = Schema.encodeOption(Schema.fromJsonString(Schema.Unknown));\n\nexport const jsonOf = (value: unknown): Option.Option<string> => encodeJson(value);\n\nexport const truncate = (text: string, limit: number): string => {\n if (Str.length(text) <= limit) {\n return text;\n }\n return `${Str.slice(FIRST, Math.max(FIRST, limit - ONE))(text)}${ELLIPSIS}`;\n};\n\nexport const isPinned = (index: number, total: number, preserveRecentMessages: number): boolean =>\n index === FIRST || index >= total - preserveRecentMessages;\n\ninterface Found {\n readonly index: number;\n readonly chars: number;\n readonly isError: boolean;\n}\n\nconst resultsOf = (messages: readonly Message[]): ReadonlyMap<string, Found> =>\n new Map(\n pipe(\n messages,\n Arr.flatMap((message, index) =>\n pipe(\n message.toolResults,\n Arr.map(\n (result) =>\n [\n result.tool_use_id,\n { index, chars: Str.length(result.text), isError: result.isError },\n ] as const,\n ),\n ),\n ),\n ),\n );\n\nexport const collectToolCalls = (\n messages: readonly Message[],\n preserveRecentMessages: number,\n): readonly ToolCall[] => {\n const results = resultsOf(messages);\n const pinned = (index: number): boolean =>\n isPinned(index, messages.length, preserveRecentMessages);\n return pipe(\n messages,\n Arr.flatMap((message, callIndex) =>\n pipe(\n message.toolUses,\n Arr.flatMap((tool) =>\n pipe(\n Option.fromUndefinedOr(results.get(tool.tool_use_id)),\n Option.map((found) => ({ tool, callIndex, found })),\n Option.toArray,\n ),\n ),\n ),\n ),\n Arr.map(({ tool, callIndex, found }, index) => ({\n id: `t${String(index + ONE)}`,\n tool_use_id: tool.tool_use_id,\n tool: tool.tool,\n input: tool.input,\n callIndex,\n resultIndex: found.index,\n resultChars: found.chars,\n isError: found.isError,\n pinned: pinned(callIndex) || pinned(found.index),\n })),\n );\n};\n\nexport const inputText = (input: Readonly<Record<string, unknown>>, limit: number): string =>\n truncate(\n Option.getOrElse(jsonOf(input), () => \"[unserializable input]\"),\n limit,\n );\n\nconst outcomeOf = (call: ToolCall): string => {\n if (call.isError) {\n return \"error\";\n }\n return \"ok\";\n};\n\nconst resultNote = (call: ToolCall): string =>\n `${outcomeOf(call)}, ${String(call.resultChars)} chars (omitted)`;\n\nconst valueText = ([key, value]: readonly [string, unknown]): string => {\n const text = pipe(\n Option.liftPredicate(value, (raw): raw is string => typeof raw === \"string\"),\n Option.getOrElse(() => inputText({ [key]: value }, VALUE_CHARS)),\n );\n return `${key}=${Str.replaceAll(SPACES, \" \")(text)}`;\n};\n\nexport const compactCall = (call: ToolCall): string => {\n const input = pipe(Rec.toEntries(call.input), Arr.map(valueText), Arr.join(\" \"));\n return `${call.id} ${call.tool} ${truncate(input, COMPACT_INPUT_CHARS)} → ${outcomeOf(call)} ${String(call.resultChars)}ch`;\n};\n\nexport const callsByMessage = (\n calls: readonly ToolCall[],\n): ReadonlyMap<number, readonly ToolCall[]> =>\n new Map(\n pipe(\n calls,\n Arr.groupBy((call) => String(call.callIndex)),\n Rec.toEntries,\n Arr.map(([index, own]) => [Number(index), own] as const),\n ),\n );\n\nconst historyCallOf =\n (inputChars: number) =>\n (call: ToolCall): HistoryToolCall => ({\n id: call.id,\n tool: call.tool,\n input: inputText(call.input, inputChars),\n result: resultNote(call),\n });\n\nexport const historyEntries = (\n messages: readonly Message[],\n calls: readonly ToolCall[],\n inputChars: number,\n): readonly HistoryEntry[] => {\n const byMessage = callsByMessage(calls);\n return pipe(\n messages,\n Arr.flatMap((message, index): readonly HistoryEntry[] => {\n const own = Option.getOrElse(Option.fromUndefinedOr(byMessage.get(index)), () => []);\n const toolCalls = pipe(own, Arr.map(historyCallOf(inputChars)));\n const entry = { index, role: message.role, text: message.text };\n if (Arr.isReadonlyArrayNonEmpty(toolCalls)) {\n return [{ ...entry, tool_calls: toolCalls }];\n }\n if (Str.isEmpty(Str.trim(message.text))) {\n return [];\n }\n return [entry];\n }),\n );\n};\n","import { Array as Arr, Number as Num, Option, String as Str, pipe } from \"effect\";\n\nconst PIECES = /(?<alpha>[A-Za-z]+)|(?<digits>\\d+)|(?<other>[^\\sA-Za-z\\d])/gu;\nconst DIGITS_PER_TOKEN = 2;\nconst LETTERS_PER_TOKEN = 6;\nconst SYMBOL_TOKENS = 0.9;\nconst ONE = 1;\n\nconst groupOf = (match: RegExpMatchArray, key: string): Option.Option<string> =>\n pipe(\n Option.fromUndefinedOr(match.groups),\n Option.flatMap((groups) => Option.fromUndefinedOr(groups[key])),\n );\n\nconst pieceTokens = (match: RegExpMatchArray): number =>\n pipe(\n groupOf(match, \"digits\"),\n Option.map((digits) => Str.length(digits) / DIGITS_PER_TOKEN),\n Option.orElse(() =>\n Option.map(\n groupOf(match, \"alpha\"),\n (alpha) => ONE + Math.floor((Str.length(alpha) - ONE) / LETTERS_PER_TOKEN),\n ),\n ),\n Option.getOrElse(() => SYMBOL_TOKENS),\n );\n\nconst matchesOf = (pattern: RegExp, text: string): readonly RegExpMatchArray[] =>\n Arr.fromIterable(Str.matchAll(pattern)(text));\n\nexport const estimateTokens = (text: string): number => {\n const pieces = pipe(matchesOf(PIECES, text), Arr.map(pieceTokens));\n return Math.ceil(Num.sumAll(pieces));\n};\n","import { Array as Arr, Number as Num, Option, pipe } from \"effect\";\n\nimport { estimateTokens } from \"#/shared/lib/tokens.ts\";\n\nimport { isPinned, jsonOf } from \"./calls.ts\";\nimport type {\n CompactionState,\n FitOptions,\n FittedState,\n HistoryEntry,\n Message,\n ToolCall,\n} from \"./types.ts\";\n\nconst ONE = 1;\nconst NONE = 0;\n\nexport const entryTokens = (entry: HistoryEntry): number =>\n estimateTokens(Option.getOrElse(jsonOf(entry), () => \"\")) + ONE;\n\nexport interface Fitting {\n readonly history: readonly Option.Option<HistoryEntry>[];\n readonly perEntry: readonly number[];\n readonly tokens: number;\n}\n\nexport interface Plan {\n readonly messages: readonly Message[];\n readonly calls: readonly ToolCall[];\n readonly options: FitOptions;\n readonly stateOf: (history: readonly HistoryEntry[]) => CompactionState;\n readonly baseTokens: number;\n readonly byMessage: ReadonlyMap<number, readonly ToolCall[]>;\n}\n\nexport type Change = (entry: HistoryEntry) => Option.Option<Option.Option<HistoryEntry>>;\n\nexport const fittingOf = (plan: Plan, history: readonly HistoryEntry[]): Fitting => {\n const perEntry = pipe(history, Arr.map(entryTokens));\n return {\n history: pipe(history, Arr.map(Option.some)),\n perEntry,\n tokens: plan.baseTokens + Num.sumAll(perEntry),\n };\n};\n\nexport const kept = (fitting: Fitting): readonly HistoryEntry[] => Arr.getSomes(fitting.history);\n\nexport const fits = (plan: Plan, fitting: Fitting): boolean =>\n fitting.tokens <= plan.options.maxStateTokens;\n\nexport const fitted = (plan: Plan, fitting: Fitting, stage: string): FittedState => ({\n state: plan.stateOf(kept(fitting)),\n tokens: fitting.tokens,\n stage,\n});\n\nexport const pinnedEntry = (plan: Plan, entry: HistoryEntry): boolean =>\n isPinned(entry.index, plan.messages.length, plan.options.preserveRecentMessages);\n\nconst orderOf = (plan: Plan, fitting: Fitting): readonly number[] => {\n const present = pipe(\n fitting.history,\n Arr.flatMap((entry, index) =>\n pipe(\n entry,\n Option.map((value) => [index, pinnedEntry(plan, value)] as const),\n Option.toArray,\n ),\n ),\n );\n const loose = pipe(\n present,\n Arr.filter(([, pinned]) => !pinned),\n );\n const pinned = pipe(\n present,\n Arr.filter(([, isPinnedEntry]) => isPinnedEntry),\n );\n return pipe(\n [...loose, ...pinned],\n Arr.map(([index]) => index),\n );\n};\n\ninterface Step {\n readonly index: number;\n readonly entry: Option.Option<HistoryEntry>;\n readonly tokens: number;\n}\n\nconst stepOf =\n (fitting: Fitting, change: Change) =>\n (index: number): Option.Option<Step> =>\n pipe(\n Option.flatten(Option.fromUndefinedOr(fitting.history[index])),\n Option.flatMap(change),\n Option.map((entry) => ({\n index,\n entry,\n tokens: Option.match(entry, { onNone: () => NONE, onSome: entryTokens }),\n })),\n );\n\nconst applied = (fitting: Fitting, steps: readonly Step[]): Fitting => {\n const byIndex = new Map(\n pipe(\n steps,\n Arr.map((step) => [step.index, step] as const),\n ),\n );\n const pick = <Value>(index: number, value: Value, of: (step: Step) => Value): Value =>\n Option.match(Option.fromUndefinedOr(byIndex.get(index)), { onNone: () => value, onSome: of });\n const history = pipe(\n fitting.history,\n Arr.map((entry, index) => pick(index, entry, (step) => step.entry)),\n );\n const perEntry = pipe(\n fitting.perEntry,\n Arr.map((tokens, index) => pick(index, tokens, (step) => step.tokens)),\n );\n const delta = Num.sumAll(\n pipe(\n steps,\n Arr.map(\n (step) => step.tokens - Option.getOrElse(Arr.get(fitting.perEntry, step.index), () => NONE),\n ),\n ),\n );\n return { history, perEntry, tokens: fitting.tokens + delta };\n};\n\nexport const staged = (\n plan: Plan,\n fitting: Fitting,\n change: Change,\n): readonly [Fitting, boolean] => {\n const steps = pipe(\n orderOf(plan, fitting),\n Arr.flatMap((index) => Option.toArray(stepOf(fitting, change)(index))),\n );\n const totals = pipe(\n steps,\n Arr.scan(\n fitting.tokens,\n (tokens, step) =>\n tokens + step.tokens - Option.getOrElse(Arr.get(fitting.perEntry, step.index), () => NONE),\n ),\n Arr.drop(ONE),\n );\n return Option.match(\n Arr.findFirstIndex(totals, (tokens) => tokens <= plan.options.maxStateTokens),\n {\n onNone: () => [applied(fitting, steps), false] as const,\n onSome: (at) => [applied(fitting, Arr.take(steps, at + ONE)), true] as const,\n },\n );\n};\n","import {\n Array as Arr,\n Effect,\n Option,\n Predicate,\n Result,\n Schema,\n String as Str,\n pipe,\n} from \"effect\";\n\nimport { estimateTokens } from \"#/shared/lib/tokens.ts\";\n\nimport { callsByMessage, compactCall, historyEntries, jsonOf, truncate } from \"./calls.ts\";\nimport { fits, fitted, fittingOf, kept, pinnedEntry, staged } from \"./fitting.ts\";\nimport type { Change, Fitting, Plan } from \"./fitting.ts\";\nimport type {\n CompactionState,\n FitOptions,\n FittedState,\n HistoryEntry,\n HistoryToolCall,\n Message,\n ToolCall,\n} from \"./types.ts\";\n\nexport const STATE_CONTEXT =\n \"A coding assistant conversation is being compacted to free context. `history` is the whole conversation so far, oldest first; tool outputs are replaced by a short `result` note and long texts may be abridged. Each question asks whether one tool call, or the full output of that call, still needs to stay in the history verbatim. Whatever is not kept is deleted permanently, but the assistant can always re-run a tool or re-read a file.\";\n\nconst taggedError = Schema.TaggedError;\n\nexport class HistoryTooLarge extends taggedError<\n HistoryTooLarge,\n { readonly brand: unique symbol }\n>()(\"HistoryTooLarge\", { reason: Schema.String }) {}\n\nconst FULL_INPUT_CHARS = 1000;\nconst SHORT_INPUT_CHARS = 200;\nconst SHORTEST_INPUT_CHARS = 60;\nconst SHORTER_INPUT_CHARS = [SHORT_INPUT_CHARS, SHORTEST_INPUT_CHARS] as const;\nconst TEXT_HEAD = 400;\nconst TEXT_TAIL = 150;\nconst ABRIDGE_MARGIN = 40;\nconst RECENT_GOALS = 3;\nconst GOAL_CHARS = 500;\nconst ONE = 1;\n\nconst abridge = (text: string): string => {\n const omitted = Str.length(text) - TEXT_HEAD - TEXT_TAIL;\n return `${Str.takeLeft(TEXT_HEAD)(text)}\\n[… ${String(omitted)} chars omitted …]\\n${Str.takeRight(TEXT_TAIL)(text)}`;\n};\n\nexport const goalFromMessages = (messages: readonly Message[]): string =>\n pipe(\n messages,\n Arr.filter(\n (message) =>\n message.role === \"user\" &&\n Str.isNonEmpty(Str.trim(message.text)) &&\n Arr.isReadonlyArrayEmpty(message.toolResults),\n ),\n Arr.takeRight(RECENT_GOALS),\n Arr.map((message) => truncate(message.text, GOAL_CHARS)),\n Arr.join(\"\\n\"),\n );\n\nconst abridgeText: Change = (entry: HistoryEntry) =>\n Option.liftPredicate(\n Option.some({ ...entry, text: abridge(entry.text) }),\n () => Str.length(entry.text) > TEXT_HEAD + TEXT_TAIL + ABRIDGE_MARGIN,\n );\n\nconst collapseText =\n (plan: Plan): Change =>\n (entry: HistoryEntry) => {\n const original = pipe(\n Arr.get(plan.messages, entry.index),\n Option.map((message) => Str.length(message.text)),\n Option.getOrElse(() => Str.length(entry.text)),\n );\n return Option.liftPredicate(\n Option.some({ ...entry, text: `[… ${String(original)} chars omitted …]` }),\n () => !pinnedEntry(plan, entry) && Str.isNonEmpty(entry.text),\n );\n };\n\nconst compactCalls =\n (plan: Plan): Change =>\n (entry: HistoryEntry) =>\n pipe(\n Option.fromUndefinedOr(plan.byMessage.get(entry.index)),\n Option.filter(() => !pinnedEntry(plan, entry)),\n Option.map((own) => Option.some({ ...entry, tool_calls: pipe(own, Arr.map(compactCall)) })),\n );\n\nconst leaveOut =\n (plan: Plan): Change =>\n (entry: HistoryEntry) =>\n Option.liftPredicate(\n Option.none<HistoryEntry>(),\n () => !pinnedEntry(plan, entry) && Predicate.isUndefined(entry.tool_calls),\n );\n\nconst callsOf = (entry: HistoryEntry): readonly (HistoryToolCall | string)[] =>\n Option.getOrElse(Option.fromUndefinedOr(entry.tool_calls), () => []);\n\nconst stringCalls = (entry: HistoryEntry): readonly string[] =>\n pipe(callsOf(entry), Arr.filter(Predicate.isString));\n\nconst foldable = (plan: Plan, entry: HistoryEntry): boolean =>\n !pinnedEntry(plan, entry) &&\n Str.isEmpty(entry.text) &&\n pipe(Arr.head(callsOf(entry)), Option.exists(Predicate.isString));\n\nconst mergedRun = (group: Arr.NonEmptyReadonlyArray<HistoryEntry>): HistoryEntry => {\n const first = Arr.headNonEmpty(group);\n if (group.length === ONE) {\n return first;\n }\n return { ...first, tool_calls: pipe(group, Arr.flatMap(stringCalls)) };\n};\n\nconst mergeRuns = (plan: Plan, history: readonly HistoryEntry[]): readonly HistoryEntry[] => {\n if (!Arr.isReadonlyArrayNonEmpty(history)) {\n return [];\n }\n return pipe(\n Arr.groupWith(\n history,\n (left, right) => foldable(plan, left) && foldable(plan, right) && left.role === right.role,\n ),\n Arr.map(mergedRun),\n );\n};\n\ntype Staged = readonly [Fitting, boolean];\n\ntype Stage = readonly [string, (fitting: Fitting) => Staged];\n\nconst rebuilt = (plan: Plan, inputChars: number) => (): readonly [Fitting, boolean] => {\n const fitting = fittingOf(plan, historyEntries(plan.messages, plan.calls, inputChars));\n return [fitting, fits(plan, fitting)];\n};\n\nconst stagesOf = (plan: Plan): readonly Stage[] => [\n ...pipe(\n SHORTER_INPUT_CHARS,\n Arr.map((limit): Stage => [`inputs<=${String(limit)}`, rebuilt(plan, limit)]),\n ),\n [\"texts abridged\", (fitting): Staged => staged(plan, fitting, abridgeText)],\n [\"old messages collapsed\", (fitting): Staged => staged(plan, fitting, collapseText(plan))],\n [\"old calls compacted\", (fitting): Staged => staged(plan, fitting, compactCalls(plan))],\n [\"old messages left out\", (fitting): Staged => staged(plan, fitting, leaveOut(plan))],\n [\n \"old calls merged\",\n (fitting): Staged => {\n const merged = fittingOf(plan, mergeRuns(plan, kept(fitting)));\n return [merged, fits(plan, merged)];\n },\n ],\n];\n\nconst throughStages = (\n plan: Plan,\n fitting: Fitting,\n stages: readonly Stage[],\n): Result.Result<FittedState, Fitting> =>\n Option.match(Arr.head(stages), {\n onNone: () => Result.fail(fitting),\n onSome: ([name, run]) => {\n const [next, done] = run(fitting);\n if (done) {\n return Result.succeed(fitted(plan, next, name));\n }\n return throughStages(plan, next, Arr.drop(stages, ONE));\n },\n });\n\nconst jsonText = (value: unknown): string => Option.getOrElse(jsonOf(value), () => \"\");\n\nconst planOf = (\n messages: readonly Message[],\n calls: readonly ToolCall[],\n options: FitOptions,\n): Plan => {\n const goal = pipe(\n Option.liftPredicate(options.goal, Str.isNonEmpty),\n Option.getOrElse(() => goalFromMessages(messages)),\n );\n const stateOf = (history: readonly HistoryEntry[]): CompactionState => ({\n context: STATE_CONTEXT,\n goal,\n history,\n });\n return {\n messages,\n calls,\n options,\n stateOf,\n baseTokens: estimateTokens(jsonText(stateOf([]))),\n byMessage: callsByMessage(calls),\n };\n};\n\nexport const fitState = (\n messages: readonly Message[],\n calls: readonly ToolCall[],\n options: FitOptions,\n): Effect.Effect<FittedState, HistoryTooLarge> => {\n const plan = planOf(messages, calls, options);\n const full = fittingOf(plan, historyEntries(messages, calls, FULL_INPUT_CHARS));\n if (fits(plan, full)) {\n return Effect.succeed(fitted(plan, full, \"full\"));\n }\n return Result.match(throughStages(plan, full, stagesOf(plan)), {\n onSuccess: Effect.succeed,\n onFailure: (last) =>\n Effect.fail(\n HistoryTooLarge.make({\n reason: `history too large for Jev (~${String(last.tokens)} tokens after truncation, limit ${String(options.maxStateTokens)})`,\n }),\n ),\n });\n};\n","import { Array as Arr, Option, String as Str, pipe } from \"effect\";\n\nconst OWNER_BODIES: readonly RegExp[] = [\n /<message\\b[^>]*\\bfrom=\"human\"[^>]*\\btrust=\"principal\"[^>]*>(?<body>[\\s\\S]*?)<\\/message>/gu,\n /<cited\\b[^>]*\\bauthor=\"user\"[^>]*>(?<body>[\\s\\S]*?)<\\/cited>/gu,\n];\n\nconst bodiesOf = (prompt: string): readonly string[] =>\n pipe(\n OWNER_BODIES,\n Arr.flatMap((pattern) => Arr.fromIterable(pipe(prompt, Str.matchAll(pattern)))),\n Arr.map((found) =>\n pipe(\n Option.fromUndefinedOr(found.groups),\n Option.flatMap((groups) => Option.fromUndefinedOr(groups[\"body\"])),\n ),\n ),\n Arr.getSomes,\n );\n\nconst argumentsAfter =\n (text: string) =>\n (command: string): Option.Option<string> =>\n pipe(\n Option.some(Str.trimStart(text)),\n Option.filter(Str.startsWith(command)),\n Option.map((typed) => Str.slice(command.length)(typed)),\n Option.filter((rest) => Str.isEmpty(rest) || /^\\s/u.test(rest)),\n Option.map(Str.trim),\n );\n\nconst typedIn =\n (commands: readonly string[]) =>\n (text: string): Option.Option<string> =>\n Arr.findFirst(commands, argumentsAfter(text));\n\nconst ownerBody =\n (commands: readonly string[]) =>\n (prompt: string): Option.Option<string> =>\n pipe(bodiesOf(prompt), Arr.map(typedIn(commands)), Arr.getSomes, Arr.last);\n\nexport const ownerCommand = (prompt: string, commands: readonly string[]): Option.Option<string> =>\n Option.orElse(typedIn(commands)(prompt), () => ownerBody(commands)(prompt));\n","import { Array as Arr, Effect, FileSystem, Option, Path, String as Str, pipe } from \"effect\";\n\nimport { ownerCommand } from \"./owner-command.ts\";\n\nconst OFF = \"disable\";\n\nconst turnsOn = (args: string): boolean =>\n !pipe(\n Str.split(args, /\\s+/u),\n Arr.head,\n Option.exists((word) => word === OFF),\n );\n\nexport const ownerSwitch = (prompt: string, commands: readonly string[]): Option.Option<boolean> =>\n Option.map(ownerCommand(prompt, commands), turnsOn);\n\nconst markerOf = Effect.fn(\"markerOf\")(function* markerOf(directory: string, session: string) {\n const path = yield* Path.Path;\n return path.join(directory, path.basename(session));\n});\n\n/** @internal */\nexport const switchSession = Effect.fn(\"switchSession\")(function* switchSession(\n directory: string,\n session: string,\n on: boolean,\n) {\n const fs = yield* FileSystem.FileSystem;\n const marker = yield* markerOf(directory, session);\n if (!on) {\n return yield* fs.remove(marker, { force: true });\n }\n yield* fs.makeDirectory(directory, { recursive: true });\n return yield* fs.writeFileString(marker, \"\");\n});\n\n/** @internal */\nexport const sessionSwitchedOn = Effect.fn(\"sessionSwitchedOn\")(function* sessionSwitchedOn(\n directory: string,\n session: string,\n) {\n const fs = yield* FileSystem.FileSystem;\n if (Str.isEmpty(session)) {\n return false;\n }\n const marker = yield* markerOf(directory, session);\n return yield* fs.exists(marker).pipe(Effect.orElseSucceed(() => false));\n});\n","import { Array as Arr, Effect, FileSystem, Path, Record as Rec, Schema, pipe } from \"effect\";\n\nconst InstalledEntry = Schema.Struct({\n installPath: Schema.String,\n version: Schema.Unknown,\n gitCommitSha: Schema.Unknown,\n});\nconst InstalledPlugins = Schema.Struct({\n plugins: Schema.Record(Schema.String, Schema.Array(InstalledEntry)),\n});\nconst decodeInstalled = Schema.decodeUnknownEffect(Schema.fromJsonString(InstalledPlugins));\n\nexport interface InstalledPlugin {\n readonly id: string;\n readonly installPath: string;\n readonly version: unknown;\n readonly sha: unknown;\n}\n\nconst flattened = (installed: typeof InstalledPlugins.Type): readonly InstalledPlugin[] =>\n pipe(\n Rec.toEntries(installed.plugins),\n Arr.flatMap(([id, entries]) =>\n pipe(\n entries,\n Arr.map((entry) => ({\n id,\n installPath: entry.installPath,\n version: entry.version,\n sha: entry.gitCommitSha,\n })),\n ),\n ),\n );\n\n/** @internal */\nexport const installedPlugins = Effect.fn(\"installedPlugins\")(function* installedPlugins(\n home: string,\n) {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const file = path.join(home, \".claude\", \"plugins\", \"installed_plugins.json\");\n return yield* fs.readFileString(file).pipe(\n Effect.flatMap(decodeInstalled),\n Effect.map(flattened),\n Effect.orElseSucceed((): readonly InstalledPlugin[] => []),\n );\n});\n","import {\n Array as Arr,\n Option,\n Predicate,\n Record as Rec,\n Schema,\n String as Str,\n pipe,\n} from \"effect\";\n\nexport type Place = \"ci\" | \"cloud\" | \"local\";\n\nexport interface Origin {\n readonly place: Place;\n readonly project: string;\n readonly hook: string;\n readonly sessionId: string;\n}\n\nexport interface JevSettings {\n readonly openRouterKey: string;\n readonly openRouterModel: string;\n readonly allowTraining: boolean;\n readonly attribution: Readonly<Record<string, string>>;\n}\n\nexport interface JevBackend {\n readonly apiKey: string;\n readonly baseURL: string;\n readonly model: string;\n readonly extra: Readonly<Record<string, unknown>>;\n readonly headers: Readonly<Record<string, string>>;\n readonly textState: boolean;\n}\n\nexport interface PlaceEnv {\n readonly githubActions: string;\n readonly remote: string;\n}\n\nexport type JevState = Readonly<Record<string, string>>;\n\nconst DEFAULT_OPENROUTER_MODEL = \"respan/span-01-lite\";\nconst TEXT_STATE_PREFIX = \"respan/\";\nconst encodeJson = Schema.encodeOption(Schema.fromJsonString(Schema.Unknown));\n\nexport const placeOf = (env: PlaceEnv): Place => {\n if (env.githubActions === \"true\") {\n return \"ci\";\n }\n if (env.remote === \"true\") {\n return \"cloud\";\n }\n return \"local\";\n};\n\nconst dataCollection = (allowTraining: boolean): string => {\n if (allowTraining) {\n return \"allow\";\n }\n return \"deny\";\n};\n\nexport const jevBackend = (settings: JevSettings, origin: Origin): JevBackend => {\n const model = pipe(\n Option.liftPredicate(settings.openRouterModel, Str.isNonEmpty),\n Option.getOrElse(() => DEFAULT_OPENROUTER_MODEL),\n );\n const session = pipe(\n Option.liftPredicate(origin.sessionId, Str.isNonEmpty),\n Option.match({ onNone: () => ({}), onSome: (id) => ({ session_id: id }) }),\n );\n return {\n apiKey: settings.openRouterKey,\n baseURL: \"https://openrouter.ai/api\",\n model,\n extra: {\n provider: { data_collection: dataCollection(settings.allowTraining) },\n user: `${origin.place}:${origin.project}:${origin.hook}`,\n ...session,\n },\n headers: settings.attribution,\n textState: Str.startsWith(TEXT_STATE_PREFIX)(model),\n };\n};\n\nconst sectionOf = ([key, value]: readonly [string, unknown]): string => {\n const text = pipe(\n Option.liftPredicate(value, Predicate.isString),\n Option.orElse(() => encodeJson(value)),\n Option.getOrElse(() => \"\"),\n );\n return `## ${key}\\n${text}`;\n};\n\nexport const stateFor = (backend: JevBackend, state: JevState): JevState | string => {\n if (!backend.textState) {\n return state;\n }\n return pipe(Rec.toEntries(state), Arr.map(sectionOf), Arr.join(\"\\n\\n\"));\n};\n"],"mappings":";;;;AAEA,MAAM,gBAAgB;AAEtB,MAAMA,gBAAc,OAAO;;AAG3B,IAAa,cAAb,cAAiCA,cAA4D,CAAC,CAC5F,eACA,EAAE,QAAQ,OAAO,OAAO,CAC1B,CAAC,CAAC;CACA,CAA0B,QAAQ,iBAAiB;CACnD,CAA0B,QAAQ,iBAAiB;AACrD;;AAGA,MAAa,gBAAgB,OAAO,GAAG,WAAW;;AAGlD,MAAa,aAAa,WACxB,OAAO,KAAK,YAAY,KAAK,EAAE,OAAO,CAAC,CAAC;;AAG1C,MAAa,YAAuD,OAAO,IACzE,UAAU,YAAY;CAEpB,OAAO,QAAO,OADO,MAAM,MAAA,CACP,MAAM,KAAK,OAAO,YAAY,OAAO,UAAU,OAAO,KAAK;AACjF,CACF;;AAGA,MAAa,iBACX,WAEA,OAAO,IAAI,UAAU,OAAO;CAC1B,MAAM,OAAO,OAAO;CACpB,MAAM,OAAO,OAAO,eAAe,MAAM;CACzC,OAAO,OAAO,OAAO,aAAa,IAAI,CAAC,CAAC,IAAI;AAC9C,CAAC;;AAGH,MAAa,eAAe,SAC1B,OAAO,IAAI,UAAU,WAAW;CAC9B,MAAM,QAAQ,OAAO,MAAM;CAC3B,OAAO,OAAO,KAAK,IAAI,CAAC,CAAC,KAAK,OAAO,IAAI,MAAM,OAAO,CAAC,GAAG,OAAO,KAAK;AACxE,CAAC;;AAGH,MAAa,eAAe,SAC1B,OAAO,IAAI,UAAU,WAAW;CAC9B,MAAM,QAAQ,OAAO,MAAM;CAC3B,OAAO,OAAO,KAAK,IAAI,CAAC,CAAC,KAAK,OAAO,IAAI,MAAM,OA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nF,IAAI,CAAC,QAAQ,WACX,OAAO;CAET,OAAO,KAAKC,OAAI,UAAU,KAAK,GAAGC,MAAI,IAAI,SAAS,GAAGA,MAAI,KAAK,MAAM,CAAC;AACxE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@r_masseater/masseater-utils",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.1",
|
|
4
4
|
"description": "The small shared libraries of masseater's repositories as subpaths of one package: a chip row for React, Claude Code plugin helpers, Effect entry points for Node.js and GitHub Actions, file import mapping, Node package readers, OTLP assertions for Vitest and Cloudflare Workers tracing, and what the Tauri desktop apps share: OpenTelemetry for the screens, Vite settings, the media-notes screens and the release commands.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"actions",
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: add-scroll-chip-row
|
|
3
3
|
description: >
|
|
4
|
-
Use when a React page shows a row of filter chips or tags that must scroll
|
|
5
|
-
wrapping: ScrollChipRow of
|
|
6
|
-
|
|
4
|
+
Use when a React page shows a row of filter chips or tags that must scroll
|
|
5
|
+
sideways instead of wrapping: ScrollChipRow of
|
|
6
|
+
@r_masseater/masseater-utils/skerm, the stylesheet it needs, the aria
|
|
7
|
+
attributes that mark the current chip, and the colors of its arrow buttons.
|
|
7
8
|
metadata:
|
|
8
9
|
type: core
|
|
9
10
|
library: "@r_masseater/masseater-utils"
|
|
11
|
+
library_version: 0.11.1
|
|
10
12
|
sources:
|
|
11
|
-
- src/app
|
|
12
|
-
- src/features/scroll-chip-row
|
|
13
|
+
- src/app
|
|
14
|
+
- src/features/scroll-chip-row
|
|
13
15
|
- README.md
|
|
14
16
|
---
|
|
15
17
|
|
|
@@ -57,3 +59,5 @@ Set `--skerm-surface`, `--skerm-on-surface`, `--skerm-border` and `--skerm-hover
|
|
|
57
59
|
|
|
58
60
|
- Do not wrap the chips in your own `overflow-x` container. The row already scrolls, and a second scroller breaks the fade and the arrows.
|
|
59
61
|
- Do not give a chip `aria-current="false"` to mean "not current" unless you want it ignored. The row skips `"false"`.
|
|
62
|
+
|
|
63
|
+
This skill describes [`src/app`](../../src/app), [`src/features/scroll-chip-row`](../../src/features/scroll-chip-row) and [`README.md`](../../README.md).
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: assert-exported-telemetry
|
|
3
3
|
description: >
|
|
4
|
-
Use when a Vitest test must prove which OpenTelemetry spans, logs or metrics
|
|
5
|
-
really exported: the otlp() plugin, waitForSpans,
|
|
6
|
-
the semconv check with Weaver,
|
|
4
|
+
Use when a Vitest test must prove which OpenTelemetry spans, logs or metrics
|
|
5
|
+
the code under test really exported: the otlp() plugin, waitForSpans,
|
|
6
|
+
waitForLogs, waitForMetrics, clearTelemetry, the semconv check with Weaver,
|
|
7
|
+
and tailWorker for Cloudflare Workers under Miniflare.
|
|
7
8
|
metadata:
|
|
8
9
|
type: core
|
|
9
10
|
library: "@r_masseater/masseater-utils"
|
|
11
|
+
library_version: 0.11.1
|
|
10
12
|
sources:
|
|
11
|
-
- src/app
|
|
12
|
-
- src/features/receive-otlp
|
|
13
|
+
- src/app
|
|
14
|
+
- src/features/receive-otlp
|
|
13
15
|
- README.md
|
|
14
16
|
---
|
|
15
17
|
|
|
@@ -129,3 +131,5 @@ test("caching writes to KV", () =>
|
|
|
129
131
|
- Asserting right after the code runs without `waitFor*`. Batch processors export later, so read through `waitFor*` or shut the SDK down first.
|
|
130
132
|
- Sharing received telemetry between tests. Call `clearTelemetry` in `beforeEach` when tests check counts.
|
|
131
133
|
- Mocking the exporter instead. That proves nothing about what leaves the process.
|
|
134
|
+
|
|
135
|
+
This skill describes [`src/app`](../../src/app), [`src/features/receive-otlp`](../../src/features/receive-otlp) and [`README.md`](../../README.md).
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: build-tauri-app
|
|
3
3
|
description: >
|
|
4
|
-
Use when building or releasing a Tauri desktop app on
|
|
5
|
-
|
|
4
|
+
Use when building or releasing a Tauri desktop app on
|
|
5
|
+
@r_masseater/masseater-utils/desktop-shell: the Rust crate and its cargo
|
|
6
|
+
patches, the Vite settings, telemetry from the screen and from Rust, the
|
|
6
7
|
updater and its signing key, the release commands, and the media-notes parts.
|
|
7
8
|
metadata:
|
|
8
9
|
type: core
|
|
9
10
|
library: "@r_masseater/masseater-utils"
|
|
11
|
+
library_version: 0.11.1
|
|
10
12
|
sources:
|
|
11
|
-
- src
|
|
12
|
-
- bin
|
|
13
|
-
- native
|
|
13
|
+
- src
|
|
14
|
+
- bin
|
|
15
|
+
- native
|
|
14
16
|
- README.md
|
|
15
17
|
---
|
|
16
18
|
|
|
@@ -56,3 +58,5 @@ Apps check for an update when they start, download it, ask the user, then instal
|
|
|
56
58
|
## Media notes
|
|
57
59
|
|
|
58
60
|
Apps that mark and comment on ranges of media use `@r_masseater/masseater-utils/desktop-shell/media-notes` for the screen parts, `@r_masseater/masseater-utils/desktop-shell/media-notes/protocol` for the types, and the `media-notes` crate for the Rust side. Each app's page lays out the parts and adds the form and list for the notes it saves.
|
|
61
|
+
|
|
62
|
+
This skill describes [`src`](../../src), [`bin`](../../bin), [`native`](../../native) and [`README.md`](../../README.md).
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: find-cache-folder
|
|
3
3
|
description: >
|
|
4
|
-
Use when a Claude Code plugin hook or script must keep downloaded or built
|
|
5
|
-
such as a model, a binary or an installed tool:
|
|
6
|
-
XDG_CACHE_HOME or ~/.cache.
|
|
4
|
+
Use when a Claude Code plugin hook or script must keep downloaded or built
|
|
5
|
+
files between runs, such as a model, a binary or an installed tool:
|
|
6
|
+
cacheRootOf gives the folder under XDG_CACHE_HOME or ~/.cache.
|
|
7
7
|
metadata:
|
|
8
8
|
type: core
|
|
9
9
|
library: "@r_masseater/masseater-utils"
|
|
10
|
+
library_version: 0.11.1
|
|
10
11
|
sources:
|
|
11
|
-
- src/app
|
|
12
|
+
- src/app
|
|
12
13
|
- src/shared/lib/cache.ts
|
|
13
14
|
- README.md
|
|
14
15
|
---
|
|
@@ -34,3 +35,5 @@ const root = await cacheRootOf(["my-plugin", "runtime"]);
|
|
|
34
35
|
```
|
|
35
36
|
|
|
36
37
|
The folder is `$XDG_CACHE_HOME/my-plugin/runtime`, or `~/.cache/my-plugin/runtime` when `XDG_CACHE_HOME` is unset or empty. The function builds the path only and creates nothing. It rejects with `CacheRootError` when neither `XDG_CACHE_HOME` nor `HOME` (or `USERPROFILE` on Windows) is set. `cacheRootEffect` is the same lookup as an Effect: provide a `ConfigProvider` to test it with a fake environment.
|
|
38
|
+
|
|
39
|
+
This skill describes [`src/app`](../../src/app), [`src/shared/lib/cache.ts`](../../src/shared/lib/cache.ts) and [`README.md`](../../README.md).
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: import-custom-format
|
|
3
3
|
description: >
|
|
4
|
-
Use when TypeScript must import a file in a custom format with editor support:
|
|
5
|
-
mapping as segments (text, verbatim, alias, atom), producing
|
|
6
|
-
mappedOutput, and loading the file as a module
|
|
4
|
+
Use when TypeScript must import a file in a custom format with editor support:
|
|
5
|
+
describing the mapping as segments (text, verbatim, alias, atom), producing
|
|
6
|
+
ts-content-mapper output with mappedOutput, and loading the file as a module
|
|
7
|
+
with the contentImport Vite plugin.
|
|
7
8
|
metadata:
|
|
8
9
|
type: core
|
|
9
10
|
library: "@r_masseater/masseater-utils"
|
|
11
|
+
library_version: 0.11.1
|
|
10
12
|
sources:
|
|
11
|
-
- src/entities/segment
|
|
12
|
-
- src/features/map-content
|
|
13
|
-
- src/features/import-content
|
|
13
|
+
- src/entities/segment
|
|
14
|
+
- src/features/map-content
|
|
15
|
+
- src/features/import-content
|
|
14
16
|
- README.md
|
|
15
17
|
---
|
|
16
18
|
|
|
@@ -74,3 +76,5 @@ Pass the request and the mapped result. Errors need a `fallback` text, so the se
|
|
|
74
76
|
Wrong: write `<file>.d.my.ts` in `load` with the file system.
|
|
75
77
|
|
|
76
78
|
Correct: return it as `declaration` and let the plugin write it only when it changed.
|
|
79
|
+
|
|
80
|
+
This skill describes [`src/entities/segment`](../../src/entities/segment), [`src/features/map-content`](../../src/features/map-content), [`src/features/import-content`](../../src/features/import-content) and [`README.md`](../../README.md).
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: name-stack-resources
|
|
3
3
|
description: >
|
|
4
|
-
Use when an Alchemy stack must be named after its app and every Cloudflare
|
|
5
|
-
start with the app name, with
|
|
6
|
-
app-name.ts, and
|
|
4
|
+
Use when an Alchemy stack must be named after its app and every Cloudflare
|
|
5
|
+
resource in it must start with the app name, with
|
|
6
|
+
@r_masseater/masseater-utils/app-name: appNamed, APP_NAME in app-name.ts, and
|
|
7
|
+
yielding requireAppPrefix at the end of the stack.
|
|
7
8
|
metadata:
|
|
8
9
|
type: core
|
|
9
10
|
library: "@r_masseater/masseater-utils"
|
|
10
|
-
library_version: 0.1
|
|
11
|
+
library_version: 0.11.1
|
|
11
12
|
sources:
|
|
12
13
|
- src/app/app-name.ts
|
|
13
|
-
- src/features/name-app
|
|
14
|
+
- src/features/name-app
|
|
14
15
|
---
|
|
15
16
|
|
|
16
17
|
# name-stack-resources
|
|
@@ -58,3 +59,5 @@ export default Stack(
|
|
|
58
59
|
- A resource that declares no `name` is not checked, because Alchemy derives its name from the stack name.
|
|
59
60
|
|
|
60
61
|
When any resource is off, `requireAppPrefix` stops the deploy with an error that lists every offender.
|
|
62
|
+
|
|
63
|
+
This skill describes [`src/app/app-name.ts`](../../src/app/app-name.ts) and [`src/features/name-app`](../../src/features/name-app).
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: read-hook-input
|
|
3
3
|
description: >
|
|
4
|
-
Use when a Claude Code plugin hook or script must read JSON it did not write,
|
|
5
|
-
payload on stdin or a settings file: runHook, runHookWith,
|
|
6
|
-
|
|
4
|
+
Use when a Claude Code plugin hook or script must read JSON it did not write,
|
|
5
|
+
such as a hook payload on stdin or a settings file: runHook, runHookWith,
|
|
6
|
+
readHookInput, writeHookOutput and blockHook for a hook written with Effect,
|
|
7
|
+
and parseJson and isRecord for plain code.
|
|
7
8
|
metadata:
|
|
8
9
|
type: core
|
|
9
10
|
library: "@r_masseater/masseater-utils"
|
|
11
|
+
library_version: 0.11.1
|
|
10
12
|
sources:
|
|
11
|
-
- src/app
|
|
13
|
+
- src/app
|
|
12
14
|
- src/features/run-main/model/hook-io.ts
|
|
13
15
|
- src/features/run-main/model/run-hook.ts
|
|
14
16
|
- src/shared/lib/record.ts
|
|
@@ -70,3 +72,5 @@ if (parsed._tag === "Some" && isRecord(parsed.value)) {
|
|
|
70
72
|
```
|
|
71
73
|
|
|
72
74
|
`parseJson` returns `{ _tag: "None" }` when the text is not JSON and never throws. `isRecord` is false for `null`, arrays and primitives, so check it before reading keys.
|
|
75
|
+
|
|
76
|
+
This skill describes [`src/app`](../../src/app), [`src/features/run-main/model/hook-io.ts`](../../src/features/run-main/model/hook-io.ts), [`src/features/run-main/model/run-hook.ts`](../../src/features/run-main/model/run-hook.ts), [`src/shared/lib/record.ts`](../../src/shared/lib/record.ts) and [`README.md`](../../README.md).
|
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: read-node-ecosystem
|
|
3
3
|
description: >
|
|
4
|
-
Use when TypeScript code must read or write a package.json, read
|
|
5
|
-
pnpm-lock.yaml or the projects of a pnpm workspace, or
|
|
6
|
-
values: PackageJson, decodePackageJson,
|
|
7
|
-
|
|
4
|
+
Use when TypeScript code must read or write a package.json, read
|
|
5
|
+
pnpm-workspace.yaml, pnpm-lock.yaml or the projects of a pnpm workspace, or
|
|
6
|
+
find an installed package, as Effect values: PackageJson, decodePackageJson,
|
|
7
|
+
readPackageJson, updatePackageJson, readWorkspaceManifest, lockedGraph,
|
|
8
|
+
findWorkspaceProjects and findPackageJson.
|
|
8
9
|
metadata:
|
|
9
10
|
type: core
|
|
10
11
|
library: "@r_masseater/masseater-utils"
|
|
12
|
+
library_version: 0.11.1
|
|
11
13
|
sources:
|
|
12
|
-
- src/app
|
|
13
|
-
- src/entities/package-json
|
|
14
|
-
- src/features/find-node-package
|
|
15
|
-
- src/features/read-npm
|
|
16
|
-
- src/features/read-pnpm
|
|
14
|
+
- src/app
|
|
15
|
+
- src/entities/package-json
|
|
16
|
+
- src/features/find-node-package
|
|
17
|
+
- src/features/read-npm
|
|
18
|
+
- src/features/read-pnpm
|
|
17
19
|
- README.md
|
|
18
20
|
---
|
|
19
21
|
|
|
@@ -129,3 +131,5 @@ import { findPackageJson } from "@r_masseater/masseater-utils/kestrion/node";
|
|
|
129
131
|
|
|
130
132
|
const file = findPackageJson("effect", import.meta.url);
|
|
131
133
|
```
|
|
134
|
+
|
|
135
|
+
This skill describes [`src/app`](../../src/app), [`src/entities/package-json`](../../src/entities/package-json), [`src/features/find-node-package`](../../src/features/find-node-package), [`src/features/read-npm`](../../src/features/read-npm), [`src/features/read-pnpm`](../../src/features/read-pnpm) and [`README.md`](../../README.md).
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: run-effect-main
|
|
3
3
|
description: >
|
|
4
|
-
Use when an Effect program must run as a Node.js entry point with the Node
|
|
5
|
-
client and OTLP tracing provided: runMain, runMainWith, and
|
|
6
|
-
process that must stop when its parent exits.
|
|
4
|
+
Use when an Effect program must run as a Node.js entry point with the Node
|
|
5
|
+
services, an HTTP client and OTLP tracing provided: runMain, runMainWith, and
|
|
6
|
+
whileParentAlive for a child process that must stop when its parent exits.
|
|
7
7
|
metadata:
|
|
8
8
|
type: core
|
|
9
9
|
library: "@r_masseater/masseater-utils"
|
|
10
|
+
library_version: 0.11.1
|
|
10
11
|
sources:
|
|
11
|
-
- src/app
|
|
12
|
-
- src/features/run-main
|
|
13
|
-
- src/features/watch-parent
|
|
12
|
+
- src/app
|
|
13
|
+
- src/features/run-main
|
|
14
|
+
- src/features/watch-parent
|
|
14
15
|
- README.md
|
|
15
16
|
---
|
|
16
17
|
|
|
@@ -80,3 +81,5 @@ runMain("my-tool")(program);
|
|
|
80
81
|
```
|
|
81
82
|
|
|
82
83
|
The direct call has no tracing and none of the services the program expects.
|
|
84
|
+
|
|
85
|
+
This skill describes [`src/app`](../../src/app), [`src/features/run-main`](../../src/features/run-main), [`src/features/watch-parent`](../../src/features/watch-parent) and [`README.md`](../../README.md).
|
|
@@ -1,28 +1,30 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: share-types-with-rust
|
|
3
3
|
description: >
|
|
4
|
-
Use when TypeScript and Rust in this repository exchange data: a Tauri app
|
|
5
|
-
side, a Rust process reading JSON that TypeScript writes,
|
|
6
|
-
that mirrors a TypeScript type. Covers
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
Use when TypeScript and Rust in this repository exchange data: a Tauri app
|
|
5
|
+
talking to its web side, a Rust process reading JSON that TypeScript writes,
|
|
6
|
+
or any Rust struct, enum, or constant that mirrors a TypeScript type. Covers
|
|
7
|
+
defining the types as Effect Schema, generating the serde Rust with the
|
|
8
|
+
effect2rs subpath of @r_masseater/masseater-utils from the app's own codegen
|
|
9
|
+
command, the checkRust freshness and hand-written copy check, and the wire
|
|
10
|
+
differences that stay between the two sides. Also use when codegen:check
|
|
11
|
+
reports a stale file or a hand-written copy.
|
|
10
12
|
metadata:
|
|
11
|
-
purpose: >
|
|
12
|
-
Keep one source of truth for every type that crosses the TypeScript and Rust boundary, so the
|
|
13
|
-
Rust side is always generated from Effect Schema and never drifts or gets copied by hand.
|
|
14
13
|
type: core
|
|
15
14
|
library: "@r_masseater/masseater-utils"
|
|
15
|
+
library_version: 0.11.1
|
|
16
16
|
sources:
|
|
17
|
-
- src/app
|
|
18
|
-
- src/entities/rust-item
|
|
19
|
-
- src/features/check-rust
|
|
20
|
-
- src/features/render-rust
|
|
21
|
-
- effect2rs-conformance
|
|
17
|
+
- src/app
|
|
18
|
+
- src/entities/rust-item
|
|
19
|
+
- src/features/check-rust
|
|
20
|
+
- src/features/render-rust
|
|
21
|
+
- effect2rs-conformance
|
|
22
22
|
---
|
|
23
23
|
|
|
24
24
|
# share-types-with-rust
|
|
25
25
|
|
|
26
|
+
This skill exists to keep one source of truth for every type that crosses the TypeScript and Rust boundary, so the Rust side is always generated from Effect Schema and never drifts or gets copied by hand.
|
|
27
|
+
|
|
26
28
|
Effect Schema is the source of truth. Rust never declares a type that crosses the boundary. It imports the module that effect2rs generates.
|
|
27
29
|
|
|
28
30
|
## Add or change a shared type
|
|
@@ -88,3 +90,5 @@ specta needs its `serde_json` feature when a type contains `Schema.Unknown`.
|
|
|
88
90
|
|
|
89
91
|
When a schema needs something effect2rs does not support, extend effect2rs instead of writing the type by hand.
|
|
90
92
|
Add a case to its tests and to the conformance samples at the same time.
|
|
93
|
+
|
|
94
|
+
This skill describes [`src/app`](../../src/app), [`src/entities/rust-item`](../../src/entities/rust-item), [`src/features/check-rust`](../../src/features/check-rust), [`src/features/render-rust`](../../src/features/render-rust) and [`effect2rs-conformance`](../../effect2rs-conformance).
|
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: trace-workers
|
|
3
3
|
description: >
|
|
4
|
-
Use when adding application spans to Cloudflare Workers traces with
|
|
5
|
-
withWorkersTracing for Alchemy
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
Use when adding application spans to Cloudflare Workers traces with
|
|
5
|
+
@r_masseater/masseater-utils/workers-tracing: withWorkersTracing for Alchemy
|
|
6
|
+
stacks, TanStack Start and Elysia middleware, running Effect programs so
|
|
7
|
+
withSpan and fn become spans, browser spans and logs, runWorkersAi, traceSink
|
|
8
|
+
and the workers-traces command that checks spans in CI.
|
|
8
9
|
metadata:
|
|
9
10
|
type: core
|
|
10
11
|
library: "@r_masseater/masseater-utils"
|
|
11
|
-
library_version: 0.1
|
|
12
|
+
library_version: 0.11.1
|
|
12
13
|
sources:
|
|
13
|
-
- src/app
|
|
14
|
-
- src/features/sink-traces
|
|
15
|
-
- src/features/receive-browser
|
|
16
|
-
- src/entities/log
|
|
17
|
-
- src/entities/span
|
|
18
|
-
- bin
|
|
14
|
+
- src/app
|
|
15
|
+
- src/features/sink-traces
|
|
16
|
+
- src/features/receive-browser
|
|
17
|
+
- src/entities/log
|
|
18
|
+
- src/entities/span
|
|
19
|
+
- bin
|
|
19
20
|
- README.md
|
|
20
21
|
---
|
|
21
22
|
|
|
@@ -149,3 +150,5 @@ The `workers-traces` command comes from the separate `@r_masseater/workers-traci
|
|
|
149
150
|
- Calling `Effect.runPromise` in a Worker. The spans exist but are not attached to the request's trace.
|
|
150
151
|
- Adding a tracer layer from `@effect/opentelemetry` as well. Workers already exports the trace, and a second exporter duplicates spans.
|
|
151
152
|
- Expecting spans on the Workers Free plan. Traces are not kept there.
|
|
153
|
+
|
|
154
|
+
This skill describes [`src/app`](../../src/app), [`src/features/sink-traces`](../../src/features/sink-traces), [`src/features/receive-browser`](../../src/features/receive-browser), [`src/entities/log`](../../src/entities/log), [`src/entities/span`](../../src/entities/span), [`bin`](../../bin) and [`README.md`](../../README.md).
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: use-model-server
|
|
3
3
|
description: >
|
|
4
|
-
Use when a Claude Code plugin hook or script needs a local model, such as text
|
|
5
|
-
search: the model-server subpath of
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
Use when a Claude Code plugin hook or script needs a local model, such as text
|
|
5
|
+
embeddings for search: the model-server subpath of
|
|
6
|
+
@r_masseater/masseater-utils runs one resident process per user that every
|
|
7
|
+
plugin shares, started on the first call and stopped when idle. Covers embed,
|
|
8
|
+
warm, prepare, status and the EmbeddingGemma 2 prefixes.
|
|
8
9
|
metadata:
|
|
9
10
|
type: core
|
|
10
11
|
library: "@r_masseater/masseater-utils"
|
|
12
|
+
library_version: 0.11.1
|
|
11
13
|
sources:
|
|
12
|
-
- src/app
|
|
14
|
+
- src/app
|
|
13
15
|
- src/entities/embedding/model/text.ts
|
|
14
16
|
---
|
|
15
17
|
|
|
@@ -48,3 +50,5 @@ const score = dot(query, documents[0]);
|
|
|
48
50
|
- Call `warm({})` from `SessionStart`. It returns at once and the server loads the model in the background.
|
|
49
51
|
- In `UserPromptSubmit` or `PostToolUse`, pass a short `timeoutMillis` and fall back to something without the model when `embed` rejects. The first run of a machine installs the runtime and downloads the model, which takes minutes.
|
|
50
52
|
- `status({})` says whether a server runs and which models it holds, without starting one.
|
|
53
|
+
|
|
54
|
+
This skill describes [`src/app`](../../src/app) and [`src/entities/embedding/model/text.ts`](../../src/entities/embedding/model/text.ts).
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: write-actions-steps
|
|
3
3
|
description: >
|
|
4
|
-
Use when a GitHub Actions step is written in TypeScript with Effect and must
|
|
5
|
-
of its own repository, write GITHUB_OUTPUT or GITHUB_ENV,
|
|
6
|
-
a
|
|
7
|
-
|
|
4
|
+
Use when a GitHub Actions step is written in TypeScript with Effect and must
|
|
5
|
+
call the GitHub API of its own repository, write GITHUB_OUTPUT or GITHUB_ENV,
|
|
6
|
+
mask a value, emit annotations, or run a command: getJson, postJson, post,
|
|
7
|
+
patch, remove, writeOutputs, setEnv, mask, warn, fail, succeeds, mustSucceed,
|
|
8
|
+
outputOf, finished and sha256Of.
|
|
8
9
|
metadata:
|
|
9
10
|
type: core
|
|
10
11
|
library: "@r_masseater/masseater-utils"
|
|
12
|
+
library_version: 0.11.1
|
|
11
13
|
sources:
|
|
12
|
-
- src/app
|
|
13
|
-
- src/shared/api/github
|
|
14
|
+
- src/app
|
|
15
|
+
- src/shared/api/github
|
|
14
16
|
- src/shared/lib/workflow.ts
|
|
15
17
|
- src/shared/lib/process.ts
|
|
16
18
|
- src/shared/lib/digest.ts
|
|
@@ -74,3 +76,5 @@ getJson(Issue)("issues/1", { token });
|
|
|
74
76
|
```
|
|
75
77
|
|
|
76
78
|
Correct: set `GH_TOKEN` in the step's `env` and call `getJson(Issue)("issues/1")`.
|
|
79
|
+
|
|
80
|
+
This skill describes [`src/app`](../../src/app), [`src/shared/api/github`](../../src/shared/api/github), [`src/shared/lib/workflow.ts`](../../src/shared/lib/workflow.ts), [`src/shared/lib/process.ts`](../../src/shared/lib/process.ts), [`src/shared/lib/digest.ts`](../../src/shared/lib/digest.ts) and [`README.md`](../../README.md).
|