clavix 1.8.2 → 1.8.3

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.
@@ -10,7 +10,6 @@ export default class Init extends Command {
10
10
  private injectDocumentation;
11
11
  private migrateOldCommands;
12
12
  private extractDescription;
13
- private parseTomlTemplate;
14
13
  private extractClavixBlock;
15
14
  }
16
15
  //# sourceMappingURL=init.d.ts.map
@@ -49,6 +49,7 @@ const file_system_1 = require("../../utils/file-system");
49
49
  const config_1 = require("../../types/config");
50
50
  const gemini_adapter_1 = require("../../core/adapters/gemini-adapter");
51
51
  const qwen_adapter_1 = require("../../core/adapters/qwen-adapter");
52
+ const toml_templates_1 = require("../../utils/toml-templates");
52
53
  class Init extends core_1.Command {
53
54
  async run() {
54
55
  console.log(chalk_1.default.bold.cyan('\nšŸš€ Clavix Initialization\n'));
@@ -366,7 +367,7 @@ See documentation for template format details.
366
367
  const content = await file_system_1.FileSystem.readFile(path.join(templateDir, file));
367
368
  const name = file.slice(0, -extension.length);
368
369
  if (extension === '.toml') {
369
- const parsed = this.parseTomlTemplate(content, name, adapter.name);
370
+ const parsed = (0, toml_templates_1.parseTomlSlashCommand)(content, name, adapter.name);
370
371
  templates.push({
371
372
  name,
372
373
  content: parsed.prompt,
@@ -435,16 +436,6 @@ See documentation for template format details.
435
436
  }
436
437
  return '';
437
438
  }
438
- parseTomlTemplate(content, templateName, providerName) {
439
- const descriptionMatch = content.match(/^\s*description\s*=\s*(['"])(.*?)\1/m);
440
- const promptMatch = content.match(/^\s*prompt\s*=\s*"""([\s\S]*?)"""/m);
441
- if (!promptMatch) {
442
- throw new Error(`Template ${templateName}.toml for ${providerName} is missing a prompt = """ ... """ block.`);
443
- }
444
- const description = descriptionMatch ? descriptionMatch[2] : '';
445
- const prompt = promptMatch[1];
446
- return { description, prompt };
447
- }
448
439
  extractClavixBlock(content) {
449
440
  const match = content.match(/<!-- CLAVIX:START -->([\s\S]*?)<!-- CLAVIX:END -->/);
450
441
  return match ? match[1].trim() : content;
@@ -154,7 +154,7 @@ class Update extends core_1.Command {
154
154
  return updated;
155
155
  }
156
156
  async updateCommands(adapter, force) {
157
- this.log(chalk_1.default.cyan('\nšŸ”§ Updating slash commands...'));
157
+ this.log(chalk_1.default.cyan(`\nšŸ”§ Updating slash commands for ${adapter.displayName}...`));
158
158
  const commandsDir = adapter.getCommandPath();
159
159
  const commandsPath = path.join(process.cwd(), commandsDir);
160
160
  const extension = adapter.fileExtension;
@@ -0,0 +1,10 @@
1
+ export interface ParsedTomlTemplate {
2
+ description: string;
3
+ prompt: string;
4
+ }
5
+ /**
6
+ * Parse TOML-based slash command templates (Gemini/Qwen) and extract metadata.
7
+ * Ensures the resulting prompt body does not include duplicated frontmatter.
8
+ */
9
+ export declare function parseTomlSlashCommand(content: string, templateName: string, providerName: string): ParsedTomlTemplate;
10
+ //# sourceMappingURL=toml-templates.d.ts.map
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseTomlSlashCommand = parseTomlSlashCommand;
4
+ /**
5
+ * Parse TOML-based slash command templates (Gemini/Qwen) and extract metadata.
6
+ * Ensures the resulting prompt body does not include duplicated frontmatter.
7
+ */
8
+ function parseTomlSlashCommand(content, templateName, providerName) {
9
+ let normalized = content.replace(/\r\n/g, '\n').replace(/\r/g, '\n');
10
+ if (normalized.charCodeAt(0) === 0xfeff) {
11
+ normalized = normalized.slice(1);
12
+ }
13
+ const descriptionMatch = normalized.match(/^\s*description\s*=\s*(['"])(.*?)\1\s*$/m);
14
+ const promptHeaderMatch = normalized.match(/^\s*prompt\s*=\s*"""/m);
15
+ if (!promptHeaderMatch || promptHeaderMatch.index === undefined) {
16
+ throw new Error(`Template ${templateName}.toml for ${providerName} is missing a prompt = """ ... """ block.`);
17
+ }
18
+ const bodyStart = promptHeaderMatch.index + promptHeaderMatch[0].length;
19
+ const bodyRemainder = normalized.slice(bodyStart);
20
+ const closingIndex = bodyRemainder.indexOf('"""');
21
+ if (closingIndex === -1) {
22
+ throw new Error(`Template ${templateName}.toml for ${providerName} does not terminate its prompt = """ ... """ block.`);
23
+ }
24
+ let promptBody = bodyRemainder.slice(0, closingIndex);
25
+ const promptLines = promptBody.split('\n');
26
+ while (promptLines.length > 0 && /^\s*(description\s*=|prompt\s*=)/.test(promptLines[0])) {
27
+ promptLines.shift();
28
+ }
29
+ promptBody = promptLines.join('\n').replace(/^\n+/, '').replace(/[\s]+$/, '');
30
+ return {
31
+ description: descriptionMatch ? descriptionMatch[2] : '',
32
+ prompt: promptBody,
33
+ };
34
+ }
35
+ //# sourceMappingURL=toml-templates.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clavix",
3
- "version": "1.8.2",
3
+ "version": "1.8.3",
4
4
  "description": "AI prompt improvement and PRD generation CLI tool for developers",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",