@lumpcode/cli-utils 0.0.12 → 0.0.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.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @lumpcode/cli-utils
2
2
 
3
- Published npm package: **types**, **`define*` helpers**, and **runtime utilities** for authoring Lumpcode lump configs and recipes.
3
+ **Types**, **`define*` helpers**, and **runtime utilities** for authoring Lumpcode lump configs and recipes.
4
4
 
5
5
  Re-exports all of [`@lumpcode/cli-types`](https://www.npmjs.com/package/@lumpcode/cli-types) plus runtime helpers bundled from `@lumpcode/cli` sources at build time (`cli-types` stays an external dependency at publish).
6
6
 
@@ -15,9 +15,28 @@ npm install @lumpcode/cli-utils
15
15
  ## Usage
16
16
 
17
17
  ```ts
18
- import { defineConfig, normalizeSteps, type LumpJsConfig } from '@lumpcode/cli-utils';
18
+ import {
19
+ defineConfig,
20
+ normalizeSteps,
21
+ type CursorPresetLumpVariables,
22
+ type CursorPresetStepVariables,
23
+ type LumpJsConfig,
24
+ type StepFn,
25
+ } from '@lumpcode/cli-utils';
26
+
27
+ export default defineConfig<
28
+ CursorPresetLumpVariables & { myHookFlag: boolean },
29
+ CursorPresetStepVariables & { myHookFlag: boolean }
30
+ >({
31
+ baseBranch: 'main',
32
+ command: 'cursor',
33
+ lumpVariables: { model: 'auto', myHookFlag: true },
34
+ steps: [{ promptTemplate: 'Do the work.', stepVariables: { newChat: true } }],
35
+ });
19
36
  ```
20
37
 
38
+ `defineConfig` (and the other variable-carrying `define*` helpers) take independent generics `<V, SV>` for lump and step variable bags. Preset option contracts (`CursorPreset*`, `CopilotPreset*`, `PresetSessionStepVariables`, …) are closed TypeScript types — intersect with your own keys via `& Extra`.
39
+
21
40
  ## Build
22
41
 
23
42
  From the monorepo root:
package/dist/index.cjs CHANGED
@@ -80,7 +80,7 @@ async function readYamlList(filePath) {
80
80
  function normalizeSteps({ prompt: originalPrompt, jsSteps: originalJsSteps, }) {
81
81
  const { prompt, jsSteps } = normalizePromptAndSteps({
82
82
  prompt: originalPrompt,
83
- jsSteps: originalJsSteps
83
+ jsSteps: originalJsSteps,
84
84
  });
85
85
  if (jsSteps && Array.isArray(jsSteps)) {
86
86
  return jsSteps;
@@ -94,6 +94,10 @@ function normalizeSteps({ prompt: originalPrompt, jsSteps: originalJsSteps, }) {
94
94
  }
95
95
  function normalizePromptAndSteps({ prompt, jsSteps, }) {
96
96
  if (jsSteps !== undefined && !Array.isArray(jsSteps)) {
97
+ // Solo dynamic steps fn must stay in the steps walk, not become promptFn.
98
+ if (typeof jsSteps === 'function') {
99
+ return { prompt, jsSteps: [jsSteps] };
100
+ }
97
101
  return { prompt: jsSteps, jsSteps: undefined };
98
102
  }
99
103
  return { prompt, jsSteps };
package/dist/index.d.ts CHANGED
@@ -1,12 +1,12 @@
1
1
  export * from '@lumpcode/cli-types';
2
- import { CodeBasePath, MaybePromise, Maybe, Context, ContextStatus, Step, PromptFn, PostCommandExecFn, PromptFnInput, LumpVariables, RunLumpInput, GitCommitMessageFn } from '@lumpcode/core';
2
+ import { LumpVariables, CodeBasePath, MaybePromise, Maybe, Context, ContextStatus, StepVariables, PromptFnInput, PostCommandExecFn, Step, PromptFn, RunLumpInput, GitCommitMessageFn } from '@lumpcode/core';
3
3
 
4
4
  type CommandTag = string;
5
5
 
6
- type ContextMatchFn = (params: {
6
+ type ContextMatchFn<V extends LumpVariables = LumpVariables> = (params: {
7
7
  codeBasePath: CodeBasePath;
8
8
  codeBasePaths: CodeBasePath[];
9
- lumpVariables: Record<string, unknown>;
9
+ lumpVariables: V;
10
10
  }) => MaybePromise<Maybe<{
11
11
  contextName: Context['name'];
12
12
  filePathVariableName: string;
@@ -29,30 +29,34 @@ type FilePathOrString = FilePath | string;
29
29
 
30
30
  type MergeObjs<T, U> = Omit<T, keyof U> & U;
31
31
 
32
- type LumpJsConfigStep = MergeObjs<Step, {
32
+ type LumpJsConfigStepsFn<V extends LumpVariables = LumpVariables, SV extends StepVariables = StepVariables> = (input: Omit<PromptFnInput<V, SV>, 'stepVariables'>) => MaybePromise<LumpJsConfigSteps<V, SV> | LumpJsConfigStepsItem<V, SV>>;
33
+ type LumpJsConfigStepsItem<V extends LumpVariables = LumpVariables, SV extends StepVariables = StepVariables> = LumpJsConfigStep<V, SV> | LumpJsConfigStepsFn<V, SV> | LumpJsConfigStep<V, SV>['promptTemplate'];
34
+ type LumpJsConfigSteps<V extends LumpVariables = LumpVariables, SV extends StepVariables = StepVariables> = Array<LumpJsConfigStepsItem<V, SV>>;
35
+
36
+ type LumpJsConfigPostCommandExecFn<V extends LumpVariables = LumpVariables, SV extends StepVariables = StepVariables> = (input: Parameters<PostCommandExecFn<V, SV>>[0]) => MaybePromise<void | LumpJsConfigSteps<V, SV> | LumpJsConfigStepsItem<V, SV>>;
37
+
38
+ type LumpJsConfigStep<V extends LumpVariables = LumpVariables, SV extends StepVariables = StepVariables> = MergeObjs<Step<V, SV>, {
33
39
  promptTemplate?: FilePathOrString;
34
- promptFn?: FilePath | PromptFn;
35
- postCommandExecFn?: FilePath | PostCommandExecFn;
36
- command?: CommandTag | FilePath | Step['commandFn'];
40
+ promptFn?: FilePath | PromptFn<V, SV>;
41
+ postCommandExecFn?: FilePath | LumpJsConfigPostCommandExecFn<V, SV>;
42
+ command?: CommandTag | FilePath | Step<V, SV>['commandFn'];
37
43
  }>;
38
44
 
39
- type LumpJsConfigSteps = Array<LumpJsConfigStep | ((input: Exclude<PromptFnInput, 'stepVariables'>) => MaybePromise<LumpJsConfigSteps>) | LumpJsConfigStep['promptTemplate']>;
40
-
41
- type LumpJsConfigSoloStep = LumpJsConfigStep | LumpJsConfigStep['promptTemplate'] | LumpJsConfigStep['promptFn'];
42
- type LumpJsConfig<V extends LumpVariables = LumpVariables> = MergeObjs<Omit<{
43
- [K in keyof RunLumpInput<V>]?: NonNullable<RunLumpInput<V>[K]> extends Function ? (RunLumpInput<V>[K] | FilePath) : RunLumpInput<V>[K];
45
+ type LumpJsConfigSoloStep<V extends LumpVariables = LumpVariables, SV extends StepVariables = StepVariables> = LumpJsConfigStep<V, SV> | LumpJsConfigStep<V, SV>['promptTemplate'] | LumpJsConfigStep<V, SV>['promptFn'];
46
+ type LumpJsConfig<V extends LumpVariables = LumpVariables, SV extends StepVariables = StepVariables> = MergeObjs<Omit<{
47
+ [K in keyof RunLumpInput<V, SV>]?: NonNullable<RunLumpInput<V, SV>[K]> extends Function ? (RunLumpInput<V, SV>[K] | FilePath) : RunLumpInput<V, SV>[K];
44
48
  }, 'gitCommitMessageFn' | 'projectRoot' | 'branchFn' | 'baseBranch' | 'setupWorkspaceFn' | 'teardownWorkspaceFn' | 'gitAddCommandFn' | 'gitCommitCommandFn' | 'gitPushCommandFn'>, {
45
- baseBranch?: RunLumpInput<V>['baseBranch'];
49
+ baseBranch?: RunLumpInput<V, SV>['baseBranch'];
46
50
  /** Which integration line this lump is discovered and scheduled on (defaults to primary branch from local.json). */
47
51
  discoveryBranch?: string;
48
- command?: LumpJsConfigStep['command'];
52
+ command?: LumpJsConfigStep<V, SV>['command'];
49
53
  contextListJson?: FilePath | Record<string, string>;
50
- contextMatchFn?: FilePath | ContextMatchFn;
54
+ contextMatchFn?: FilePath | ContextMatchFn<V>;
51
55
  contextOptionsFn?: FilePath | ContextOptionsFn;
52
56
  disabled?: boolean | (() => MaybePromise<boolean>) | FilePath;
53
57
  maximumNumberOfConcurrentBranches?: number;
54
- prompt?: LumpJsConfigSoloStep;
55
- steps?: LumpJsConfigSteps | LumpJsConfigSoloStep;
58
+ prompt?: LumpJsConfigSoloStep<V, SV>;
59
+ steps?: LumpJsConfigSteps<V, SV> | LumpJsConfigStepsItem<V, SV>;
56
60
  registerCommands?: string[];
57
61
  keepHistory?: boolean;
58
62
  verbose?: boolean;
@@ -78,9 +82,68 @@ declare function getLumpCommitPrefixForLump(input: {
78
82
  /** Reads a YAML file as a flat list; returns `[]` when missing or not an array. */
79
83
  declare function readYamlList<T>(filePath: string): Promise<T[]>;
80
84
 
81
- declare function normalizeSteps({ prompt: originalPrompt, jsSteps: originalJsSteps, }: {
82
- prompt: LumpJsConfig['prompt'];
83
- jsSteps: LumpJsConfig['steps'];
84
- }): LumpJsConfigSteps;
85
+ declare function normalizeSteps<V extends LumpVariables = LumpVariables, SV extends StepVariables = StepVariables>({ prompt: originalPrompt, jsSteps: originalJsSteps, }: {
86
+ prompt: LumpJsConfig<V, SV>['prompt'];
87
+ jsSteps: LumpJsConfig<V, SV>['steps'];
88
+ }): LumpJsConfigSteps<V, SV>;
89
+
90
+ type PresetSessionStepVariables = {
91
+ newChat?: boolean;
92
+ chatIdIndex?: string | null;
93
+ };
94
+
95
+ type CursorAgentPermissions = {
96
+ cursorConfigDir?: string;
97
+ };
98
+ type CursorPresetLumpVariables = {
99
+ model?: string;
100
+ agentPermissions?: CursorAgentPermissions;
101
+ };
102
+ type CursorPresetStepVariables = CursorPresetLumpVariables & PresetSessionStepVariables;
103
+
104
+ type CopilotAgentPermissions = {
105
+ writablePaths?: readonly string[];
106
+ denyShell?: readonly string[];
107
+ };
108
+ type CopilotPresetLumpVariables = {
109
+ model?: string;
110
+ agentPermissions?: CopilotAgentPermissions;
111
+ };
112
+ type CopilotPresetStepVariables = CopilotPresetLumpVariables & PresetSessionStepVariables;
113
+
114
+ type ClaudeCodeAgentPermissions = {
115
+ permissionMode?: 'default' | 'acceptEdits' | 'plan' | 'auto' | 'dontAsk' | 'bypassPermissions';
116
+ allowedTools?: readonly string[];
117
+ disallowedTools?: readonly string[];
118
+ bare?: boolean;
119
+ addDirs?: readonly string[];
120
+ };
121
+ type ClaudeCodePresetLumpVariables = {
122
+ model?: string;
123
+ agentPermissions?: ClaudeCodeAgentPermissions;
124
+ };
125
+ type ClaudeCodePresetStepVariables = ClaudeCodePresetLumpVariables & PresetSessionStepVariables;
126
+
127
+ type OpenCodeAgentPermissions = {
128
+ auto?: boolean;
129
+ agent?: string;
130
+ };
131
+ type OpenCodePresetLumpVariables = {
132
+ model?: string;
133
+ agentPermissions?: OpenCodeAgentPermissions;
134
+ };
135
+ type OpenCodePresetStepVariables = OpenCodePresetLumpVariables & PresetSessionStepVariables;
136
+
137
+ type CodexAgentPermissions = {
138
+ sandbox?: 'read-only' | 'workspace-write' | 'danger-full-access';
139
+ dangerouslyBypassApprovalsAndSandbox?: boolean;
140
+ addDirs?: readonly string[];
141
+ };
142
+ type CodexPresetLumpVariables = {
143
+ model?: string;
144
+ agentPermissions?: CodexAgentPermissions;
145
+ };
146
+ type CodexPresetStepVariables = CodexPresetLumpVariables & PresetSessionStepVariables;
85
147
 
86
148
  export { getContextStatus, getGitCommitMessage, getLumpCommitPrefixForLump, makeGitCommitMessageFnFromLumpName, normalizeSteps, readYamlList };
149
+ export type { ClaudeCodeAgentPermissions, ClaudeCodePresetLumpVariables, ClaudeCodePresetStepVariables, CodexAgentPermissions, CodexPresetLumpVariables, CodexPresetStepVariables, CopilotAgentPermissions, CopilotPresetLumpVariables, CopilotPresetStepVariables, CursorAgentPermissions, CursorPresetLumpVariables, CursorPresetStepVariables, OpenCodeAgentPermissions, OpenCodePresetLumpVariables, OpenCodePresetStepVariables, PresetSessionStepVariables };
package/dist/index.js CHANGED
@@ -57,7 +57,7 @@ async function readYamlList(filePath) {
57
57
  function normalizeSteps({ prompt: originalPrompt, jsSteps: originalJsSteps, }) {
58
58
  const { prompt, jsSteps } = normalizePromptAndSteps({
59
59
  prompt: originalPrompt,
60
- jsSteps: originalJsSteps
60
+ jsSteps: originalJsSteps,
61
61
  });
62
62
  if (jsSteps && Array.isArray(jsSteps)) {
63
63
  return jsSteps;
@@ -71,6 +71,10 @@ function normalizeSteps({ prompt: originalPrompt, jsSteps: originalJsSteps, }) {
71
71
  }
72
72
  function normalizePromptAndSteps({ prompt, jsSteps, }) {
73
73
  if (jsSteps !== undefined && !Array.isArray(jsSteps)) {
74
+ // Solo dynamic steps fn must stay in the steps walk, not become promptFn.
75
+ if (typeof jsSteps === 'function') {
76
+ return { prompt, jsSteps: [jsSteps] };
77
+ }
74
78
  return { prompt: jsSteps, jsSteps: undefined };
75
79
  }
76
80
  return { prompt, jsSteps };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lumpcode/cli-utils",
3
- "version": "0.0.12",
3
+ "version": "0.0.14",
4
4
  "description": "Types, defineX helpers, and runtime utilities for Lumpcode lump configs and recipes",
5
5
  "keywords": [
6
6
  "lumpcode",
@@ -39,11 +39,12 @@
39
39
  "scripts": {
40
40
  "prepublishOnly": "npm run build",
41
41
  "clean": "rm -rf dist",
42
- "build": "rollup -c"
42
+ "build": "rollup -c",
43
+ "test": "vitest run"
43
44
  },
44
45
  "dependencies": {
45
- "@lumpcode/cli-types": "^0.0.12",
46
- "@lumpcode/core": "^0.0.12",
46
+ "@lumpcode/cli-types": "^0.0.14",
47
+ "@lumpcode/core": "^0.0.14",
47
48
  "js-yaml": "^5.0.0"
48
49
  },
49
50
  "devDependencies": {
@@ -53,6 +54,7 @@
53
54
  "rollup": "^4.52.5",
54
55
  "rollup-plugin-dts": "^6.1.1",
55
56
  "tslib": "^2.8.1",
56
- "typescript": "^5.7.2"
57
+ "typescript": "^5.7.2",
58
+ "vitest": "^3.2.4"
57
59
  }
58
60
  }