@lmctl-ai/lmctl 0.2.12 → 0.2.14

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.
@@ -0,0 +1,36 @@
1
+ import type { CliIo } from './common.js';
2
+ export interface SaveScriptRequest {
3
+ destPath: string;
4
+ /** Resolved script name, e.g. "plan" (default) or "plan-minimal" (--script). */
5
+ slug: string;
6
+ force: boolean;
7
+ }
8
+ export interface ExtractSaveScriptResult {
9
+ rest: string[];
10
+ request?: SaveScriptRequest;
11
+ error?: string;
12
+ }
13
+ /**
14
+ * Strips --save-script <file>, --script <slug>, and (unless the command
15
+ * already owns --force itself, e.g. `plan`) a bare --force from args.
16
+ * --script only makes sense paired with --save-script.
17
+ */
18
+ export declare function extractSaveScriptFlags(args: string[], command: string, opts?: {
19
+ ownsForce?: boolean;
20
+ }): ExtractSaveScriptResult;
21
+ /**
22
+ * Fetches https://lmctl.com/lmscript/commands/<slug>.lms and writes it to
23
+ * request.destPath. Verifies the full response BEFORE writing anything --
24
+ * a failed fetch, a 404, or an HTML page (offline/misconfigured host
25
+ * fallback) never reaches the destination file, half-written or otherwise.
26
+ */
27
+ export declare function performSaveScript(io: CliIo, request: SaveScriptRequest, fetchFn?: typeof fetch): Promise<number>;
28
+ /**
29
+ * Wraps a command's own run function with --save-script handling: strips
30
+ * the flags, runs the command UNCHANGED with the remaining args, and -- only
31
+ * if the command itself succeeded -- fetches and writes the script as an
32
+ * additive side effect. A failed command is left alone; nothing is fetched.
33
+ */
34
+ export declare function runWithSaveScript(io: CliIo, command: string, args: string[], runCommand: (rest: string[]) => Promise<number>, opts?: {
35
+ ownsForce?: boolean;
36
+ }): Promise<number>;