clavix 5.5.1 → 5.6.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/cli/commands/init.d.ts +1 -0
- package/dist/cli/commands/init.js +24 -4
- package/dist/cli/commands/update.js +3 -6
- package/dist/constants.d.ts +0 -11
- package/dist/constants.js +0 -16
- package/dist/core/adapter-registry.d.ts +5 -0
- package/dist/core/adapter-registry.js +5 -0
- package/dist/core/adapters/agents-md-generator.js +2 -1
- package/dist/core/adapters/copilot-instructions-generator.js +2 -1
- package/dist/core/adapters/instructions-generator.js +3 -2
- package/dist/core/adapters/octo-md-generator.js +2 -1
- package/dist/core/adapters/warp-md-generator.js +2 -1
- package/dist/core/doc-injector.js +16 -7
- package/dist/core/template-assembler.d.ts +2 -0
- package/dist/core/template-assembler.js +26 -5
- package/dist/templates/agents/agents.md +4 -0
- package/dist/templates/instructions/QUICKSTART.md +65 -0
- package/dist/templates/slash-commands/_canonical/improve.md +4 -4
- package/dist/templates/slash-commands/_canonical/prd.md +10 -4
- package/dist/templates/slash-commands/_canonical/refine.md +612 -0
- package/dist/templates/slash-commands/_components/MANIFEST.md +15 -1
- package/dist/templates/slash-commands/_components/agent-protocols/self-correction-protocol.md +21 -0
- package/dist/templates/slash-commands/_components/agent-protocols/state-assertion.md +12 -0
- package/dist/templates/slash-commands/_components/sections/prd-examples.md +22 -0
- package/dist/utils/agent-error-messages.d.ts +25 -0
- package/dist/utils/agent-error-messages.js +69 -1
- package/dist/utils/integration-selector.d.ts +12 -0
- package/dist/utils/integration-selector.js +19 -2
- package/dist/utils/toml-templates.js +3 -2
- package/dist/utils/version.d.ts +0 -5
- package/dist/utils/version.js +0 -14
- package/oclif.manifest.json +1 -1
- package/package.json +1 -1
|
@@ -2,7 +2,10 @@ import { Command } from '@oclif/core';
|
|
|
2
2
|
import inquirer from 'inquirer';
|
|
3
3
|
import chalk from 'chalk';
|
|
4
4
|
import * as path from 'path';
|
|
5
|
+
import { fileURLToPath } from 'url';
|
|
5
6
|
import { AgentManager } from '../../core/agent-manager.js';
|
|
7
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
8
|
+
const __dirname = path.dirname(__filename);
|
|
6
9
|
import { DocInjector } from '../../core/doc-injector.js';
|
|
7
10
|
import { AgentsMdGenerator } from '../../core/adapters/agents-md-generator.js';
|
|
8
11
|
import { OctoMdGenerator } from '../../core/adapters/octo-md-generator.js';
|
|
@@ -15,6 +18,7 @@ import { GeminiAdapter } from '../../core/adapters/gemini-adapter.js';
|
|
|
15
18
|
import { QwenAdapter } from '../../core/adapters/qwen-adapter.js';
|
|
16
19
|
import { loadCommandTemplates } from '../../utils/template-loader.js';
|
|
17
20
|
import { collectLegacyCommandFiles } from '../../utils/legacy-command-cleanup.js';
|
|
21
|
+
import { CLAVIX_BLOCK_START, CLAVIX_BLOCK_END } from '../../constants.js';
|
|
18
22
|
export default class Init extends Command {
|
|
19
23
|
static description = 'Initialize Clavix in the current project';
|
|
20
24
|
static examples = ['<%= config.bin %> <%= command.id %>'];
|
|
@@ -76,8 +80,11 @@ export default class Init extends Command {
|
|
|
76
80
|
// Select integrations using shared utility
|
|
77
81
|
console.log(chalk.gray('Select AI development tools to support:\n'));
|
|
78
82
|
console.log(chalk.gray('(Space to select, Enter to confirm)\n'));
|
|
79
|
-
|
|
80
|
-
const
|
|
83
|
+
console.log(chalk.cyan('ℹ'), chalk.gray('AGENTS.md is always enabled to provide universal agent guidance.\n'));
|
|
84
|
+
const { selectIntegrations, ensureMandatoryIntegrations } = await import('../../utils/integration-selector.js');
|
|
85
|
+
const userSelectedIntegrations = await selectIntegrations(agentManager, existingIntegrations);
|
|
86
|
+
// Always include AGENTS.md
|
|
87
|
+
const selectedIntegrations = ensureMandatoryIntegrations(userSelectedIntegrations);
|
|
81
88
|
if (!selectedIntegrations || selectedIntegrations.length === 0) {
|
|
82
89
|
console.log(chalk.red('\n✗ No integrations selected\n'));
|
|
83
90
|
return;
|
|
@@ -153,8 +160,9 @@ export default class Init extends Command {
|
|
|
153
160
|
// Generate config
|
|
154
161
|
console.log(chalk.cyan('⚙️ Generating configuration...'));
|
|
155
162
|
await this.generateConfig(selectedIntegrations);
|
|
156
|
-
// Generate INSTRUCTIONS.md
|
|
163
|
+
// Generate INSTRUCTIONS.md and QUICKSTART.md
|
|
157
164
|
await this.generateInstructions();
|
|
165
|
+
await this.generateQuickstart();
|
|
158
166
|
// Generate commands for each selected integration
|
|
159
167
|
console.log(chalk.cyan(`\n📝 Generating commands for ${selectedIntegrations.length} integration(s)...\n`));
|
|
160
168
|
for (const integrationName of selectedIntegrations) {
|
|
@@ -553,8 +561,20 @@ To reconfigure integrations, run \`clavix init\` again.
|
|
|
553
561
|
}
|
|
554
562
|
}
|
|
555
563
|
extractClavixBlock(content) {
|
|
556
|
-
const
|
|
564
|
+
const regex = new RegExp(`${CLAVIX_BLOCK_START}([\\s\\S]*?)${CLAVIX_BLOCK_END}`);
|
|
565
|
+
const match = content.match(regex);
|
|
557
566
|
return match ? match[1].trim() : content;
|
|
558
567
|
}
|
|
568
|
+
async generateQuickstart() {
|
|
569
|
+
const quickstartPath = path.join(__dirname, '..', '..', 'templates', 'instructions', 'QUICKSTART.md');
|
|
570
|
+
try {
|
|
571
|
+
const quickstartContent = await FileSystem.readFile(quickstartPath);
|
|
572
|
+
await FileSystem.writeFileAtomic('.clavix/QUICKSTART.md', quickstartContent);
|
|
573
|
+
}
|
|
574
|
+
catch {
|
|
575
|
+
// QUICKSTART.md template not found or write failed, skip silently
|
|
576
|
+
// This can happen in test environments or custom installations
|
|
577
|
+
}
|
|
578
|
+
}
|
|
559
579
|
}
|
|
560
580
|
//# sourceMappingURL=init.js.map
|
|
@@ -3,8 +3,6 @@ import chalk from 'chalk';
|
|
|
3
3
|
import inquirer from 'inquirer';
|
|
4
4
|
import fs from 'fs-extra';
|
|
5
5
|
import * as path from 'path';
|
|
6
|
-
import { fileURLToPath } from 'url';
|
|
7
|
-
import { dirname } from 'path';
|
|
8
6
|
import { DocInjector } from '../../core/doc-injector.js';
|
|
9
7
|
import { AgentManager } from '../../core/agent-manager.js';
|
|
10
8
|
import { AgentsMdGenerator } from '../../core/adapters/agents-md-generator.js';
|
|
@@ -12,8 +10,7 @@ import { OctoMdGenerator } from '../../core/adapters/octo-md-generator.js';
|
|
|
12
10
|
import { WarpMdGenerator } from '../../core/adapters/warp-md-generator.js';
|
|
13
11
|
import { InstructionsGenerator } from '../../core/adapters/instructions-generator.js';
|
|
14
12
|
import { collectLegacyCommandFiles } from '../../utils/legacy-command-cleanup.js';
|
|
15
|
-
|
|
16
|
-
const _dirname = dirname(__filename); // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
13
|
+
import { CLAVIX_BLOCK_START, CLAVIX_BLOCK_END } from '../../constants.js';
|
|
17
14
|
export default class Update extends Command {
|
|
18
15
|
static description = 'Update managed blocks and slash commands';
|
|
19
16
|
static examples = [
|
|
@@ -135,8 +132,8 @@ export default class Update extends Command {
|
|
|
135
132
|
const currentContent = fs.readFileSync(claudePath, 'utf-8');
|
|
136
133
|
if (force || !this.hasUpToDateBlock(currentContent, claudeContent)) {
|
|
137
134
|
await DocInjector.injectBlock(claudePath, claudeContent, {
|
|
138
|
-
startMarker:
|
|
139
|
-
endMarker:
|
|
135
|
+
startMarker: CLAVIX_BLOCK_START,
|
|
136
|
+
endMarker: CLAVIX_BLOCK_END,
|
|
140
137
|
});
|
|
141
138
|
this.log(chalk.gray(' ✓ Updated CLAUDE.md'));
|
|
142
139
|
updated++;
|
package/dist/constants.d.ts
CHANGED
|
@@ -2,17 +2,6 @@
|
|
|
2
2
|
* Clavix constants and magic values
|
|
3
3
|
* Centralizes hardcoded values for maintainability
|
|
4
4
|
*/
|
|
5
|
-
export declare const BACKUP_EXTENSION = ".backup";
|
|
6
|
-
export declare const SEPARATOR_WIDTH = 50;
|
|
7
|
-
export declare const SEPARATOR_CHAR = "\u2500";
|
|
8
5
|
export declare const CLAVIX_BLOCK_START = "<!-- CLAVIX:START -->";
|
|
9
6
|
export declare const CLAVIX_BLOCK_END = "<!-- CLAVIX:END -->";
|
|
10
|
-
export declare const WINDSURF_CHAR_LIMIT = 12000;
|
|
11
|
-
export declare const DEPTH_STANDARD = "standard";
|
|
12
|
-
export declare const DEPTH_COMPREHENSIVE = "comprehensive";
|
|
13
|
-
export declare const CLAVIX_CONFIG_DIR = ".clavix";
|
|
14
|
-
export declare const CLAVIX_CONFIG_FILE = "config.json";
|
|
15
|
-
export declare const CLAVIX_OUTPUTS_DIR = "outputs";
|
|
16
|
-
export declare const CLAVIX_PROMPTS_DIR = "prompts";
|
|
17
|
-
export declare const CLAVIX_TEMPLATES_DIR = "templates";
|
|
18
7
|
//# sourceMappingURL=constants.d.ts.map
|
package/dist/constants.js
CHANGED
|
@@ -2,23 +2,7 @@
|
|
|
2
2
|
* Clavix constants and magic values
|
|
3
3
|
* Centralizes hardcoded values for maintainability
|
|
4
4
|
*/
|
|
5
|
-
// File system
|
|
6
|
-
export const BACKUP_EXTENSION = '.backup';
|
|
7
|
-
// CLI formatting
|
|
8
|
-
export const SEPARATOR_WIDTH = 50;
|
|
9
|
-
export const SEPARATOR_CHAR = '─';
|
|
10
5
|
// Clavix managed block markers
|
|
11
6
|
export const CLAVIX_BLOCK_START = '<!-- CLAVIX:START -->';
|
|
12
7
|
export const CLAVIX_BLOCK_END = '<!-- CLAVIX:END -->';
|
|
13
|
-
// Adapter-specific limits
|
|
14
|
-
export const WINDSURF_CHAR_LIMIT = 12000;
|
|
15
|
-
// Depth terminology (canonical)
|
|
16
|
-
export const DEPTH_STANDARD = 'standard';
|
|
17
|
-
export const DEPTH_COMPREHENSIVE = 'comprehensive';
|
|
18
|
-
// File patterns
|
|
19
|
-
export const CLAVIX_CONFIG_DIR = '.clavix';
|
|
20
|
-
export const CLAVIX_CONFIG_FILE = 'config.json';
|
|
21
|
-
export const CLAVIX_OUTPUTS_DIR = 'outputs';
|
|
22
|
-
export const CLAVIX_PROMPTS_DIR = 'prompts';
|
|
23
|
-
export const CLAVIX_TEMPLATES_DIR = 'templates';
|
|
24
8
|
//# sourceMappingURL=constants.js.map
|
|
@@ -7,6 +7,11 @@
|
|
|
7
7
|
* For adapters requiring custom behavior (TOML format, doc injection),
|
|
8
8
|
* dedicated adapter classes still exist.
|
|
9
9
|
*
|
|
10
|
+
* NOTE: AGENTS.md is a mandatory integration that is always enabled by default.
|
|
11
|
+
* It provides universal agent guidance that all AI tools can read. The AGENTS.md
|
|
12
|
+
* adapter is handled separately via AgentsMdGenerator and is automatically
|
|
13
|
+
* included by ensureMandatoryIntegrations() in integration-selector.ts.
|
|
14
|
+
*
|
|
10
15
|
* @since v5.3.0
|
|
11
16
|
*/
|
|
12
17
|
import { AdapterConfig } from '../types/adapter-config.js';
|
|
@@ -7,6 +7,11 @@
|
|
|
7
7
|
* For adapters requiring custom behavior (TOML format, doc injection),
|
|
8
8
|
* dedicated adapter classes still exist.
|
|
9
9
|
*
|
|
10
|
+
* NOTE: AGENTS.md is a mandatory integration that is always enabled by default.
|
|
11
|
+
* It provides universal agent guidance that all AI tools can read. The AGENTS.md
|
|
12
|
+
* adapter is handled separately via AgentsMdGenerator and is automatically
|
|
13
|
+
* included by ensureMandatoryIntegrations() in integration-selector.ts.
|
|
14
|
+
*
|
|
10
15
|
* @since v5.3.0
|
|
11
16
|
*/
|
|
12
17
|
import { DEFAULT_MD_FEATURES, DEFAULT_TOML_FEATURES, } from '../types/adapter-config.js';
|
|
@@ -3,6 +3,7 @@ import { fileURLToPath } from 'url';
|
|
|
3
3
|
import { dirname } from 'path';
|
|
4
4
|
import { FileSystem } from '../../utils/file-system.js';
|
|
5
5
|
import { DocInjector } from '../doc-injector.js';
|
|
6
|
+
import { DataError } from '../../types/errors.js';
|
|
6
7
|
const __filename = fileURLToPath(import.meta.url);
|
|
7
8
|
const __dirname = dirname(__filename);
|
|
8
9
|
/**
|
|
@@ -17,7 +18,7 @@ export class AgentsMdGenerator {
|
|
|
17
18
|
static async generate() {
|
|
18
19
|
const templatePath = path.join(__dirname, '../../templates/agents/agents.md');
|
|
19
20
|
if (!(await FileSystem.exists(templatePath))) {
|
|
20
|
-
throw new
|
|
21
|
+
throw new DataError(`AGENTS.md template not found at ${templatePath}`, "Check Clavix installation or run 'clavix update'");
|
|
21
22
|
}
|
|
22
23
|
const template = await FileSystem.readFile(templatePath);
|
|
23
24
|
await DocInjector.injectBlock(this.TARGET_FILE, template, {
|
|
@@ -3,6 +3,7 @@ import { fileURLToPath } from 'url';
|
|
|
3
3
|
import { dirname } from 'path';
|
|
4
4
|
import { FileSystem } from '../../utils/file-system.js';
|
|
5
5
|
import { DocInjector } from '../doc-injector.js';
|
|
6
|
+
import { DataError } from '../../types/errors.js';
|
|
6
7
|
const __filename = fileURLToPath(import.meta.url);
|
|
7
8
|
const __dirname = dirname(__filename);
|
|
8
9
|
/**
|
|
@@ -17,7 +18,7 @@ export class CopilotInstructionsGenerator {
|
|
|
17
18
|
static async generate() {
|
|
18
19
|
const templatePath = path.join(__dirname, '../../templates/agents/copilot-instructions.md');
|
|
19
20
|
if (!(await FileSystem.exists(templatePath))) {
|
|
20
|
-
throw new
|
|
21
|
+
throw new DataError(`Copilot instructions template not found at ${templatePath}`, "Check Clavix installation or run 'clavix update'");
|
|
21
22
|
}
|
|
22
23
|
const template = await FileSystem.readFile(templatePath);
|
|
23
24
|
// Ensure .github directory exists
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { FileSystem } from '../../utils/file-system.js';
|
|
2
2
|
import { TemplateAssembler } from '../template-assembler.js';
|
|
3
3
|
import { CommandTransformer } from '../command-transformer.js';
|
|
4
|
+
import { DataError } from '../../types/errors.js';
|
|
4
5
|
import * as path from 'path';
|
|
5
6
|
import { fileURLToPath } from 'url';
|
|
6
7
|
import { dirname } from 'path';
|
|
@@ -28,7 +29,7 @@ export class InstructionsGenerator {
|
|
|
28
29
|
const staticInstructionsPath = path.join(__dirname, '../../templates/instructions');
|
|
29
30
|
// Check if static template exists
|
|
30
31
|
if (!(await FileSystem.exists(staticInstructionsPath))) {
|
|
31
|
-
throw new
|
|
32
|
+
throw new DataError(`.clavix/instructions static files not found at ${staticInstructionsPath}`, "Check Clavix installation or run 'clavix update'");
|
|
32
33
|
}
|
|
33
34
|
// Create target directory
|
|
34
35
|
await FileSystem.ensureDir(this.TARGET_DIR);
|
|
@@ -70,7 +71,7 @@ export class InstructionsGenerator {
|
|
|
70
71
|
const canonicalPath = path.join(__dirname, '../../templates/slash-commands/_canonical');
|
|
71
72
|
const workflowsTarget = path.join(this.TARGET_DIR, 'workflows');
|
|
72
73
|
if (!(await FileSystem.exists(canonicalPath))) {
|
|
73
|
-
throw new
|
|
74
|
+
throw new DataError(`Canonical templates not found at ${canonicalPath}`, "Check Clavix installation or run 'clavix update'");
|
|
74
75
|
}
|
|
75
76
|
// Create workflows directory
|
|
76
77
|
await FileSystem.ensureDir(workflowsTarget);
|
|
@@ -3,6 +3,7 @@ import { fileURLToPath } from 'url';
|
|
|
3
3
|
import { dirname } from 'path';
|
|
4
4
|
import { FileSystem } from '../../utils/file-system.js';
|
|
5
5
|
import { DocInjector } from '../doc-injector.js';
|
|
6
|
+
import { DataError } from '../../types/errors.js';
|
|
6
7
|
const __filename = fileURLToPath(import.meta.url);
|
|
7
8
|
const __dirname = dirname(__filename);
|
|
8
9
|
/**
|
|
@@ -17,7 +18,7 @@ export class OctoMdGenerator {
|
|
|
17
18
|
static async generate() {
|
|
18
19
|
const templatePath = path.join(__dirname, '../../templates/agents/octo.md');
|
|
19
20
|
if (!(await FileSystem.exists(templatePath))) {
|
|
20
|
-
throw new
|
|
21
|
+
throw new DataError(`OCTO.md template not found at ${templatePath}`, "Check Clavix installation or run 'clavix update'");
|
|
21
22
|
}
|
|
22
23
|
const template = await FileSystem.readFile(templatePath);
|
|
23
24
|
await DocInjector.injectBlock(this.TARGET_FILE, template, {
|
|
@@ -3,6 +3,7 @@ import { fileURLToPath } from 'url';
|
|
|
3
3
|
import { dirname } from 'path';
|
|
4
4
|
import { FileSystem } from '../../utils/file-system.js';
|
|
5
5
|
import { DocInjector } from '../doc-injector.js';
|
|
6
|
+
import { DataError } from '../../types/errors.js';
|
|
6
7
|
const __filename = fileURLToPath(import.meta.url);
|
|
7
8
|
const __dirname = dirname(__filename);
|
|
8
9
|
/**
|
|
@@ -17,7 +18,7 @@ export class WarpMdGenerator {
|
|
|
17
18
|
static async generate() {
|
|
18
19
|
const templatePath = path.join(__dirname, '../../templates/agents/warp.md');
|
|
19
20
|
if (!(await FileSystem.exists(templatePath))) {
|
|
20
|
-
throw new
|
|
21
|
+
throw new DataError(`WARP.md template not found at ${templatePath}`, "Check Clavix installation or run 'clavix update'");
|
|
21
22
|
}
|
|
22
23
|
const template = await FileSystem.readFile(templatePath);
|
|
23
24
|
await DocInjector.injectBlock(this.TARGET_FILE, template, {
|
|
@@ -3,12 +3,13 @@ import { FileSystem } from '../utils/file-system.js';
|
|
|
3
3
|
import { DataError } from '../types/errors.js';
|
|
4
4
|
import { escapeRegex } from '../utils/string-utils.js';
|
|
5
5
|
import { logger } from '../utils/logger.js';
|
|
6
|
+
import { CLAVIX_BLOCK_START, CLAVIX_BLOCK_END } from '../constants.js';
|
|
6
7
|
/**
|
|
7
8
|
* DocInjector - manages injection and updating of managed blocks in documentation files
|
|
8
9
|
*/
|
|
9
10
|
export class DocInjector {
|
|
10
|
-
static DEFAULT_START_MARKER =
|
|
11
|
-
static DEFAULT_END_MARKER =
|
|
11
|
+
static DEFAULT_START_MARKER = CLAVIX_BLOCK_START;
|
|
12
|
+
static DEFAULT_END_MARKER = CLAVIX_BLOCK_END;
|
|
12
13
|
/**
|
|
13
14
|
* Inject or update managed block in a file
|
|
14
15
|
*/
|
|
@@ -168,6 +169,8 @@ For more information, run \`clavix --help\` in your terminal.
|
|
|
168
169
|
|
|
169
170
|
This project uses Clavix for prompt improvement and PRD generation. The following slash commands are available:
|
|
170
171
|
|
|
172
|
+
> **Command Format:** Commands shown with colon (\`:\`) format. Some tools use hyphen (\`-\`): Claude Code uses \`/clavix:improve\`, Cursor uses \`/clavix-improve\`. Your tool autocompletes the correct format.
|
|
173
|
+
|
|
171
174
|
### Prompt Optimization
|
|
172
175
|
|
|
173
176
|
#### /clavix:improve [prompt]
|
|
@@ -184,7 +187,7 @@ Generate an optimized implementation task breakdown from your PRD. Creates a pha
|
|
|
184
187
|
#### /clavix:implement
|
|
185
188
|
Execute tasks or prompts with AI assistance. Auto-detects source: tasks.md (from PRD workflow) or prompts/ (from improve workflow). Supports automatic git commits and progress tracking.
|
|
186
189
|
|
|
187
|
-
Use \`--latest\` to
|
|
190
|
+
Use \`--latest\` to implement most recent prompt, \`--tasks\` to force task mode.
|
|
188
191
|
|
|
189
192
|
### Session Management
|
|
190
193
|
|
|
@@ -194,6 +197,11 @@ Enter conversational mode for iterative prompt development. Discuss your require
|
|
|
194
197
|
#### /clavix:summarize
|
|
195
198
|
Analyze the current conversation and extract key requirements into a structured prompt and mini-PRD.
|
|
196
199
|
|
|
200
|
+
### Refinement
|
|
201
|
+
|
|
202
|
+
#### /clavix:refine
|
|
203
|
+
Refine existing PRD or prompt through continued discussion. Detects available PRDs and saved prompts, then guides you through updating them with tracked changes.
|
|
204
|
+
|
|
197
205
|
### Agentic Utilities
|
|
198
206
|
|
|
199
207
|
These utilities provide structured workflows for common tasks. Invoke them using the slash commands below:
|
|
@@ -207,10 +215,11 @@ These utilities provide structured workflows for common tasks. Invoke them using
|
|
|
207
215
|
|
|
208
216
|
**Recommended Workflow:**
|
|
209
217
|
1. Start with \`/clavix:prd\` or \`/clavix:start\` for complex features
|
|
210
|
-
2.
|
|
211
|
-
3.
|
|
212
|
-
4.
|
|
213
|
-
5.
|
|
218
|
+
2. Refine requirements with \`/clavix:refine\` as needed
|
|
219
|
+
3. Generate tasks with \`/clavix:plan\`
|
|
220
|
+
4. Implement with \`/clavix:implement\`
|
|
221
|
+
5. Verify with \`/clavix:verify\`
|
|
222
|
+
6. Archive when complete with \`/clavix:archive\`
|
|
214
223
|
|
|
215
224
|
**Pro tip**: Start complex features with \`/clavix:prd\` or \`/clavix:start\` to ensure clear requirements before implementation.`;
|
|
216
225
|
}
|
|
@@ -51,6 +51,8 @@ export declare class TemplateAssembler {
|
|
|
51
51
|
hasIncludes(content: string): boolean;
|
|
52
52
|
/**
|
|
53
53
|
* Process all include markers in content
|
|
54
|
+
* @param content - The template content to process
|
|
55
|
+
* @param depth - Current nesting depth (for circular include protection)
|
|
54
56
|
*/
|
|
55
57
|
private processIncludes;
|
|
56
58
|
/**
|
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
import { promises as fs } from 'fs';
|
|
2
2
|
import * as path from 'path';
|
|
3
|
+
import { DataError } from '../types/errors.js';
|
|
4
|
+
/**
|
|
5
|
+
* Maximum depth for nested {{INCLUDE:}} directives
|
|
6
|
+
* Prevents infinite loops from circular includes
|
|
7
|
+
*/
|
|
8
|
+
const MAX_INCLUDE_DEPTH = 10;
|
|
9
|
+
/**
|
|
10
|
+
* Depth at which to log a warning about deep nesting
|
|
11
|
+
*/
|
|
12
|
+
const DEPTH_WARNING_THRESHOLD = 5;
|
|
3
13
|
/**
|
|
4
14
|
* TemplateAssembler - v4.0 Template Modularity System
|
|
5
15
|
*
|
|
@@ -30,13 +40,13 @@ export class TemplateAssembler {
|
|
|
30
40
|
async assembleTemplate(templatePath) {
|
|
31
41
|
const fullPath = path.join(this.templatesBasePath, 'slash-commands', '_canonical', templatePath);
|
|
32
42
|
const content = await this.loadFile(fullPath);
|
|
33
|
-
return this.processIncludes(content);
|
|
43
|
+
return this.processIncludes(content, 0);
|
|
34
44
|
}
|
|
35
45
|
/**
|
|
36
46
|
* Assemble template from raw content string
|
|
37
47
|
*/
|
|
38
48
|
async assembleFromContent(content) {
|
|
39
|
-
return this.processIncludes(content);
|
|
49
|
+
return this.processIncludes(content, 0);
|
|
40
50
|
}
|
|
41
51
|
/**
|
|
42
52
|
* Check if a template contains include markers
|
|
@@ -46,8 +56,19 @@ export class TemplateAssembler {
|
|
|
46
56
|
}
|
|
47
57
|
/**
|
|
48
58
|
* Process all include markers in content
|
|
59
|
+
* @param content - The template content to process
|
|
60
|
+
* @param depth - Current nesting depth (for circular include protection)
|
|
49
61
|
*/
|
|
50
|
-
async processIncludes(content) {
|
|
62
|
+
async processIncludes(content, depth) {
|
|
63
|
+
// Circular include protection
|
|
64
|
+
if (depth > MAX_INCLUDE_DEPTH) {
|
|
65
|
+
throw new DataError(`Maximum include depth (${MAX_INCLUDE_DEPTH}) exceeded`, 'Check for circular {{INCLUDE:}} references in templates');
|
|
66
|
+
}
|
|
67
|
+
// Warn about deep nesting
|
|
68
|
+
if (depth === DEPTH_WARNING_THRESHOLD) {
|
|
69
|
+
console.warn(`[TemplateAssembler] Warning: Include depth ${depth} reached. ` +
|
|
70
|
+
'Consider flattening template structure.');
|
|
71
|
+
}
|
|
51
72
|
const includedComponents = [];
|
|
52
73
|
const missingComponents = [];
|
|
53
74
|
const variablesUsed = new Set();
|
|
@@ -86,9 +107,9 @@ export class TemplateAssembler {
|
|
|
86
107
|
processedContent = processedContent.replace(fullMatch, `<!-- MISSING COMPONENT: ${componentPath} -->`);
|
|
87
108
|
}
|
|
88
109
|
}
|
|
89
|
-
// Process nested includes (recursive)
|
|
110
|
+
// Process nested includes (recursive with depth tracking)
|
|
90
111
|
if (this.hasIncludes(processedContent)) {
|
|
91
|
-
const nestedResult = await this.processIncludes(processedContent);
|
|
112
|
+
const nestedResult = await this.processIncludes(processedContent, depth + 1);
|
|
92
113
|
processedContent = nestedResult.content;
|
|
93
114
|
includedComponents.push(...nestedResult.includedComponents);
|
|
94
115
|
missingComponents.push(...nestedResult.missingComponents);
|
|
@@ -60,6 +60,7 @@ For complete step-by-step workflows, see `.clavix/instructions/`:
|
|
|
60
60
|
| "create a PRD", "product requirements" | PRD mode → Socratic questioning | `workflows/prd.md` |
|
|
61
61
|
| "let's discuss", "not sure what I want" | Conversational mode → Start gathering | `workflows/start.md` |
|
|
62
62
|
| "summarize our conversation" | Extract mode → Analyze thread | `workflows/summarize.md` |
|
|
63
|
+
| "refine", "update PRD", "change requirements", "modify prompt" | Refine mode → Update existing content | `workflows/refine.md` |
|
|
63
64
|
| "verify", "check my implementation" | Verify mode → Implementation verification | `core/verification.md` |
|
|
64
65
|
|
|
65
66
|
**When detected:** Reference the corresponding `.clavix/instructions/workflows/{workflow}.md` file.
|
|
@@ -79,6 +80,8 @@ For complete step-by-step workflows, see `.clavix/instructions/`:
|
|
|
79
80
|
### Workflow Commands (Slash Commands)
|
|
80
81
|
All workflows are executed via slash commands that AI agents read and follow:
|
|
81
82
|
|
|
83
|
+
> **Command Format:** Commands shown with colon (`:`) format. Some tools use hyphen (`-`): Claude Code uses `/clavix:improve`, Cursor uses `/clavix-improve`. Your tool autocompletes the correct format.
|
|
84
|
+
|
|
82
85
|
| Slash Command | Purpose |
|
|
83
86
|
|---------------|---------|
|
|
84
87
|
| `/clavix:improve` | Optimize prompts (auto-selects depth) |
|
|
@@ -87,6 +90,7 @@ All workflows are executed via slash commands that AI agents read and follow:
|
|
|
87
90
|
| `/clavix:implement` | Execute tasks or prompts (auto-detects source) |
|
|
88
91
|
| `/clavix:start` | Begin conversational session |
|
|
89
92
|
| `/clavix:summarize` | Extract requirements from conversation |
|
|
93
|
+
| `/clavix:refine` | Refine existing PRD or saved prompt |
|
|
90
94
|
|
|
91
95
|
### Agentic Utilities (Project Management)
|
|
92
96
|
These utilities provide structured workflows for project completion:
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# Clavix Quick Reference
|
|
2
|
+
|
|
3
|
+
## Commands at a Glance
|
|
4
|
+
|
|
5
|
+
| Command | Purpose | Mode |
|
|
6
|
+
|---------|---------|------|
|
|
7
|
+
| `/clavix:improve` | Optimize a prompt with auto-depth | Planning |
|
|
8
|
+
| `/clavix:prd` | Generate PRD via strategic questions | Planning |
|
|
9
|
+
| `/clavix:plan` | Create task breakdown from PRD | Planning |
|
|
10
|
+
| `/clavix:implement` | Execute tasks or prompts | Implementation |
|
|
11
|
+
| `/clavix:start` | Begin conversational exploration | Planning |
|
|
12
|
+
| `/clavix:summarize` | Extract requirements from conversation | Planning |
|
|
13
|
+
| `/clavix:refine` | Update existing PRD or prompt | Planning |
|
|
14
|
+
| `/clavix:verify` | Check implementation against requirements | Verification |
|
|
15
|
+
| `/clavix:archive` | Move completed project to archive | Management |
|
|
16
|
+
|
|
17
|
+
> **Command Format:** Commands shown with colon (`:`) format. Some tools use hyphen (`-`): Claude Code uses `/clavix:improve`, Cursor uses `/clavix-improve`. Your tool autocompletes the correct format.
|
|
18
|
+
|
|
19
|
+
## Common Workflows
|
|
20
|
+
|
|
21
|
+
**Quick optimization:**
|
|
22
|
+
```
|
|
23
|
+
/clavix:improve "your prompt here"
|
|
24
|
+
→ /clavix:implement --latest
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
**Full planning cycle:**
|
|
28
|
+
```
|
|
29
|
+
/clavix:prd
|
|
30
|
+
→ /clavix:plan
|
|
31
|
+
→ /clavix:implement
|
|
32
|
+
→ /clavix:verify
|
|
33
|
+
→ /clavix:archive
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
**Exploratory approach:**
|
|
37
|
+
```
|
|
38
|
+
/clavix:start
|
|
39
|
+
→ (conversation)
|
|
40
|
+
→ /clavix:summarize
|
|
41
|
+
→ /clavix:plan
|
|
42
|
+
→ /clavix:implement
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Key Directories
|
|
46
|
+
|
|
47
|
+
- `.clavix/outputs/` — Generated PRDs, tasks, prompts
|
|
48
|
+
- `.clavix/outputs/prompts/` — Saved optimized prompts
|
|
49
|
+
- `.clavix/outputs/archive/` — Archived completed projects
|
|
50
|
+
- `.clavix/instructions/` — Detailed workflow documentation
|
|
51
|
+
|
|
52
|
+
## Mode Boundaries
|
|
53
|
+
|
|
54
|
+
- **Planning Mode** (improve, prd, plan, start, summarize, refine): NO code generation
|
|
55
|
+
- **Implementation Mode** (implement): Code generation ALLOWED
|
|
56
|
+
- **Verification Mode** (verify): Read-only checks
|
|
57
|
+
- **Management Mode** (archive): File organization only
|
|
58
|
+
|
|
59
|
+
## Getting Started
|
|
60
|
+
|
|
61
|
+
1. Run `clavix init` to set up your project
|
|
62
|
+
2. Use `/clavix:improve "your idea"` to optimize a prompt
|
|
63
|
+
3. Use `/clavix:implement --latest` to implement it
|
|
64
|
+
|
|
65
|
+
For detailed documentation, see `.clavix/instructions/` in your project.
|
|
@@ -326,9 +326,9 @@ Before considering this task complete, verify:
|
|
|
326
326
|
|
|
327
327
|
---
|
|
328
328
|
|
|
329
|
-
|
|
329
|
+
**CHECKPOINT:** Analysis Complete
|
|
330
330
|
|
|
331
|
-
|
|
331
|
+
Before proceeding to save, verify you have output ALL of the following:
|
|
332
332
|
|
|
333
333
|
**Standard Depth:**
|
|
334
334
|
- [ ] **Intent Analysis** with type and confidence
|
|
@@ -349,9 +349,9 @@ Before considering this task complete, verify:
|
|
|
349
349
|
|
|
350
350
|
---
|
|
351
351
|
|
|
352
|
-
|
|
352
|
+
**CHECKPOINT:** Saving Protocol (REQUIRED - DO NOT SKIP)
|
|
353
353
|
|
|
354
|
-
|
|
354
|
+
DO NOT output any "saved" message until you have COMPLETED and VERIFIED all save steps.
|
|
355
355
|
|
|
356
356
|
This is a BLOCKING checkpoint. You cannot proceed to the final message until saving is verified.
|
|
357
357
|
|
|
@@ -252,11 +252,17 @@ mkdir -p .clavix/outputs/{sanitized-project-name}
|
|
|
252
252
|
```
|
|
253
253
|
|
|
254
254
|
### Step 5: Verify Files Were Created
|
|
255
|
-
```bash
|
|
256
|
-
ls .clavix/outputs/{project-name}/
|
|
257
|
-
```
|
|
258
255
|
|
|
259
|
-
**
|
|
256
|
+
**Verification Protocol:**
|
|
257
|
+
1. **Immediately after Write**, use Read tool to verify each file:
|
|
258
|
+
- Read `.clavix/outputs/{project-name}/full-prd.md`
|
|
259
|
+
- Confirm content matches what you wrote
|
|
260
|
+
- Read `.clavix/outputs/{project-name}/quick-prd.md`
|
|
261
|
+
- Confirm content matches what you wrote
|
|
262
|
+
|
|
263
|
+
2. **If Read fails**: STOP and report error to user
|
|
264
|
+
|
|
265
|
+
**Expected files**:
|
|
260
266
|
- `full-prd.md`
|
|
261
267
|
- `quick-prd.md`
|
|
262
268
|
|