@curenorway/kode-cli 1.0.0 → 1.0.2

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 CHANGED
@@ -1,17 +1,178 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
+ contextCommand,
4
+ deletePageContext,
3
5
  deployCommand,
6
+ findProjectRoot,
7
+ getProjectConfig,
4
8
  htmlCommand,
5
9
  initCommand,
10
+ listCachedPages,
6
11
  pullCommand,
7
12
  pushCommand,
13
+ readPageContext,
8
14
  statusCommand,
9
15
  watchCommand
10
- } from "./chunk-NWXEBN2N.js";
16
+ } from "./chunk-LYIXUQOG.js";
11
17
 
12
18
  // src/cli.ts
13
19
  import { Command } from "commander";
20
+ import chalk2 from "chalk";
21
+
22
+ // src/commands/pages.ts
14
23
  import chalk from "chalk";
24
+ async function pagesCommand(options) {
25
+ const projectRoot = findProjectRoot();
26
+ if (!projectRoot) {
27
+ console.log(chalk.red("Error: Not in a Cure Kode project."));
28
+ console.log(chalk.dim('Run "kode init" first.'));
29
+ return;
30
+ }
31
+ const config = getProjectConfig(projectRoot);
32
+ if (!config) {
33
+ console.log(chalk.red("Error: Invalid project configuration."));
34
+ return;
35
+ }
36
+ if (options.delete && options.page) {
37
+ const deleted = deletePageContext(projectRoot, options.page);
38
+ if (deleted) {
39
+ console.log(chalk.green(`Deleted: ${options.page}`));
40
+ } else {
41
+ console.log(chalk.red(`Not found: ${options.page}`));
42
+ }
43
+ return;
44
+ }
45
+ if (options.page) {
46
+ const context = readPageContext(projectRoot, options.page);
47
+ if (!context) {
48
+ console.log(chalk.red(`Page not found: ${options.page}`));
49
+ console.log(chalk.dim('Use "kode pages" to list cached pages'));
50
+ return;
51
+ }
52
+ if (options.json) {
53
+ console.log(JSON.stringify(context, null, 2));
54
+ return;
55
+ }
56
+ printPageDetails(context);
57
+ return;
58
+ }
59
+ const pages = listCachedPages(projectRoot);
60
+ if (pages.length === 0) {
61
+ console.log(chalk.yellow("No cached pages."));
62
+ console.log(chalk.dim('Use "kode html <url> --save" to cache page structures.'));
63
+ return;
64
+ }
65
+ if (options.json) {
66
+ console.log(JSON.stringify(pages, null, 2));
67
+ return;
68
+ }
69
+ console.log(chalk.bold(`Cached Pages (${pages.length})`));
70
+ console.log();
71
+ for (const page of pages) {
72
+ const path = new URL(page.url).pathname;
73
+ const date = new Date(page.extractedAt).toLocaleDateString();
74
+ const badges = [];
75
+ if (page.sectionCount > 0) badges.push(`${page.sectionCount} sections`);
76
+ if (page.cmsCollectionCount > 0) badges.push(chalk.cyan(`${page.cmsCollectionCount} CMS`));
77
+ console.log(` ${chalk.bold(path)} ${chalk.dim(`[${page.slug}]`)}`);
78
+ if (page.title) {
79
+ console.log(chalk.dim(` "${page.title}"`));
80
+ }
81
+ console.log(chalk.dim(` ${badges.join(", ")} \u2022 ${date}`));
82
+ console.log();
83
+ }
84
+ console.log(chalk.dim(`Use "kode pages <slug>" to see details`));
85
+ console.log(chalk.dim(`Use "kode html <url> --save --force" to refresh`));
86
+ }
87
+ function printPageDetails(context) {
88
+ console.log(chalk.bold(context.title || context.url));
89
+ console.log(chalk.dim(context.url));
90
+ console.log(chalk.dim(`Extracted: ${context.extractedAt}`));
91
+ console.log();
92
+ if (context.sections.length > 0) {
93
+ console.log(chalk.bold("Sections"));
94
+ for (const section of context.sections) {
95
+ const name = section.heading || section.id || section.className?.split(" ")[0] || "section";
96
+ const badges = [];
97
+ if (section.hasCms) badges.push(chalk.cyan("CMS"));
98
+ if (section.hasForm) badges.push(chalk.yellow("Form"));
99
+ const badgeStr = badges.length > 0 ? ` [${badges.join(", ")}]` : "";
100
+ console.log(` \u2022 ${name}${badgeStr}`);
101
+ if (section.textSample) {
102
+ console.log(chalk.dim(` "${section.textSample.slice(0, 80)}..."`));
103
+ }
104
+ }
105
+ console.log();
106
+ }
107
+ if (context.headings.length > 0) {
108
+ console.log(chalk.bold("Headings"));
109
+ for (const h of context.headings.slice(0, 10)) {
110
+ const level = "H" + h.level;
111
+ console.log(` ${chalk.dim(level)} ${h.text}`);
112
+ }
113
+ if (context.headings.length > 10) {
114
+ console.log(chalk.dim(` ... and ${context.headings.length - 10} more`));
115
+ }
116
+ console.log();
117
+ }
118
+ if (context.ctas.length > 0) {
119
+ console.log(chalk.bold("CTAs"));
120
+ for (const cta of context.ctas) {
121
+ const href = cta.href ? chalk.dim(` \u2192 ${cta.href}`) : "";
122
+ console.log(` \u2022 "${cta.text}"${href}`);
123
+ console.log(chalk.dim(` in ${cta.location}`));
124
+ }
125
+ console.log();
126
+ }
127
+ if (context.forms.length > 0) {
128
+ console.log(chalk.bold("Forms"));
129
+ for (const form of context.forms) {
130
+ console.log(` ${chalk.bold(form.name || "form")}`);
131
+ for (const field of form.fields) {
132
+ const required = field.required ? chalk.red("*") : "";
133
+ const label = field.label || field.type;
134
+ console.log(` \u2022 ${label}${required} ${chalk.dim(`(${field.type})`)}`);
135
+ }
136
+ if (form.submitText) {
137
+ console.log(` \u2192 Submit: "${form.submitText}"`);
138
+ }
139
+ }
140
+ console.log();
141
+ }
142
+ if (context.cmsPatterns.length > 0) {
143
+ console.log(chalk.bold("CMS Collections"));
144
+ for (const cms of context.cmsPatterns) {
145
+ console.log(` ${chalk.bold(cms.containerClass)}: ${chalk.cyan(`${cms.itemCount} items`)}`);
146
+ if (cms.templateFields.length > 0) {
147
+ console.log(chalk.dim(` Template fields: ${cms.templateFields.join(", ")}`));
148
+ }
149
+ }
150
+ console.log();
151
+ }
152
+ if (context.navigation.length > 0) {
153
+ console.log(chalk.bold("Navigation"));
154
+ for (const nav of context.navigation) {
155
+ console.log(` ${chalk.bold(nav.type)}:`);
156
+ for (const item of nav.items.slice(0, 8)) {
157
+ const href = item.href ? chalk.dim(` \u2192 ${item.href}`) : "";
158
+ console.log(` \u2022 ${item.text}${href}`);
159
+ }
160
+ if (nav.items.length > 8) {
161
+ console.log(chalk.dim(` ... and ${nav.items.length - 8} more`));
162
+ }
163
+ }
164
+ console.log();
165
+ }
166
+ if (context.notes && context.notes.length > 0) {
167
+ console.log(chalk.bold("Notes"));
168
+ for (const note of context.notes) {
169
+ console.log(` \u2022 ${note}`);
170
+ }
171
+ console.log();
172
+ }
173
+ }
174
+
175
+ // src/cli.ts
15
176
  var program = new Command();
16
177
  program.name("kode").description("CLI for Cure Kode - manage JS/CSS scripts for Webflow sites").version("1.0.0");
17
178
  program.command("init").description("Initialize Cure Kode in current directory").option("-k, --api-key <key>", "API key").option("-s, --site-slug <slug>", "Site slug").option("-f, --force", "Reinitialize even if already configured").action((options) => {
@@ -29,15 +190,21 @@ program.command("watch").description("Watch for changes and auto-push").option("
29
190
  program.command("deploy [environment]").description("Deploy to staging or production").option("-p, --promote", "Promote staging to production").action((environment, options) => {
30
191
  deployCommand(environment, options);
31
192
  });
32
- program.command("html <url>").description("Fetch and analyze HTML from a URL").option("-j, --json", "Output as JSON").option("--scripts", "Show only scripts").option("--styles", "Show only styles").action((url, options) => {
193
+ program.command("html <url>").description("Fetch and analyze HTML from a URL").option("-j, --json", "Output as JSON").option("--scripts", "Show only scripts").option("--styles", "Show only styles").option("-s, --save", "Save page structure to context").option("-f, --force", "Force refresh when using --save").action((url, options) => {
33
194
  htmlCommand(url, options);
34
195
  });
196
+ program.command("pages").description("List cached page contexts").option("-j, --json", "Output as JSON").argument("[page]", "Show details for a specific page slug").action((page, options) => {
197
+ pagesCommand({ page, ...options });
198
+ });
35
199
  program.command("status").description("Show current status of scripts and deployments").option("-v, --verbose", "Show more details").action((options) => {
36
200
  statusCommand(options);
37
201
  });
202
+ program.command("context").description("View or edit project context for AI agents").option("-e, --edit", "Open context.md in editor").option("-r, --refresh", "Refresh context from server").option("-j, --json", "Output as JSON").action((options) => {
203
+ contextCommand(options);
204
+ });
38
205
  program.showHelpAfterError();
39
206
  console.log();
40
- console.log(chalk.bold(" Cure Kode CLI"));
41
- console.log(chalk.dim(" Manage JS/CSS for Webflow sites"));
207
+ console.log(chalk2.bold(" Cure Kode CLI"));
208
+ console.log(chalk2.dim(" Manage JS/CSS for Webflow sites"));
42
209
  console.log();
43
210
  program.parse();
package/dist/index.d.ts CHANGED
@@ -206,6 +206,8 @@ declare function htmlCommand(url: string, options?: {
206
206
  json?: boolean;
207
207
  scripts?: boolean;
208
208
  styles?: boolean;
209
+ save?: boolean;
210
+ force?: boolean;
209
211
  }): Promise<void>;
210
212
 
211
213
  /**
@@ -215,4 +217,97 @@ declare function statusCommand(options?: {
215
217
  verbose?: boolean;
216
218
  }): Promise<void>;
217
219
 
218
- export { type CdnDeployment, type CdnPage, type CdnScript, type CdnSite, KodeApiClient, KodeApiError, type ParsedHtmlResult, type ProjectConfig, createApiClient, deployCommand, findProjectRoot, getApiKey, getApiUrl, getProjectConfig, getScriptsDir, htmlCommand, initCommand, pullCommand, pushCommand, saveProjectConfig, setGlobalConfig, statusCommand, watchCommand };
220
+ interface ContextOptions {
221
+ edit?: boolean;
222
+ refresh?: boolean;
223
+ json?: boolean;
224
+ }
225
+ /**
226
+ * Context command - View or edit project context
227
+ */
228
+ declare function contextCommand(options: ContextOptions): Promise<void>;
229
+
230
+ /**
231
+ * Kode Context - Dynamic project state for AI agents
232
+ */
233
+ interface KodeSession {
234
+ date: string;
235
+ agent: string;
236
+ task: string;
237
+ changes: string[];
238
+ }
239
+ interface KodeScriptContext {
240
+ slug: string;
241
+ type: 'javascript' | 'css';
242
+ scope: 'global' | 'page-specific';
243
+ purpose?: string;
244
+ }
245
+ interface KodePageContext {
246
+ slug: string;
247
+ url: string;
248
+ title?: string;
249
+ sections: string;
250
+ ctas?: string;
251
+ forms?: string;
252
+ cms?: string;
253
+ notes?: string[];
254
+ }
255
+ interface KodeContext {
256
+ site: {
257
+ name: string;
258
+ slug: string;
259
+ domain?: string;
260
+ stagingDomain?: string;
261
+ };
262
+ scripts: KodeScriptContext[];
263
+ pages: KodePageContext[];
264
+ notes: string[];
265
+ sessions: KodeSession[];
266
+ lastUpdated: string;
267
+ updatedBy: string;
268
+ }
269
+ /**
270
+ * Get path to context.md
271
+ */
272
+ declare function getContextPath(projectRoot: string): string;
273
+ /**
274
+ * Parse context.md markdown into structured data
275
+ */
276
+ declare function parseContext(content: string): KodeContext;
277
+ /**
278
+ * Serialize context to markdown
279
+ */
280
+ declare function serializeContext(context: KodeContext): string;
281
+ /**
282
+ * Read context from project
283
+ */
284
+ declare function readContext(projectRoot: string): KodeContext | null;
285
+ /**
286
+ * Write context to project
287
+ */
288
+ declare function writeContext(projectRoot: string, context: KodeContext): void;
289
+ /**
290
+ * Add a note to context
291
+ */
292
+ declare function appendNote(projectRoot: string, note: string, agent?: string): void;
293
+ /**
294
+ * Add a session to context
295
+ */
296
+ declare function addSession(projectRoot: string, session: Omit<KodeSession, 'date'>, agent?: string): void;
297
+ /**
298
+ * Update a script's purpose
299
+ */
300
+ declare function updateScriptPurpose(projectRoot: string, slug: string, purpose: string, agent?: string): void;
301
+ /**
302
+ * Generate initial context from config and scripts
303
+ */
304
+ declare function generateInitialContext(config: ProjectConfig, scripts: CdnScript[], site?: {
305
+ domain?: string | null;
306
+ staging_domain?: string | null;
307
+ }): string;
308
+ /**
309
+ * Generate CLAUDE.md content
310
+ */
311
+ declare function generateClaudeMd(siteName: string, scriptsDir?: string): string;
312
+
313
+ export { type CdnDeployment, type CdnPage, type CdnScript, type CdnSite, KodeApiClient, KodeApiError, type KodeContext, type KodeScriptContext, type KodeSession, type ParsedHtmlResult, type ProjectConfig, addSession, appendNote, contextCommand, createApiClient, deployCommand, findProjectRoot, generateClaudeMd, generateInitialContext, getApiKey, getApiUrl, getContextPath, getProjectConfig, getScriptsDir, htmlCommand, initCommand, parseContext, pullCommand, pushCommand, readContext, saveProjectConfig, serializeContext, setGlobalConfig, statusCommand, updateScriptPurpose, watchCommand, writeContext };
package/dist/index.js CHANGED
@@ -1,38 +1,60 @@
1
1
  import {
2
2
  KodeApiClient,
3
3
  KodeApiError,
4
+ addSession,
5
+ appendNote,
6
+ contextCommand,
4
7
  createApiClient,
5
8
  deployCommand,
6
9
  findProjectRoot,
10
+ generateClaudeMd,
11
+ generateInitialContext,
7
12
  getApiKey,
8
13
  getApiUrl,
14
+ getContextPath,
9
15
  getProjectConfig,
10
16
  getScriptsDir,
11
17
  htmlCommand,
12
18
  initCommand,
19
+ parseContext,
13
20
  pullCommand,
14
21
  pushCommand,
22
+ readContext,
15
23
  saveProjectConfig,
24
+ serializeContext,
16
25
  setGlobalConfig,
17
26
  statusCommand,
18
- watchCommand
19
- } from "./chunk-NWXEBN2N.js";
27
+ updateScriptPurpose,
28
+ watchCommand,
29
+ writeContext
30
+ } from "./chunk-LYIXUQOG.js";
20
31
  export {
21
32
  KodeApiClient,
22
33
  KodeApiError,
34
+ addSession,
35
+ appendNote,
36
+ contextCommand,
23
37
  createApiClient,
24
38
  deployCommand,
25
39
  findProjectRoot,
40
+ generateClaudeMd,
41
+ generateInitialContext,
26
42
  getApiKey,
27
43
  getApiUrl,
44
+ getContextPath,
28
45
  getProjectConfig,
29
46
  getScriptsDir,
30
47
  htmlCommand,
31
48
  initCommand,
49
+ parseContext,
32
50
  pullCommand,
33
51
  pushCommand,
52
+ readContext,
34
53
  saveProjectConfig,
54
+ serializeContext,
35
55
  setGlobalConfig,
36
56
  statusCommand,
37
- watchCommand
57
+ updateScriptPurpose,
58
+ watchCommand,
59
+ writeContext
38
60
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@curenorway/kode-cli",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "CLI tool for Cure Kode - manage JS/CSS scripts for Webflow sites",
5
5
  "type": "module",
6
6
  "bin": {