@curenorway/kode-cli 1.2.1 → 1.3.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/{chunk-43RZM4JR.js → chunk-E2KOP6ND.js} +113 -19
- package/dist/cli.js +2 -2
- package/dist/index.d.ts +6 -0
- package/dist/index.js +1 -1
- package/package.json +1 -1
|
@@ -98,11 +98,14 @@ function parseContext(content) {
|
|
|
98
98
|
for (const row of rows) {
|
|
99
99
|
const cols = row.split("|").map((c) => c.trim()).filter(Boolean);
|
|
100
100
|
if (cols.length >= 3) {
|
|
101
|
+
const hasAutoCol = cols.length >= 5 || cols.length === 4 && (cols[3] === "\u26A1" || cols[3] === "\u25CB");
|
|
101
102
|
context.scripts.push({
|
|
102
103
|
slug: cols[0],
|
|
103
104
|
type: cols[1].toLowerCase() === "css" ? "css" : "javascript",
|
|
104
105
|
scope: cols[2].toLowerCase() === "page-specific" ? "page-specific" : "global",
|
|
105
|
-
|
|
106
|
+
autoLoad: hasAutoCol ? cols[3] === "\u26A1" : true,
|
|
107
|
+
// Default to true for old format
|
|
108
|
+
purpose: hasAutoCol ? cols[4] || void 0 : cols[3] || void 0
|
|
106
109
|
});
|
|
107
110
|
}
|
|
108
111
|
}
|
|
@@ -161,16 +164,20 @@ function serializeContext(context) {
|
|
|
161
164
|
md += `## Scripts
|
|
162
165
|
|
|
163
166
|
`;
|
|
164
|
-
md += `| Script | Type | Scope | Purpose |
|
|
167
|
+
md += `| Script | Type | Scope | Auto | Purpose |
|
|
165
168
|
`;
|
|
166
|
-
md +=
|
|
169
|
+
md += `|--------|------|-------|------|--------|
|
|
167
170
|
`;
|
|
168
171
|
for (const script of context.scripts) {
|
|
169
172
|
const purpose = script.purpose || "(add purpose)";
|
|
170
|
-
|
|
173
|
+
const autoIcon = script.autoLoad ? "\u26A1" : "\u25CB";
|
|
174
|
+
md += `| ${script.slug} | ${script.type === "css" ? "CSS" : "JS"} | ${script.scope} | ${autoIcon} | ${purpose} |
|
|
171
175
|
`;
|
|
172
176
|
}
|
|
173
177
|
md += `
|
|
178
|
+
`;
|
|
179
|
+
md += `> Legend: \u26A1 = auto-loads, \u25CB = manual load via \`CK.loadScript()\`
|
|
180
|
+
|
|
174
181
|
`;
|
|
175
182
|
if (context.pages && context.pages.length > 0) {
|
|
176
183
|
md += `## Pages
|
|
@@ -324,7 +331,8 @@ function generateInitialContext(config, scripts, site) {
|
|
|
324
331
|
scripts: scripts.map((s) => ({
|
|
325
332
|
slug: s.slug,
|
|
326
333
|
type: s.type,
|
|
327
|
-
scope: s.scope
|
|
334
|
+
scope: s.scope,
|
|
335
|
+
autoLoad: s.auto_load
|
|
328
336
|
})),
|
|
329
337
|
pages: [],
|
|
330
338
|
notes: [],
|
|
@@ -402,10 +410,23 @@ Add this to Webflow \u2192 Project Settings \u2192 Custom Code \u2192 Footer Cod
|
|
|
402
410
|
| \`kode deploy --env production\` | Deploy to production |
|
|
403
411
|
| \`kode html <url> --save\` | Analyze and cache page HTML structure |
|
|
404
412
|
|
|
413
|
+
### Script Loading
|
|
414
|
+
|
|
415
|
+
Scripts have two properties: **scope** and **autoLoad**.
|
|
416
|
+
|
|
417
|
+
| Scope | Auto-Load | Behavior |
|
|
418
|
+
|-------|-----------|----------|
|
|
419
|
+
| global + true | **Default**. Inlined into init.js, runs on all pages |
|
|
420
|
+
| global + false | Not loaded. Call \`CK.loadScript('slug')\` manually |
|
|
421
|
+
| page-specific + true | Loaded when URL matches page patterns |
|
|
422
|
+
| page-specific + false | Not loaded. Call \`CK.loadScript('slug')\` manually |
|
|
423
|
+
|
|
424
|
+
**CLI flags**: \`kode push --auto-load\` or \`kode push --no-auto-load\`
|
|
425
|
+
|
|
405
426
|
### Context
|
|
406
427
|
|
|
407
428
|
**Read \`.cure-kode/context.md\` before working on scripts** - it contains:
|
|
408
|
-
- Script inventory with purposes
|
|
429
|
+
- Script inventory with purposes and auto-load status
|
|
409
430
|
- Cached page structures (sections, CTAs, forms)
|
|
410
431
|
- Notes from previous sessions
|
|
411
432
|
|
|
@@ -507,28 +528,92 @@ Page context includes:
|
|
|
507
528
|
- **Forms**: Form fields, labels, and submit buttons
|
|
508
529
|
- **CMS**: Collection patterns with item counts
|
|
509
530
|
|
|
531
|
+
## Script Loading Behavior
|
|
532
|
+
|
|
533
|
+
Scripts have two properties that control loading:
|
|
534
|
+
|
|
535
|
+
| Property | Values | Description |
|
|
536
|
+
|----------|--------|-------------|
|
|
537
|
+
| **scope** | \`global\` / \`page-specific\` | Where the script loads |
|
|
538
|
+
| **autoLoad** | \`true\` / \`false\` | Whether it loads automatically |
|
|
539
|
+
|
|
540
|
+
### Loading Matrix
|
|
541
|
+
|
|
542
|
+
| Scope | Auto-Load | Behavior |
|
|
543
|
+
|-------|-----------|----------|
|
|
544
|
+
| **global + true** | Default for new scripts. Content is **inlined** into init.js, executes immediately on all pages. |
|
|
545
|
+
| **global + false** | Listed in config but NOT loaded. Call \`CK.loadScript('slug')\` manually to load. |
|
|
546
|
+
| **page-specific + true** | Dynamically loaded when URL matches assigned page patterns. |
|
|
547
|
+
| **page-specific + false** | Not loaded automatically. Call \`CK.loadScript('slug')\` when needed. |
|
|
548
|
+
|
|
549
|
+
### CLI Flags
|
|
550
|
+
|
|
551
|
+
\`\`\`bash
|
|
552
|
+
kode push --auto-load # Force enable auto-load for new scripts
|
|
553
|
+
kode push --no-auto-load # Disable auto-load (for manual loading)
|
|
554
|
+
\`\`\`
|
|
555
|
+
|
|
556
|
+
### Page-Specific Scripts
|
|
557
|
+
|
|
558
|
+
For page-specific scripts, you must:
|
|
559
|
+
1. Create with \`scope: 'page-specific'\`
|
|
560
|
+
2. Assign to pages via MCP: \`kode_assign_script_to_page\`
|
|
561
|
+
3. Deploy to make changes live
|
|
562
|
+
|
|
563
|
+
### Manual Loading
|
|
564
|
+
|
|
565
|
+
To load scripts on-demand (for modals, lazy-load, etc.):
|
|
566
|
+
|
|
567
|
+
\`\`\`javascript
|
|
568
|
+
// Load a script that has autoLoad: false
|
|
569
|
+
CK.loadScript('my-modal-script')
|
|
570
|
+
|
|
571
|
+
// Check if loaded
|
|
572
|
+
if (CK.isLoaded('my-modal-script')) {
|
|
573
|
+
// already loaded
|
|
574
|
+
}
|
|
575
|
+
\`\`\`
|
|
576
|
+
|
|
510
577
|
## Best Practices
|
|
511
578
|
|
|
512
579
|
1. **Always deploy to staging first** - Test before production
|
|
513
|
-
2. **Use page-specific scripts** -
|
|
514
|
-
3. **
|
|
515
|
-
4. **
|
|
580
|
+
2. **Use page-specific scripts** for page-only functionality
|
|
581
|
+
3. **Use \`autoLoad: false\`** for lazy-loaded features (modals, etc.)
|
|
582
|
+
4. **Document your changes** - Update context.md
|
|
583
|
+
5. **Cache page HTML** - Use \`kode html <url> --save\` to understand structure
|
|
516
584
|
|
|
517
585
|
## MCP Tools
|
|
518
586
|
|
|
519
587
|
If using the Kode MCP server, these tools are available:
|
|
520
|
-
|
|
588
|
+
|
|
589
|
+
### Script Management
|
|
590
|
+
- \`kode_list_scripts\` - List all scripts with scope and autoLoad status
|
|
521
591
|
- \`kode_get_script\` - Get script content
|
|
522
|
-
- \`kode_create_script\` - Create new script
|
|
523
|
-
- \`kode_update_script\` - Update script content
|
|
524
|
-
- \`
|
|
592
|
+
- \`kode_create_script\` - Create new script (accepts \`scope\` and \`autoLoad\`)
|
|
593
|
+
- \`kode_update_script\` - Update script content, scope, or autoLoad
|
|
594
|
+
- \`kode_delete_script\` - Delete a script
|
|
595
|
+
|
|
596
|
+
### Page Assignment (for page-specific scripts)
|
|
597
|
+
- \`kode_list_pages\` - List page definitions with URL patterns
|
|
598
|
+
- \`kode_assign_script_to_page\` - Assign a script to a page
|
|
599
|
+
- \`kode_remove_script_from_page\` - Remove script from page
|
|
600
|
+
|
|
601
|
+
### Deployment
|
|
602
|
+
- \`kode_deploy\` - Deploy to staging or production
|
|
603
|
+
- \`kode_promote\` - Promote staging to production
|
|
525
604
|
- \`kode_status\` - Get deployment status
|
|
605
|
+
|
|
606
|
+
### HTML Analysis
|
|
526
607
|
- \`kode_fetch_html\` - Analyze page HTML
|
|
608
|
+
- \`kode_fetch_html_smart\` - Analyze with CMS truncation
|
|
609
|
+
- \`kode_refresh_page\` - Fetch and cache page structure
|
|
610
|
+
- \`kode_get_page_context\` - Get cached page structure (with CSS selectors)
|
|
611
|
+
- \`kode_list_pages_context\` - List cached page contexts
|
|
612
|
+
|
|
613
|
+
### Context
|
|
527
614
|
- \`kode_read_context\` - Read context file
|
|
528
615
|
- \`kode_update_context\` - Update context file
|
|
529
|
-
- \`
|
|
530
|
-
- \`kode_get_page_context\` - Get cached page structure
|
|
531
|
-
- \`kode_list_pages\` - List cached pages
|
|
616
|
+
- \`kode_site_info\` - Get site configuration and CDN URLs
|
|
532
617
|
`;
|
|
533
618
|
}
|
|
534
619
|
|
|
@@ -952,8 +1037,9 @@ async function pullCommand(options) {
|
|
|
952
1037
|
}
|
|
953
1038
|
writeFileSync4(filePath, script.content);
|
|
954
1039
|
const scopeTag = script.scope === "global" ? chalk2.blue("[G]") : chalk2.magenta("[P]");
|
|
1040
|
+
const loadTag = script.auto_load ? chalk2.green("\u26A1") : chalk2.dim("\u25CB");
|
|
955
1041
|
console.log(
|
|
956
|
-
chalk2.green(` \u2713 ${fileName}`) + chalk2.dim(` v${script.current_version} ${scopeTag}`
|
|
1042
|
+
chalk2.green(` \u2713 ${fileName}`) + chalk2.dim(` v${script.current_version}`) + ` ${scopeTag} ${loadTag}`
|
|
957
1043
|
);
|
|
958
1044
|
pulled++;
|
|
959
1045
|
}
|
|
@@ -971,10 +1057,12 @@ async function pullCommand(options) {
|
|
|
971
1057
|
name: s.name,
|
|
972
1058
|
type: s.type,
|
|
973
1059
|
scope: s.scope,
|
|
1060
|
+
autoLoad: s.auto_load,
|
|
974
1061
|
version: s.current_version,
|
|
975
1062
|
loadOrder: s.load_order
|
|
976
1063
|
}));
|
|
977
1064
|
writeFileSync4(metadataPath, JSON.stringify(metadata, null, 2));
|
|
1065
|
+
console.log(chalk2.dim("\nLegend: [G]=Global [P]=Page-specific \u26A1=Auto-load \u25CB=Manual load"));
|
|
978
1066
|
} catch (error) {
|
|
979
1067
|
spinner.fail("Failed to pull scripts");
|
|
980
1068
|
console.error(chalk2.red("\nError:"), error);
|
|
@@ -1062,15 +1150,19 @@ async function pushCommand(options) {
|
|
|
1062
1150
|
pushed++;
|
|
1063
1151
|
} else {
|
|
1064
1152
|
const createSpinner = ora3(`Creating ${file}...`).start();
|
|
1153
|
+
const scriptScope = localMeta?.scope || "global";
|
|
1065
1154
|
const newScript = await client.createScript(config.siteId, {
|
|
1066
1155
|
name: slug.charAt(0).toUpperCase() + slug.slice(1).replace(/-/g, " "),
|
|
1067
1156
|
slug,
|
|
1068
1157
|
type,
|
|
1069
|
-
scope:
|
|
1158
|
+
scope: scriptScope,
|
|
1159
|
+
// autoLoad: if explicitly set via CLI, use that; otherwise let API default based on scope
|
|
1160
|
+
autoLoad: options.autoLoad,
|
|
1070
1161
|
content
|
|
1071
1162
|
});
|
|
1163
|
+
const autoLoadInfo = newScript.auto_load ? chalk3.green("auto-load") : chalk3.dim("manual");
|
|
1072
1164
|
createSpinner.succeed(
|
|
1073
|
-
chalk3.green(` \u2713 ${file}`) + chalk3.cyan(" (new)")
|
|
1165
|
+
chalk3.green(` \u2713 ${file}`) + chalk3.cyan(" (new)") + ` [${autoLoadInfo}]`
|
|
1074
1166
|
);
|
|
1075
1167
|
created++;
|
|
1076
1168
|
}
|
|
@@ -1092,6 +1184,7 @@ async function pushCommand(options) {
|
|
|
1092
1184
|
name: s.name,
|
|
1093
1185
|
type: s.type,
|
|
1094
1186
|
scope: s.scope,
|
|
1187
|
+
autoLoad: s.auto_load,
|
|
1095
1188
|
version: s.current_version,
|
|
1096
1189
|
loadOrder: s.load_order
|
|
1097
1190
|
}));
|
|
@@ -1863,6 +1956,7 @@ async function contextCommand(options) {
|
|
|
1863
1956
|
slug: s.slug,
|
|
1864
1957
|
type: s.type,
|
|
1865
1958
|
scope: s.scope,
|
|
1959
|
+
autoLoad: s.auto_load,
|
|
1866
1960
|
purpose: existing?.purpose
|
|
1867
1961
|
};
|
|
1868
1962
|
}),
|
package/dist/cli.js
CHANGED
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
readPageContext,
|
|
15
15
|
statusCommand,
|
|
16
16
|
watchCommand
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-E2KOP6ND.js";
|
|
18
18
|
|
|
19
19
|
// src/cli.ts
|
|
20
20
|
import { Command } from "commander";
|
|
@@ -238,7 +238,7 @@ program.command("init").description("Initialize Cure Kode in current directory")
|
|
|
238
238
|
program.command("pull").description("Download scripts from Cure to local files").argument("[script]", "Specific script slug to pull").option("-f, --force", "Overwrite local changes").action((script, options) => {
|
|
239
239
|
pullCommand({ script, ...options });
|
|
240
240
|
});
|
|
241
|
-
program.command("push").description("Upload local scripts to Cure").argument("[script]", "Specific script file or slug to push").option("-m, --message <message>", "Change summary").option("-a, --all", "Push all scripts even if unchanged").action((script, options) => {
|
|
241
|
+
program.command("push").description("Upload local scripts to Cure").argument("[script]", "Specific script file or slug to push").option("-m, --message <message>", "Change summary").option("-a, --all", "Push all scripts even if unchanged").option("--auto-load", "Enable auto-loading for new scripts (default for global)").option("--no-auto-load", "Disable auto-loading for new scripts").action((script, options) => {
|
|
242
242
|
pushCommand({ script, ...options });
|
|
243
243
|
});
|
|
244
244
|
program.command("watch").description("Watch for changes and auto-push").option("-d, --deploy", "Auto-deploy after each push").action((options) => {
|
package/dist/index.d.ts
CHANGED
|
@@ -58,6 +58,7 @@ interface CdnScript {
|
|
|
58
58
|
slug: string;
|
|
59
59
|
type: 'javascript' | 'css';
|
|
60
60
|
scope: 'global' | 'page-specific';
|
|
61
|
+
auto_load: boolean;
|
|
61
62
|
content: string;
|
|
62
63
|
current_version: number;
|
|
63
64
|
is_active: boolean;
|
|
@@ -121,12 +122,14 @@ declare class KodeApiClient {
|
|
|
121
122
|
slug: string;
|
|
122
123
|
type: 'javascript' | 'css';
|
|
123
124
|
scope?: 'global' | 'page-specific';
|
|
125
|
+
autoLoad?: boolean;
|
|
124
126
|
content?: string;
|
|
125
127
|
}): Promise<CdnScript>;
|
|
126
128
|
updateScript(scriptId: string, data: {
|
|
127
129
|
content?: string;
|
|
128
130
|
name?: string;
|
|
129
131
|
scope?: 'global' | 'page-specific';
|
|
132
|
+
autoLoad?: boolean;
|
|
130
133
|
changeSummary?: string;
|
|
131
134
|
}): Promise<CdnScript>;
|
|
132
135
|
deleteScript(scriptId: string): Promise<void>;
|
|
@@ -136,6 +139,7 @@ declare class KodeApiClient {
|
|
|
136
139
|
content: string;
|
|
137
140
|
type: 'javascript' | 'css';
|
|
138
141
|
scope?: 'global' | 'page-specific';
|
|
142
|
+
autoLoad?: boolean;
|
|
139
143
|
changeSummary?: string;
|
|
140
144
|
}): Promise<CdnScript>;
|
|
141
145
|
listPages(siteId: string): Promise<CdnPage[]>;
|
|
@@ -183,6 +187,7 @@ declare function pushCommand(options: {
|
|
|
183
187
|
script?: string;
|
|
184
188
|
message?: string;
|
|
185
189
|
all?: boolean;
|
|
190
|
+
autoLoad?: boolean;
|
|
186
191
|
}): Promise<void>;
|
|
187
192
|
|
|
188
193
|
/**
|
|
@@ -240,6 +245,7 @@ interface KodeScriptContext {
|
|
|
240
245
|
slug: string;
|
|
241
246
|
type: 'javascript' | 'css';
|
|
242
247
|
scope: 'global' | 'page-specific';
|
|
248
|
+
autoLoad: boolean;
|
|
243
249
|
purpose?: string;
|
|
244
250
|
}
|
|
245
251
|
interface KodePageContext {
|
package/dist/index.js
CHANGED