@cullit/config 0.1.0 → 0.3.0
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/index.d.ts +56 -0
- package/dist/index.js +22 -14
- package/package.json +5 -2
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
type AIProvider = 'anthropic' | 'openai' | 'gemini' | 'ollama' | 'openclaw' | 'none';
|
|
2
|
+
type Audience = 'developer' | 'end-user' | 'executive';
|
|
3
|
+
type Tone = 'professional' | 'casual' | 'terse';
|
|
4
|
+
type OutputFormat = 'markdown' | 'html' | 'json';
|
|
5
|
+
type PublisherType = 'stdout' | 'github-release' | 'slack' | 'discord' | 'file';
|
|
6
|
+
type EnrichmentType = 'jira' | 'linear';
|
|
7
|
+
interface AIConfig {
|
|
8
|
+
provider: AIProvider;
|
|
9
|
+
model?: string;
|
|
10
|
+
apiKey?: string;
|
|
11
|
+
audience: Audience;
|
|
12
|
+
tone: Tone;
|
|
13
|
+
categories: string[];
|
|
14
|
+
maxTokens?: number;
|
|
15
|
+
}
|
|
16
|
+
interface SourceConfig {
|
|
17
|
+
type: 'local' | 'jira' | 'linear';
|
|
18
|
+
owner?: string;
|
|
19
|
+
repo?: string;
|
|
20
|
+
enrichment?: EnrichmentType[];
|
|
21
|
+
}
|
|
22
|
+
interface PublishTarget {
|
|
23
|
+
type: PublisherType;
|
|
24
|
+
channel?: string;
|
|
25
|
+
webhookUrl?: string;
|
|
26
|
+
path?: string;
|
|
27
|
+
}
|
|
28
|
+
interface JiraConfig {
|
|
29
|
+
domain: string;
|
|
30
|
+
email?: string;
|
|
31
|
+
apiToken?: string;
|
|
32
|
+
}
|
|
33
|
+
interface LinearConfig {
|
|
34
|
+
apiKey?: string;
|
|
35
|
+
}
|
|
36
|
+
interface OpenClawConfig {
|
|
37
|
+
baseUrl?: string;
|
|
38
|
+
token?: string;
|
|
39
|
+
}
|
|
40
|
+
interface CullConfig {
|
|
41
|
+
ai: AIConfig;
|
|
42
|
+
source: SourceConfig;
|
|
43
|
+
publish: PublishTarget[];
|
|
44
|
+
jira?: JiraConfig;
|
|
45
|
+
linear?: LinearConfig;
|
|
46
|
+
openclaw?: OpenClawConfig;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Loads config from .cullit.yml in the project root.
|
|
51
|
+
* Falls back to sensible defaults.
|
|
52
|
+
* Resolves environment variable references ($ENV_VAR syntax).
|
|
53
|
+
*/
|
|
54
|
+
declare function loadConfig(cwdOrPath?: string): CullConfig;
|
|
55
|
+
|
|
56
|
+
export { type AIConfig, type AIProvider, type Audience, type CullConfig, type EnrichmentType, type JiraConfig, type LinearConfig, type OpenClawConfig, type OutputFormat, type PublishTarget, type PublisherType, type SourceConfig, type Tone, loadConfig };
|
package/dist/index.js
CHANGED
|
@@ -1,33 +1,28 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
2
|
import { readFileSync, existsSync } from "fs";
|
|
3
3
|
import { join } from "path";
|
|
4
|
+
var DEFAULT_CATEGORIES = ["features", "fixes", "breaking", "improvements", "chores"];
|
|
4
5
|
var DEFAULT_CONFIG = {
|
|
5
6
|
ai: {
|
|
6
7
|
provider: "anthropic",
|
|
7
8
|
audience: "developer",
|
|
8
9
|
tone: "professional",
|
|
9
|
-
categories:
|
|
10
|
+
categories: DEFAULT_CATEGORIES
|
|
10
11
|
},
|
|
11
12
|
source: {
|
|
12
13
|
type: "local"
|
|
13
14
|
},
|
|
14
15
|
publish: [{ type: "stdout" }]
|
|
15
16
|
};
|
|
16
|
-
function loadConfig(
|
|
17
|
-
const configPath = join(
|
|
17
|
+
function loadConfig(cwdOrPath = process.cwd()) {
|
|
18
|
+
const configPath = cwdOrPath.endsWith(".yml") || cwdOrPath.endsWith(".yaml") ? cwdOrPath : join(cwdOrPath, ".cullit.yml");
|
|
18
19
|
if (!existsSync(configPath)) {
|
|
19
20
|
return DEFAULT_CONFIG;
|
|
20
21
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
return mergeWithDefaults(resolved);
|
|
26
|
-
} catch (err) {
|
|
27
|
-
console.warn(`\u26A0 Could not parse .cullit.yml: ${err.message}`);
|
|
28
|
-
console.warn("Using default configuration.");
|
|
29
|
-
return DEFAULT_CONFIG;
|
|
30
|
-
}
|
|
22
|
+
const raw = readFileSync(configPath, "utf-8");
|
|
23
|
+
const parsed = parseSimpleYaml(raw);
|
|
24
|
+
const resolved = resolveEnvVars(parsed);
|
|
25
|
+
return mergeWithDefaults(resolved);
|
|
31
26
|
}
|
|
32
27
|
function parseSimpleYaml(raw) {
|
|
33
28
|
const result = {};
|
|
@@ -106,6 +101,10 @@ function parseSimpleYaml(raw) {
|
|
|
106
101
|
return result;
|
|
107
102
|
}
|
|
108
103
|
function parseValue(val) {
|
|
104
|
+
if (!val.startsWith('"') && !val.startsWith("'") && !val.startsWith("[")) {
|
|
105
|
+
const commentIdx = val.indexOf(" #");
|
|
106
|
+
if (commentIdx > 0) val = val.substring(0, commentIdx).trim();
|
|
107
|
+
}
|
|
109
108
|
if (val === "true") return true;
|
|
110
109
|
if (val === "false") return false;
|
|
111
110
|
if (val === "null") return null;
|
|
@@ -143,12 +142,21 @@ function mergeWithDefaults(parsed) {
|
|
|
143
142
|
...DEFAULT_CONFIG.source,
|
|
144
143
|
...parsed.source || {}
|
|
145
144
|
},
|
|
146
|
-
publish: parsed.publish || DEFAULT_CONFIG.publish,
|
|
145
|
+
publish: normalizePublishTargets(parsed.publish || DEFAULT_CONFIG.publish),
|
|
147
146
|
jira: parsed.jira,
|
|
148
147
|
linear: parsed.linear,
|
|
149
148
|
openclaw: parsed.openclaw
|
|
150
149
|
};
|
|
151
150
|
}
|
|
151
|
+
function normalizePublishTargets(targets) {
|
|
152
|
+
return targets.map((t) => {
|
|
153
|
+
const normalized = { type: t.type };
|
|
154
|
+
if (t.webhookUrl || t.webhook_url) normalized.webhookUrl = t.webhookUrl || t.webhook_url;
|
|
155
|
+
if (t.channel) normalized.channel = t.channel;
|
|
156
|
+
if (t.path) normalized.path = t.path;
|
|
157
|
+
return normalized;
|
|
158
|
+
});
|
|
159
|
+
}
|
|
152
160
|
export {
|
|
153
161
|
loadConfig
|
|
154
162
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cullit/config",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Config loader for Cullit — YAML config parsing with env var resolution.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -21,8 +21,11 @@
|
|
|
21
21
|
"files": [
|
|
22
22
|
"dist"
|
|
23
23
|
],
|
|
24
|
+
"engines": {
|
|
25
|
+
"node": ">=18"
|
|
26
|
+
},
|
|
24
27
|
"scripts": {
|
|
25
|
-
"build": "tsup src/index.ts --format esm --clean",
|
|
28
|
+
"build": "tsup src/index.ts --format esm --dts --clean",
|
|
26
29
|
"dev": "tsup src/index.ts --format esm --watch"
|
|
27
30
|
}
|
|
28
31
|
}
|