@curenorway/kode-cli 1.2.1 → 1.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/{chunk-43RZM4JR.js → chunk-5S7XIMSB.js} +99 -18
- 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: [],
|
|
@@ -507,28 +515,92 @@ Page context includes:
|
|
|
507
515
|
- **Forms**: Form fields, labels, and submit buttons
|
|
508
516
|
- **CMS**: Collection patterns with item counts
|
|
509
517
|
|
|
518
|
+
## Script Loading Behavior
|
|
519
|
+
|
|
520
|
+
Scripts have two properties that control loading:
|
|
521
|
+
|
|
522
|
+
| Property | Values | Description |
|
|
523
|
+
|----------|--------|-------------|
|
|
524
|
+
| **scope** | \`global\` / \`page-specific\` | Where the script loads |
|
|
525
|
+
| **autoLoad** | \`true\` / \`false\` | Whether it loads automatically |
|
|
526
|
+
|
|
527
|
+
### Loading Matrix
|
|
528
|
+
|
|
529
|
+
| Scope | Auto-Load | Behavior |
|
|
530
|
+
|-------|-----------|----------|
|
|
531
|
+
| **global + true** | Default for new scripts. Content is **inlined** into init.js, executes immediately on all pages. |
|
|
532
|
+
| **global + false** | Listed in config but NOT loaded. Call \`CK.loadScript('slug')\` manually to load. |
|
|
533
|
+
| **page-specific + true** | Dynamically loaded when URL matches assigned page patterns. |
|
|
534
|
+
| **page-specific + false** | Not loaded automatically. Call \`CK.loadScript('slug')\` when needed. |
|
|
535
|
+
|
|
536
|
+
### CLI Flags
|
|
537
|
+
|
|
538
|
+
\`\`\`bash
|
|
539
|
+
kode push --auto-load # Force enable auto-load for new scripts
|
|
540
|
+
kode push --no-auto-load # Disable auto-load (for manual loading)
|
|
541
|
+
\`\`\`
|
|
542
|
+
|
|
543
|
+
### Page-Specific Scripts
|
|
544
|
+
|
|
545
|
+
For page-specific scripts, you must:
|
|
546
|
+
1. Create with \`scope: 'page-specific'\`
|
|
547
|
+
2. Assign to pages via MCP: \`kode_assign_script_to_page\`
|
|
548
|
+
3. Deploy to make changes live
|
|
549
|
+
|
|
550
|
+
### Manual Loading
|
|
551
|
+
|
|
552
|
+
To load scripts on-demand (for modals, lazy-load, etc.):
|
|
553
|
+
|
|
554
|
+
\`\`\`javascript
|
|
555
|
+
// Load a script that has autoLoad: false
|
|
556
|
+
CK.loadScript('my-modal-script')
|
|
557
|
+
|
|
558
|
+
// Check if loaded
|
|
559
|
+
if (CK.isLoaded('my-modal-script')) {
|
|
560
|
+
// already loaded
|
|
561
|
+
}
|
|
562
|
+
\`\`\`
|
|
563
|
+
|
|
510
564
|
## Best Practices
|
|
511
565
|
|
|
512
566
|
1. **Always deploy to staging first** - Test before production
|
|
513
|
-
2. **Use page-specific scripts** -
|
|
514
|
-
3. **
|
|
515
|
-
4. **
|
|
567
|
+
2. **Use page-specific scripts** for page-only functionality
|
|
568
|
+
3. **Use \`autoLoad: false\`** for lazy-loaded features (modals, etc.)
|
|
569
|
+
4. **Document your changes** - Update context.md
|
|
570
|
+
5. **Cache page HTML** - Use \`kode html <url> --save\` to understand structure
|
|
516
571
|
|
|
517
572
|
## MCP Tools
|
|
518
573
|
|
|
519
574
|
If using the Kode MCP server, these tools are available:
|
|
520
|
-
|
|
575
|
+
|
|
576
|
+
### Script Management
|
|
577
|
+
- \`kode_list_scripts\` - List all scripts with scope and autoLoad status
|
|
521
578
|
- \`kode_get_script\` - Get script content
|
|
522
|
-
- \`kode_create_script\` - Create new script
|
|
523
|
-
- \`kode_update_script\` - Update script content
|
|
524
|
-
- \`
|
|
579
|
+
- \`kode_create_script\` - Create new script (accepts \`scope\` and \`autoLoad\`)
|
|
580
|
+
- \`kode_update_script\` - Update script content, scope, or autoLoad
|
|
581
|
+
- \`kode_delete_script\` - Delete a script
|
|
582
|
+
|
|
583
|
+
### Page Assignment (for page-specific scripts)
|
|
584
|
+
- \`kode_list_pages\` - List page definitions with URL patterns
|
|
585
|
+
- \`kode_assign_script_to_page\` - Assign a script to a page
|
|
586
|
+
- \`kode_remove_script_from_page\` - Remove script from page
|
|
587
|
+
|
|
588
|
+
### Deployment
|
|
589
|
+
- \`kode_deploy\` - Deploy to staging or production
|
|
590
|
+
- \`kode_promote\` - Promote staging to production
|
|
525
591
|
- \`kode_status\` - Get deployment status
|
|
592
|
+
|
|
593
|
+
### HTML Analysis
|
|
526
594
|
- \`kode_fetch_html\` - Analyze page HTML
|
|
595
|
+
- \`kode_fetch_html_smart\` - Analyze with CMS truncation
|
|
596
|
+
- \`kode_refresh_page\` - Fetch and cache page structure
|
|
597
|
+
- \`kode_get_page_context\` - Get cached page structure (with CSS selectors)
|
|
598
|
+
- \`kode_list_pages_context\` - List cached page contexts
|
|
599
|
+
|
|
600
|
+
### Context
|
|
527
601
|
- \`kode_read_context\` - Read context file
|
|
528
602
|
- \`kode_update_context\` - Update context file
|
|
529
|
-
- \`
|
|
530
|
-
- \`kode_get_page_context\` - Get cached page structure
|
|
531
|
-
- \`kode_list_pages\` - List cached pages
|
|
603
|
+
- \`kode_site_info\` - Get site configuration and CDN URLs
|
|
532
604
|
`;
|
|
533
605
|
}
|
|
534
606
|
|
|
@@ -952,8 +1024,9 @@ async function pullCommand(options) {
|
|
|
952
1024
|
}
|
|
953
1025
|
writeFileSync4(filePath, script.content);
|
|
954
1026
|
const scopeTag = script.scope === "global" ? chalk2.blue("[G]") : chalk2.magenta("[P]");
|
|
1027
|
+
const loadTag = script.auto_load ? chalk2.green("\u26A1") : chalk2.dim("\u25CB");
|
|
955
1028
|
console.log(
|
|
956
|
-
chalk2.green(` \u2713 ${fileName}`) + chalk2.dim(` v${script.current_version} ${scopeTag}`
|
|
1029
|
+
chalk2.green(` \u2713 ${fileName}`) + chalk2.dim(` v${script.current_version}`) + ` ${scopeTag} ${loadTag}`
|
|
957
1030
|
);
|
|
958
1031
|
pulled++;
|
|
959
1032
|
}
|
|
@@ -971,10 +1044,12 @@ async function pullCommand(options) {
|
|
|
971
1044
|
name: s.name,
|
|
972
1045
|
type: s.type,
|
|
973
1046
|
scope: s.scope,
|
|
1047
|
+
autoLoad: s.auto_load,
|
|
974
1048
|
version: s.current_version,
|
|
975
1049
|
loadOrder: s.load_order
|
|
976
1050
|
}));
|
|
977
1051
|
writeFileSync4(metadataPath, JSON.stringify(metadata, null, 2));
|
|
1052
|
+
console.log(chalk2.dim("\nLegend: [G]=Global [P]=Page-specific \u26A1=Auto-load \u25CB=Manual load"));
|
|
978
1053
|
} catch (error) {
|
|
979
1054
|
spinner.fail("Failed to pull scripts");
|
|
980
1055
|
console.error(chalk2.red("\nError:"), error);
|
|
@@ -1062,15 +1137,19 @@ async function pushCommand(options) {
|
|
|
1062
1137
|
pushed++;
|
|
1063
1138
|
} else {
|
|
1064
1139
|
const createSpinner = ora3(`Creating ${file}...`).start();
|
|
1140
|
+
const scriptScope = localMeta?.scope || "global";
|
|
1065
1141
|
const newScript = await client.createScript(config.siteId, {
|
|
1066
1142
|
name: slug.charAt(0).toUpperCase() + slug.slice(1).replace(/-/g, " "),
|
|
1067
1143
|
slug,
|
|
1068
1144
|
type,
|
|
1069
|
-
scope:
|
|
1145
|
+
scope: scriptScope,
|
|
1146
|
+
// autoLoad: if explicitly set via CLI, use that; otherwise let API default based on scope
|
|
1147
|
+
autoLoad: options.autoLoad,
|
|
1070
1148
|
content
|
|
1071
1149
|
});
|
|
1150
|
+
const autoLoadInfo = newScript.auto_load ? chalk3.green("auto-load") : chalk3.dim("manual");
|
|
1072
1151
|
createSpinner.succeed(
|
|
1073
|
-
chalk3.green(` \u2713 ${file}`) + chalk3.cyan(" (new)")
|
|
1152
|
+
chalk3.green(` \u2713 ${file}`) + chalk3.cyan(" (new)") + ` [${autoLoadInfo}]`
|
|
1074
1153
|
);
|
|
1075
1154
|
created++;
|
|
1076
1155
|
}
|
|
@@ -1092,6 +1171,7 @@ async function pushCommand(options) {
|
|
|
1092
1171
|
name: s.name,
|
|
1093
1172
|
type: s.type,
|
|
1094
1173
|
scope: s.scope,
|
|
1174
|
+
autoLoad: s.auto_load,
|
|
1095
1175
|
version: s.current_version,
|
|
1096
1176
|
loadOrder: s.load_order
|
|
1097
1177
|
}));
|
|
@@ -1863,6 +1943,7 @@ async function contextCommand(options) {
|
|
|
1863
1943
|
slug: s.slug,
|
|
1864
1944
|
type: s.type,
|
|
1865
1945
|
scope: s.scope,
|
|
1946
|
+
autoLoad: s.auto_load,
|
|
1866
1947
|
purpose: existing?.purpose
|
|
1867
1948
|
};
|
|
1868
1949
|
}),
|
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-5S7XIMSB.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