@slowcook-ai/cli 0.13.0 → 0.14.0-alpha.5
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/cli.js +9 -0
- package/dist/cli.js.map +1 -1
- package/dist/commands/brew/prompts.d.ts +3 -290
- package/dist/commands/brew/prompts.d.ts.map +1 -1
- package/dist/commands/brew/prompts.js +3 -462
- package/dist/commands/brew/prompts.js.map +1 -1
- package/dist/commands/extract/index.d.ts +2 -0
- package/dist/commands/extract/index.d.ts.map +1 -0
- package/dist/commands/extract/index.js +90 -0
- package/dist/commands/extract/index.js.map +1 -0
- package/dist/commands/init/templates.d.ts.map +1 -1
- package/dist/commands/init/templates.js +4 -0
- package/dist/commands/init/templates.js.map +1 -1
- package/dist/commands/investigate/prompts.d.ts +7 -87
- package/dist/commands/investigate/prompts.d.ts.map +1 -1
- package/dist/commands/investigate/prompts.js +7 -234
- package/dist/commands/investigate/prompts.js.map +1 -1
- package/dist/commands/map/emit-tokens.d.ts +53 -0
- package/dist/commands/map/emit-tokens.d.ts.map +1 -0
- package/dist/commands/map/emit-tokens.js +316 -0
- package/dist/commands/map/emit-tokens.js.map +1 -0
- package/dist/commands/map/index.d.ts +17 -0
- package/dist/commands/map/index.d.ts.map +1 -1
- package/dist/commands/map/index.js +72 -5
- package/dist/commands/map/index.js.map +1 -1
- package/dist/commands/refine/agent.d.ts.map +1 -1
- package/dist/commands/refine/agent.js +21 -0
- package/dist/commands/refine/agent.js.map +1 -1
- package/dist/commands/refine/context.d.ts +11 -0
- package/dist/commands/refine/context.d.ts.map +1 -1
- package/dist/commands/refine/context.js +45 -0
- package/dist/commands/refine/context.js.map +1 -1
- package/dist/commands/refine/mock-fixtures.d.ts +39 -0
- package/dist/commands/refine/mock-fixtures.d.ts.map +1 -0
- package/dist/commands/refine/mock-fixtures.js +86 -0
- package/dist/commands/refine/mock-fixtures.js.map +1 -0
- package/dist/commands/refine/prompts.d.ts +10 -21
- package/dist/commands/refine/prompts.d.ts.map +1 -1
- package/dist/commands/refine/prompts.js +10 -376
- package/dist/commands/refine/prompts.js.map +1 -1
- package/dist/commands/refine/proposals-synth.d.ts +9 -1
- package/dist/commands/refine/proposals-synth.d.ts.map +1 -1
- package/dist/commands/refine/proposals-synth.js +488 -22
- package/dist/commands/refine/proposals-synth.js.map +1 -1
- package/dist/commands/refine/spec-yaml.d.ts +306 -128
- package/dist/commands/refine/spec-yaml.d.ts.map +1 -1
- package/dist/commands/refine/spec-yaml.js +33 -0
- package/dist/commands/refine/spec-yaml.js.map +1 -1
- package/dist/commands/sift/prompts.d.ts +3 -111
- package/dist/commands/sift/prompts.d.ts.map +1 -1
- package/dist/commands/sift/prompts.js +3 -190
- package/dist/commands/sift/prompts.js.map +1 -1
- package/dist/commands/testgen/prompts.d.ts +3 -13
- package/dist/commands/testgen/prompts.d.ts.map +1 -1
- package/dist/commands/testgen/prompts.js +3 -384
- package/dist/commands/testgen/prompts.js.map +1 -1
- package/package.json +4 -4
|
@@ -1,90 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* refine investigate
|
|
9
|
-
* ────── ───────────
|
|
10
|
-
* "what to build" "what's broken"
|
|
11
|
-
* text-only code-reading
|
|
12
|
-
* 2-3 questions 0-1 questions (only on truly ambiguous symptoms)
|
|
13
|
-
* spec.yaml bug-profile.yaml
|
|
14
|
-
*
|
|
15
|
-
* The system prompt below names the role explicitly so the LLM
|
|
16
|
-
* doesn't drift back into refine-style behaviour (asking design
|
|
17
|
-
* questions about a 1-line column rename, etc.).
|
|
2
|
+
* Re-export shim — the actual prompt strings + tool defs live in
|
|
3
|
+
* `@slowcook-ai/llm-anthropic` as of 0.13.1 (per the llm-agnosticism
|
|
4
|
+
* refactor). Kept as a passthrough so internal imports
|
|
5
|
+
* (`from "./prompts.js"`) keep working without touching every agent
|
|
6
|
+
* file. A future GPT / Gemini adapter package would publish drop-in
|
|
7
|
+
* replacements with the same exported names.
|
|
18
8
|
*/
|
|
19
|
-
export
|
|
20
|
-
/**
|
|
21
|
-
* Tool definitions the investigate agent has access to. Mirrors the
|
|
22
|
-
* brew read-only subset (no write_file): investigate diagnoses, sift
|
|
23
|
-
* fixes.
|
|
24
|
-
*
|
|
25
|
-
* Kept minimal in alpha.2a — alpha.2b wires the actual ts-morph
|
|
26
|
-
* implementations from brew/retrieval.ts.
|
|
27
|
-
*/
|
|
28
|
-
export declare const INVESTIGATE_TOOLS: ({
|
|
29
|
-
name: string;
|
|
30
|
-
description: string;
|
|
31
|
-
input_schema: {
|
|
32
|
-
type: "object";
|
|
33
|
-
properties: {
|
|
34
|
-
path: {
|
|
35
|
-
type: "string";
|
|
36
|
-
description: string;
|
|
37
|
-
};
|
|
38
|
-
symbol?: undefined;
|
|
39
|
-
pattern?: undefined;
|
|
40
|
-
glob?: undefined;
|
|
41
|
-
};
|
|
42
|
-
required: string[];
|
|
43
|
-
};
|
|
44
|
-
} | {
|
|
45
|
-
name: string;
|
|
46
|
-
description: string;
|
|
47
|
-
input_schema: {
|
|
48
|
-
type: "object";
|
|
49
|
-
properties: {
|
|
50
|
-
symbol: {
|
|
51
|
-
type: "string";
|
|
52
|
-
description: string;
|
|
53
|
-
};
|
|
54
|
-
path?: undefined;
|
|
55
|
-
pattern?: undefined;
|
|
56
|
-
glob?: undefined;
|
|
57
|
-
};
|
|
58
|
-
required: string[];
|
|
59
|
-
};
|
|
60
|
-
} | {
|
|
61
|
-
name: string;
|
|
62
|
-
description: string;
|
|
63
|
-
input_schema: {
|
|
64
|
-
type: "object";
|
|
65
|
-
properties: {
|
|
66
|
-
pattern: {
|
|
67
|
-
type: "string";
|
|
68
|
-
description: string;
|
|
69
|
-
};
|
|
70
|
-
glob: {
|
|
71
|
-
type: "string";
|
|
72
|
-
description: string;
|
|
73
|
-
};
|
|
74
|
-
path?: undefined;
|
|
75
|
-
symbol?: undefined;
|
|
76
|
-
};
|
|
77
|
-
required: string[];
|
|
78
|
-
};
|
|
79
|
-
})[];
|
|
80
|
-
/**
|
|
81
|
-
* Build the per-issue user message. The issue body becomes the
|
|
82
|
-
* agent's primary input; it tools its way out from there.
|
|
83
|
-
*/
|
|
84
|
-
export declare function buildInvestigateUserPrompt(args: {
|
|
85
|
-
issueNumber: number;
|
|
86
|
-
issueTitle: string;
|
|
87
|
-
issueBody: string;
|
|
88
|
-
prior_comments?: string[];
|
|
89
|
-
}): string;
|
|
9
|
+
export { INVESTIGATE_SYSTEM, INVESTIGATE_TOOLS, buildInvestigateUserPrompt, } from "@slowcook-ai/llm-anthropic";
|
|
90
10
|
//# sourceMappingURL=prompts.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../../../src/commands/investigate/prompts.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../../../src/commands/investigate/prompts.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,0BAA0B,GAC3B,MAAM,4BAA4B,CAAC"}
|
|
@@ -1,237 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* refine investigate
|
|
9
|
-
* ────── ───────────
|
|
10
|
-
* "what to build" "what's broken"
|
|
11
|
-
* text-only code-reading
|
|
12
|
-
* 2-3 questions 0-1 questions (only on truly ambiguous symptoms)
|
|
13
|
-
* spec.yaml bug-profile.yaml
|
|
14
|
-
*
|
|
15
|
-
* The system prompt below names the role explicitly so the LLM
|
|
16
|
-
* doesn't drift back into refine-style behaviour (asking design
|
|
17
|
-
* questions about a 1-line column rename, etc.).
|
|
2
|
+
* Re-export shim — the actual prompt strings + tool defs live in
|
|
3
|
+
* `@slowcook-ai/llm-anthropic` as of 0.13.1 (per the llm-agnosticism
|
|
4
|
+
* refactor). Kept as a passthrough so internal imports
|
|
5
|
+
* (`from "./prompts.js"`) keep working without touching every agent
|
|
6
|
+
* file. A future GPT / Gemini adapter package would publish drop-in
|
|
7
|
+
* replacements with the same exported names.
|
|
18
8
|
*/
|
|
19
|
-
export
|
|
20
|
-
|
|
21
|
-
## Your role
|
|
22
|
-
|
|
23
|
-
You receive a GitHub issue describing a bug. Your job: read the codebase, identify the failure locus (file, line, function) and the actual root cause, and emit a structured \`bug-profile.yaml\` that the next agent (sift) will use as its contract.
|
|
24
|
-
|
|
25
|
-
You are NOT refine. Refine asks PM clarifying questions and emits design specs. You investigate failed reality. Different posture, different tools, different output.
|
|
26
|
-
|
|
27
|
-
## Posture
|
|
28
|
-
|
|
29
|
-
- **Read the code.** The issue body tells you the symptom. The codebase tells you the cause. You have read tools — use them. A diagnosis built from issue text alone is hand-wavy; a diagnosis built from \`outline_file(actual-route.ts)\` + \`find_references(broken-symbol)\` + \`grep -r 'thing_X'\` is honest.
|
|
30
|
-
- **Don't paraphrase the symptom.** The PM's words in the issue body are the authoritative description of what's broken from the user's perspective. Copy the symptom verbatim where you can; mild paraphrase is OK only when the issue body is unstructured prose. (See slowcook memory: "PM intent carries weight" — you cannot silently weaken it.)
|
|
31
|
-
- **Don't suggest a fix.** Your output names the failure locus + the regression assertion. The actual code change is sift's job. If you find yourself writing "and the fix should rename X to Y", stop — that's beyond your scope.
|
|
32
|
-
- **Ask only when truly stuck.** Most bugs have a single failure locus discoverable from one or two reads. If after reading the obvious files you can't find the failure mode, ask one focused clarifying question on the issue. Do NOT ask multiple rounds of questions like refine does.
|
|
33
|
-
|
|
34
|
-
## Critical: read the code, NOT just the issue body
|
|
35
|
-
|
|
36
|
-
Issue bodies often contain BOTH the symptom *and* the reporter's proposed fix ("Expected fix: ..."). The proposed fix is a hypothesis — it has not been verified or applied to the codebase. Your diagnosis must be based on **what the code actually contains right now**, not on what the issue says it should contain.
|
|
37
|
-
|
|
38
|
-
Concrete rule: before claiming "X is fixed" or "Y now does Z", read X or Y with a tool. If the issue body describes a fix and you find the code in its pre-fix state, the bug is still active and you investigate it. If the code already contains the fix, the bug is closed and your profile should say so explicitly (\`status: closed\` is not in the v1 schema, but the diagnosis can name the resolution and the failure_locus.diagnosis can read "bug already fixed in <commit/PR>").
|
|
39
|
-
|
|
40
|
-
## Output
|
|
41
|
-
|
|
42
|
-
A single \`bug-profile.yaml\` document with these fields:
|
|
43
|
-
|
|
44
|
-
\`\`\`yaml
|
|
45
|
-
schema_version: 1
|
|
46
|
-
bug_id: B-<n> # filled in by slowcook, you don't pick this
|
|
47
|
-
title: "<one-line bug title>"
|
|
48
|
-
source_issue: "#<NNN>" # the issue you investigated
|
|
49
|
-
status: investigated
|
|
50
|
-
investigated_by: slowcook-investigate@<version>
|
|
51
|
-
created_at: <ISO-8601 UTC>
|
|
52
|
-
|
|
53
|
-
symptom:
|
|
54
|
-
- "<verbatim or near-verbatim from issue body — what the user sees>"
|
|
55
|
-
|
|
56
|
-
expected:
|
|
57
|
-
- "<what should happen instead — from issue body or implicit>"
|
|
58
|
-
|
|
59
|
-
reproduction:
|
|
60
|
-
- "<minimum step 1>"
|
|
61
|
-
- "<minimum step 2>"
|
|
62
|
-
|
|
63
|
-
failure_locus:
|
|
64
|
-
file: "src/path/to/broken-file.ts"
|
|
65
|
-
line: 42 # optional; omit if not pinpointable
|
|
66
|
-
function: handlerName # optional
|
|
67
|
-
diagnosis: |
|
|
68
|
-
<One paragraph: why is the bug happening? Be specific. Reference
|
|
69
|
-
the read evidence: "src/foo.ts:42 selects column 'bar' but no
|
|
70
|
-
migration adds 'bar' (verified: grep returns 0 hits)".>
|
|
71
|
-
|
|
72
|
-
regression_assertion:
|
|
73
|
-
- "Given <repro context>, when <action>, then <correct behavior>"
|
|
74
|
-
- "(may be multiple if the bug has compound effects)"
|
|
75
|
-
|
|
76
|
-
fix_scope:
|
|
77
|
-
- "src/path/to/broken-file.ts"
|
|
78
|
-
- "supabase/migrations/" # for example, when the fix needs DDL
|
|
79
|
-
|
|
80
|
-
related_specs: # optional, omit if none
|
|
81
|
-
- id: "story-007"
|
|
82
|
-
relationship: touches
|
|
83
|
-
note: "/api/X is owned by story-007's spec; check that contract"
|
|
84
|
-
\`\`\`
|
|
85
|
-
|
|
86
|
-
**Output format is strict.** Wrap the YAML in a single \`<bug_profile>...</bug_profile>\` XML block. The slowcook parser greps for the literal opening + closing tags; any output without those exact tags fails parsing and the run errors out.
|
|
87
|
-
|
|
88
|
-
Concrete example of the expected final-message format:
|
|
89
|
-
|
|
90
|
-
\`\`\`
|
|
91
|
-
<bug_profile>
|
|
92
|
-
schema_version: 1
|
|
93
|
-
title: "<one-line bug title>"
|
|
94
|
-
source_issue: "#135"
|
|
95
|
-
status: investigated
|
|
96
|
-
investigated_by: "(slowcook stamps this)"
|
|
97
|
-
created_at: "(slowcook stamps this)"
|
|
98
|
-
|
|
99
|
-
symptom:
|
|
100
|
-
- "Verbatim user-visible failure mode."
|
|
101
|
-
|
|
102
|
-
expected:
|
|
103
|
-
- "What should happen instead."
|
|
104
|
-
|
|
105
|
-
reproduction:
|
|
106
|
-
- "Step 1."
|
|
107
|
-
|
|
108
|
-
failure_locus:
|
|
109
|
-
file: "src/path/to/broken.ts"
|
|
110
|
-
line: 42
|
|
111
|
-
function: "handler"
|
|
112
|
-
diagnosis: |
|
|
113
|
-
One paragraph naming the actual cause, citing read evidence
|
|
114
|
-
(e.g., 'src/foo.ts:42 selects column bar but no migration adds
|
|
115
|
-
bar — verified via grep').
|
|
116
|
-
|
|
117
|
-
regression_assertion:
|
|
118
|
-
- "Given <repro context>, when <action>, then <correct behavior>."
|
|
119
|
-
|
|
120
|
-
fix_scope:
|
|
121
|
-
- "src/path/to/broken.ts"
|
|
122
|
-
</bug_profile>
|
|
123
|
-
\`\`\`
|
|
124
|
-
|
|
125
|
-
If you have one preliminary thought to share, put it BEFORE the \`<bug_profile>\` block — but the parser only reads what's inside the tags. Anything outside is ignored.
|
|
126
|
-
|
|
127
|
-
If you cannot find a single failure locus from reading the obvious files, emit a \`<halt>\` block with a one-line description of what you couldn't disambiguate. Do not emit prose explaining your confusion — the slowcook parser doesn't read prose. \`<halt>\` is the structured way to ask for help.
|
|
128
|
-
|
|
129
|
-
## Tools
|
|
130
|
-
|
|
131
|
-
You have read tools (read_file, outline_file, find_references, find_definition, grep, list_directory) — exactly the same ones brew uses for pre-write discovery. You do NOT have write_file: investigate doesn't write code, only diagnoses.
|
|
132
|
-
|
|
133
|
-
## When to halt voluntarily
|
|
134
|
-
|
|
135
|
-
If after reading the issue body and the obvious files (mirrored path from issue mentions, fetch URLs, table names, etc.) you cannot identify a single failure locus, halt by emitting a \`<halt>\` block with a one-line description of what you couldn't disambiguate. Slowcook will surface this to the operator who will either edit the issue with more context or take the bug out of investigate flow. **Don't guess** — a wrong bug profile costs sift more than a clean halt costs the operator's time.
|
|
136
|
-
`;
|
|
137
|
-
/**
|
|
138
|
-
* Tool definitions the investigate agent has access to. Mirrors the
|
|
139
|
-
* brew read-only subset (no write_file): investigate diagnoses, sift
|
|
140
|
-
* fixes.
|
|
141
|
-
*
|
|
142
|
-
* Kept minimal in alpha.2a — alpha.2b wires the actual ts-morph
|
|
143
|
-
* implementations from brew/retrieval.ts.
|
|
144
|
-
*/
|
|
145
|
-
export const INVESTIGATE_TOOLS = [
|
|
146
|
-
{
|
|
147
|
-
name: "read_file",
|
|
148
|
-
description: "Read a file's full contents. Use sparingly — outline_file is cheaper for initial scoping.",
|
|
149
|
-
input_schema: {
|
|
150
|
-
type: "object",
|
|
151
|
-
properties: {
|
|
152
|
-
path: { type: "string", description: "Repo-relative path." },
|
|
153
|
-
},
|
|
154
|
-
required: ["path"],
|
|
155
|
-
},
|
|
156
|
-
},
|
|
157
|
-
{
|
|
158
|
-
name: "outline_file",
|
|
159
|
-
description: "Compact ~200-token outline of a TS/TSX file: imports, top-level exports, signatures with line numbers. Use this first to decide whether a file is relevant.",
|
|
160
|
-
input_schema: {
|
|
161
|
-
type: "object",
|
|
162
|
-
properties: {
|
|
163
|
-
path: { type: "string", description: "Repo-relative path." },
|
|
164
|
-
},
|
|
165
|
-
required: ["path"],
|
|
166
|
-
},
|
|
167
|
-
},
|
|
168
|
-
{
|
|
169
|
-
name: "list_directory",
|
|
170
|
-
description: "List entries in a directory.",
|
|
171
|
-
input_schema: {
|
|
172
|
-
type: "object",
|
|
173
|
-
properties: {
|
|
174
|
-
path: { type: "string", description: "Repo-relative path." },
|
|
175
|
-
},
|
|
176
|
-
required: ["path"],
|
|
177
|
-
},
|
|
178
|
-
},
|
|
179
|
-
{
|
|
180
|
-
name: "find_references",
|
|
181
|
-
description: "Find all references to a symbol across the repo (definitions + use sites). Returns file:line entries.",
|
|
182
|
-
input_schema: {
|
|
183
|
-
type: "object",
|
|
184
|
-
properties: {
|
|
185
|
-
symbol: {
|
|
186
|
-
type: "string",
|
|
187
|
-
description: "Identifier name to search for.",
|
|
188
|
-
},
|
|
189
|
-
},
|
|
190
|
-
required: ["symbol"],
|
|
191
|
-
},
|
|
192
|
-
},
|
|
193
|
-
{
|
|
194
|
-
name: "grep",
|
|
195
|
-
description: "Repo-wide ripgrep for a literal or regex string. Use when find_references is too narrow (e.g. searching column names in SQL files).",
|
|
196
|
-
input_schema: {
|
|
197
|
-
type: "object",
|
|
198
|
-
properties: {
|
|
199
|
-
pattern: {
|
|
200
|
-
type: "string",
|
|
201
|
-
description: "Pattern to search.",
|
|
202
|
-
},
|
|
203
|
-
glob: {
|
|
204
|
-
type: "string",
|
|
205
|
-
description: "Optional glob restriction (e.g. 'supabase/migrations/*.sql').",
|
|
206
|
-
},
|
|
207
|
-
},
|
|
208
|
-
required: ["pattern"],
|
|
209
|
-
},
|
|
210
|
-
},
|
|
211
|
-
];
|
|
212
|
-
/**
|
|
213
|
-
* Build the per-issue user message. The issue body becomes the
|
|
214
|
-
* agent's primary input; it tools its way out from there.
|
|
215
|
-
*/
|
|
216
|
-
export function buildInvestigateUserPrompt(args) {
|
|
217
|
-
const lines = [];
|
|
218
|
-
lines.push(`# Investigate bug — issue #${args.issueNumber}`);
|
|
219
|
-
lines.push("");
|
|
220
|
-
lines.push(`## Title`);
|
|
221
|
-
lines.push(args.issueTitle);
|
|
222
|
-
lines.push("");
|
|
223
|
-
lines.push(`## Issue body`);
|
|
224
|
-
lines.push(args.issueBody);
|
|
225
|
-
if (args.prior_comments && args.prior_comments.length > 0) {
|
|
226
|
-
lines.push("");
|
|
227
|
-
lines.push(`## Prior comments (in chronological order)`);
|
|
228
|
-
for (const c of args.prior_comments) {
|
|
229
|
-
lines.push("---");
|
|
230
|
-
lines.push(c);
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
lines.push("");
|
|
234
|
-
lines.push(`## Your task\n\nInvestigate. Identify the failure locus + diagnosis. Emit a single \`<bug_profile>\` block following the system-prompt schema.`);
|
|
235
|
-
return lines.join("\n");
|
|
236
|
-
}
|
|
9
|
+
export { INVESTIGATE_SYSTEM, INVESTIGATE_TOOLS, buildInvestigateUserPrompt, } from "@slowcook-ai/llm-anthropic";
|
|
237
10
|
//# sourceMappingURL=prompts.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompts.js","sourceRoot":"","sources":["../../../src/commands/investigate/prompts.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"prompts.js","sourceRoot":"","sources":["../../../src/commands/investigate/prompts.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,0BAA0B,GAC3B,MAAM,4BAA4B,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 0.13.3 (brownfield-extraction track for 0.14 mockup-first refinement) —
|
|
3
|
+
* walk `**\/*.css` files (excluding build output) and extract design tokens
|
|
4
|
+
* declared via `:root { --var: value }` and `@theme { --var: value }` blocks.
|
|
5
|
+
*
|
|
6
|
+
* Supports the Tailwind v4 idiom (inline `@theme`) and classic CSS-vars
|
|
7
|
+
* theming. Light/dark variants captured separately when `:root` lives
|
|
8
|
+
* inside `@media (prefers-color-scheme: dark)`.
|
|
9
|
+
*
|
|
10
|
+
* Output: `.brewing/diagrams/tokens.md` — refine reads this so its
|
|
11
|
+
* mockup proposals reuse the consumer's existing palette / scale rather
|
|
12
|
+
* than inventing arbitrary hex values.
|
|
13
|
+
*/
|
|
14
|
+
export interface TokenEntry {
|
|
15
|
+
name: string;
|
|
16
|
+
value: string;
|
|
17
|
+
variant: "light" | "dark";
|
|
18
|
+
source: string;
|
|
19
|
+
}
|
|
20
|
+
export interface TokenCatalog {
|
|
21
|
+
light: TokenEntry[];
|
|
22
|
+
dark: TokenEntry[];
|
|
23
|
+
themeMappings: TokenEntry[];
|
|
24
|
+
filesScanned: number;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Parse a CSS file's :root and @theme blocks into TokenEntry rows.
|
|
28
|
+
*
|
|
29
|
+
* Strategy: walk top-level by tracking brace depth + remembering the
|
|
30
|
+
* last selector / at-rule prefix. We need only enough to distinguish:
|
|
31
|
+
* - `:root { ... }` at depth 0 → light variant
|
|
32
|
+
* - `:root { ... }` inside `@media (prefers-color-scheme: dark)` → dark
|
|
33
|
+
* - `@theme { ... }` → theme mappings (Tailwind v4)
|
|
34
|
+
*
|
|
35
|
+
* We are not building a full CSS AST; the regex+brace pass is enough
|
|
36
|
+
* for the conventional vars-in-:root pattern and degrades gracefully
|
|
37
|
+
* on weird input by emitting fewer rows.
|
|
38
|
+
*/
|
|
39
|
+
export declare function parseCssTokens(content: string, sourceLabel: string): {
|
|
40
|
+
light: TokenEntry[];
|
|
41
|
+
dark: TokenEntry[];
|
|
42
|
+
themeMappings: TokenEntry[];
|
|
43
|
+
};
|
|
44
|
+
export declare function emitTokensCatalog(repoRoot: string): {
|
|
45
|
+
written: boolean;
|
|
46
|
+
filesScanned: number;
|
|
47
|
+
lightCount?: number;
|
|
48
|
+
darkCount?: number;
|
|
49
|
+
themeCount?: number;
|
|
50
|
+
skippedReason?: string;
|
|
51
|
+
};
|
|
52
|
+
export declare function renderTokensMarkdown(catalog: TokenCatalog): string;
|
|
53
|
+
//# sourceMappingURL=emit-tokens.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"emit-tokens.d.ts","sourceRoot":"","sources":["../../../src/commands/map/emit-tokens.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;GAYG;AAEH,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,OAAO,GAAG,MAAM,CAAC;IAC1B,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,UAAU,EAAE,CAAC;IACpB,IAAI,EAAE,UAAU,EAAE,CAAC;IACnB,aAAa,EAAE,UAAU,EAAE,CAAC;IAC5B,YAAY,EAAE,MAAM,CAAC;CACtB;AA0CD;;;;;;;;;;;;GAYG;AACH,wBAAgB,cAAc,CAC5B,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,MAAM,GAClB;IAAE,KAAK,EAAE,UAAU,EAAE,CAAC;IAAC,IAAI,EAAE,UAAU,EAAE,CAAC;IAAC,aAAa,EAAE,UAAU,EAAE,CAAA;CAAE,CAsE1E;AAkGD,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG;IACnD,OAAO,EAAE,OAAO,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAoDA;AAED,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,YAAY,GAAG,MAAM,CAmDlE"}
|