@dedesfr/prompter 0.1.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/AGENTS.md +105 -0
- package/LICENSE +21 -0
- package/README.md +66 -0
- package/bin/prompter.js +3 -0
- package/build.js +20 -0
- package/dist/cli/index.d.ts +2 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +35 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/commands/init.d.ts +10 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +92 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/list.d.ts +9 -0
- package/dist/commands/list.d.ts.map +1 -0
- package/dist/commands/list.js +65 -0
- package/dist/commands/list.js.map +1 -0
- package/dist/commands/update.d.ts +4 -0
- package/dist/commands/update.d.ts.map +1 -0
- package/dist/commands/update.js +38 -0
- package/dist/commands/update.js.map +1 -0
- package/dist/core/config.d.ts +17 -0
- package/dist/core/config.d.ts.map +1 -0
- package/dist/core/config.js +33 -0
- package/dist/core/config.js.map +1 -0
- package/dist/core/configurators/slash/antigravity.d.ts +9 -0
- package/dist/core/configurators/slash/antigravity.d.ts.map +1 -0
- package/dist/core/configurators/slash/antigravity.js +19 -0
- package/dist/core/configurators/slash/antigravity.js.map +1 -0
- package/dist/core/configurators/slash/base.d.ts +19 -0
- package/dist/core/configurators/slash/base.d.ts.map +1 -0
- package/dist/core/configurators/slash/base.js +75 -0
- package/dist/core/configurators/slash/base.js.map +1 -0
- package/dist/core/configurators/slash/claude.d.ts +9 -0
- package/dist/core/configurators/slash/claude.d.ts.map +1 -0
- package/dist/core/configurators/slash/claude.js +19 -0
- package/dist/core/configurators/slash/claude.js.map +1 -0
- package/dist/core/configurators/slash/codex.d.ts +9 -0
- package/dist/core/configurators/slash/codex.d.ts.map +1 -0
- package/dist/core/configurators/slash/codex.js +19 -0
- package/dist/core/configurators/slash/codex.js.map +1 -0
- package/dist/core/configurators/slash/github-copilot.d.ts +9 -0
- package/dist/core/configurators/slash/github-copilot.d.ts.map +1 -0
- package/dist/core/configurators/slash/github-copilot.js +19 -0
- package/dist/core/configurators/slash/github-copilot.js.map +1 -0
- package/dist/core/configurators/slash/index.d.ts +9 -0
- package/dist/core/configurators/slash/index.d.ts.map +1 -0
- package/dist/core/configurators/slash/index.js +9 -0
- package/dist/core/configurators/slash/index.js.map +1 -0
- package/dist/core/configurators/slash/kilocode.d.ts +9 -0
- package/dist/core/configurators/slash/kilocode.d.ts.map +1 -0
- package/dist/core/configurators/slash/kilocode.js +19 -0
- package/dist/core/configurators/slash/kilocode.js.map +1 -0
- package/dist/core/configurators/slash/opencode.d.ts +9 -0
- package/dist/core/configurators/slash/opencode.d.ts.map +1 -0
- package/dist/core/configurators/slash/opencode.js +19 -0
- package/dist/core/configurators/slash/opencode.js.map +1 -0
- package/dist/core/configurators/slash/registry.d.ts +11 -0
- package/dist/core/configurators/slash/registry.d.ts.map +1 -0
- package/dist/core/configurators/slash/registry.js +37 -0
- package/dist/core/configurators/slash/registry.js.map +1 -0
- package/dist/core/templates/agents-template.d.ts +2 -0
- package/dist/core/templates/agents-template.d.ts.map +1 -0
- package/dist/core/templates/agents-template.js +34 -0
- package/dist/core/templates/agents-template.js.map +1 -0
- package/dist/core/templates/index.d.ts +4 -0
- package/dist/core/templates/index.d.ts.map +1 -0
- package/dist/core/templates/index.js +4 -0
- package/dist/core/templates/index.js.map +1 -0
- package/dist/core/templates/project-template.d.ts +2 -0
- package/dist/core/templates/project-template.d.ts.map +1 -0
- package/dist/core/templates/project-template.js +21 -0
- package/dist/core/templates/project-template.js.map +1 -0
- package/dist/core/templates/slash-command-templates.d.ts +7 -0
- package/dist/core/templates/slash-command-templates.d.ts.map +1 -0
- package/dist/core/templates/slash-command-templates.js +54 -0
- package/dist/core/templates/slash-command-templates.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/docs/product-spec.md +151 -0
- package/package.json +50 -0
- package/src/cli/index.ts +40 -0
- package/src/commands/init.ts +103 -0
- package/src/commands/list.ts +84 -0
- package/src/commands/update.ts +41 -0
- package/src/core/config.ts +43 -0
- package/src/core/configurators/slash/antigravity.ts +24 -0
- package/src/core/configurators/slash/base.ts +101 -0
- package/src/core/configurators/slash/claude.ts +24 -0
- package/src/core/configurators/slash/codex.ts +24 -0
- package/src/core/configurators/slash/github-copilot.ts +24 -0
- package/src/core/configurators/slash/index.ts +8 -0
- package/src/core/configurators/slash/kilocode.ts +24 -0
- package/src/core/configurators/slash/opencode.ts +24 -0
- package/src/core/configurators/slash/registry.ts +45 -0
- package/src/core/templates/agents-template.ts +33 -0
- package/src/core/templates/index.ts +3 -0
- package/src/core/templates/project-template.ts +20 -0
- package/src/core/templates/slash-command-templates.ts +58 -0
- package/src/index.ts +1 -0
- package/tsconfig.json +28 -0
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
Product Specification Document
|
|
2
|
+
|
|
3
|
+
### 1. Executive Summary
|
|
4
|
+
- Product name and tagline: **Prompter CLI** — “Enhance prompts directly in your AI coding workflow.”
|
|
5
|
+
- Core value proposition: Turn rough ideas into **structured, professional prompt specifications** and install tool-specific slash-command workflows in local repos.
|
|
6
|
+
- Primary target users: Developers/teams using AI coding assistants who want standardized prompt enhancement workflows.
|
|
7
|
+
- Key differentiators: **Multi-tool workflow generation**, **local-first** (filesystem-only), and **managed template updates** using embedded markers.
|
|
8
|
+
|
|
9
|
+
### 2. Product Overview
|
|
10
|
+
- **Problem Statement:** AI prompt quality is inconsistent; teams need a repeatable way to transform rough ideas into high-quality specs and make them available as slash commands in their tools.
|
|
11
|
+
- **Solution:** A CLI that initializes a project with Prompter context, generates slash-command workflow files for supported AI tools, and helps list enhanced prompts.
|
|
12
|
+
- **Success Metrics:**
|
|
13
|
+
- Successful initialization rate (`prompter init` completes).
|
|
14
|
+
- Number of workflow files created/updated.
|
|
15
|
+
- Number of enhanced prompts listed (`prompter list` output count).
|
|
16
|
+
- **Scope:**
|
|
17
|
+
- **Included:** CLI commands (`init`, `update`, `list`), file templates for workflows, project context file, and detection of enhanced prompts.
|
|
18
|
+
- **Excluded:** Actual prompt enhancement execution (done by the AI tool), remote services, authentication, telemetry.
|
|
19
|
+
|
|
20
|
+
### 3. User Personas
|
|
21
|
+
- **Primary: AI-Enabled Developer**
|
|
22
|
+
- Goals: Quickly bootstrap AI prompt workflows; keep workflows up to date.
|
|
23
|
+
- Pain points: Inconsistent prompt specs; manual setup across tools.
|
|
24
|
+
- **Secondary: Team Lead/Architect**
|
|
25
|
+
- Goals: Standardize AI prompt practices across team repos.
|
|
26
|
+
- Pain points: Tool fragmentation and drift in prompt instructions.
|
|
27
|
+
- **Use Case Scenarios:**
|
|
28
|
+
- New repo bootstrap → run `prompter init` to scaffold workflows.
|
|
29
|
+
- Existing repo update → run `prompter update` to refresh managed sections.
|
|
30
|
+
- Review prompt history → run `prompter list` to see enhanced specs.
|
|
31
|
+
|
|
32
|
+
### 4. Feature Specifications
|
|
33
|
+
|
|
34
|
+
**Feature Name:** CLI Initialization
|
|
35
|
+
- **Description:** Creates `prompter/` directory, `prompter/project.md`, optional `AGENTS.md`, and tool-specific workflow files.
|
|
36
|
+
- **User Flow:**
|
|
37
|
+
1. User runs `prompter init`.
|
|
38
|
+
2. CLI checks if `prompter/` exists; if so, exits with warning.
|
|
39
|
+
3. User selects tools (interactive checkbox) or passes `--tools`.
|
|
40
|
+
4. CLI writes templates and workflow files.
|
|
41
|
+
5. CLI prints next steps.
|
|
42
|
+
- **Acceptance Criteria:**
|
|
43
|
+
- `prompter/` directory created with `project.md`.
|
|
44
|
+
- `AGENTS.md` created only if missing.
|
|
45
|
+
- Tool workflow files created under tool-specific paths.
|
|
46
|
+
- Success message printed.
|
|
47
|
+
- **Priority:** Critical
|
|
48
|
+
- **Dependencies:** `src/commands/init.ts`, `src/core/config.ts`, templates in `src/core/templates/*`, configurators in `src/core/configurators/slash/*`.
|
|
49
|
+
|
|
50
|
+
**Feature Name:** Workflow Update
|
|
51
|
+
- **Description:** Updates managed template sections in existing workflow files for all supported tools.
|
|
52
|
+
- **User Flow:**
|
|
53
|
+
1. User runs `prompter update`.
|
|
54
|
+
2. CLI checks for `prompter/`; if missing, exits with error.
|
|
55
|
+
3. For each tool configurator, updates files containing managed markers.
|
|
56
|
+
4. Outputs updated count.
|
|
57
|
+
- **Acceptance Criteria:**
|
|
58
|
+
- If `prompter/` absent, prints error and sets exit code.
|
|
59
|
+
- If managed markers missing, logs failure for that file.
|
|
60
|
+
- Updates only managed section between markers.
|
|
61
|
+
- **Priority:** High
|
|
62
|
+
- **Dependencies:** `src/commands/update.ts`, `src/core/configurators/slash/base.ts`, `src/core/config.ts`.
|
|
63
|
+
|
|
64
|
+
**Feature Name:** Enhanced Prompt Listing
|
|
65
|
+
- **Description:** Lists existing enhanced prompts under `prompter/<slug>/enhanced-prompt.md`.
|
|
66
|
+
- **User Flow:**
|
|
67
|
+
1. User runs `prompter list` (or `--json`).
|
|
68
|
+
2. CLI scans `prompter/` for directories containing `enhanced-prompt.md`.
|
|
69
|
+
3. Outputs list and optional JSON structure.
|
|
70
|
+
- **Acceptance Criteria:**
|
|
71
|
+
- JSON output when `--json` used.
|
|
72
|
+
- Empty state messaging when no prompts found.
|
|
73
|
+
- Sorted list by slug.
|
|
74
|
+
- **Priority:** Medium
|
|
75
|
+
- **Dependencies:** `src/commands/list.ts`, `src/core/config.ts`.
|
|
76
|
+
|
|
77
|
+
**Feature Name:** Tool-Specific Workflow Generation
|
|
78
|
+
- **Description:** Creates or updates slash-command files for supported AI tools.
|
|
79
|
+
- **User Flow:**
|
|
80
|
+
1. CLI picks tool configurator based on user selection.
|
|
81
|
+
2. Writes file with frontmatter (if applicable) and managed markers.
|
|
82
|
+
- **Acceptance Criteria:**
|
|
83
|
+
- Files created under correct tool paths.
|
|
84
|
+
- Body contains managed markers from `PROMPTER_MARKERS`.
|
|
85
|
+
- **Priority:** High
|
|
86
|
+
- **Dependencies:** `src/core/configurators/slash/*`, `src/core/templates/slash-command-templates.ts`.
|
|
87
|
+
|
|
88
|
+
### 5. Technical Architecture
|
|
89
|
+
- **System Overview:** Local CLI that reads/writes repository files and generates prompt templates. No server-side components.
|
|
90
|
+
- **Technology Stack:**
|
|
91
|
+
- **Language:** TypeScript → compiled to Node.js ES Modules (`src/` → `dist/`).
|
|
92
|
+
- **Runtime:** Node.js >= 20 (`package.json`).
|
|
93
|
+
- **Libraries:** `commander`, `@inquirer/prompts`, `chalk`.
|
|
94
|
+
- **Data Models:**
|
|
95
|
+
- `EnhancedPrompt` (in-memory): `{ id, path, createdAt }` in `src/commands/list.ts`.
|
|
96
|
+
- `ToolChoice` and `SUPPORTED_TOOLS` in `src/core/config.ts`.
|
|
97
|
+
- **APIs & Integrations:** No network APIs. Integrates with tool-specific file conventions.
|
|
98
|
+
- **Infrastructure:** Local filesystem only. CLI entry is `bin/prompter.js` which loads `dist/cli/index.js`.
|
|
99
|
+
|
|
100
|
+
**Architecture Diagram (Mermaid):**
|
|
101
|
+
```mermaid
|
|
102
|
+
flowchart TD
|
|
103
|
+
CLI[prompter CLI] -->|init| FS[(Local Filesystem)]
|
|
104
|
+
CLI -->|update| FS
|
|
105
|
+
CLI -->|list| FS
|
|
106
|
+
FS -->|workflow files| Tools[AI Tools: Claude/Codex/etc.]
|
|
107
|
+
Templates[Templates] --> CLI
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### 6. Non-Functional Requirements
|
|
111
|
+
- **Performance:** Fast file IO; scans only `prompter/` directory.
|
|
112
|
+
- **Security:** No authentication; operates on local filesystem; no data transmission.
|
|
113
|
+
- **Scalability:** Handles many prompt folders; linear scan in `prompter/`.
|
|
114
|
+
- **Reliability:** Uses guarded checks for existing directories; safe updates via marker boundaries.
|
|
115
|
+
- **Compliance:** None specified. ⚠️ ASSUMPTION: Local-only operation minimizes compliance needs.
|
|
116
|
+
|
|
117
|
+
### 7. User Interface Specifications
|
|
118
|
+
- **Navigation Structure:** CLI commands:
|
|
119
|
+
- `prompter init`
|
|
120
|
+
- `prompter update`
|
|
121
|
+
- `prompter list`
|
|
122
|
+
- **Key Screens/Pages:** Terminal output with colored status messages (`chalk`).
|
|
123
|
+
- **Design Patterns:**
|
|
124
|
+
- Interactive selection via checkbox prompt.
|
|
125
|
+
- Managed template sections via markers: `<!-- prompter-managed-start -->` and `<!-- prompter-managed-end -->`.
|
|
126
|
+
- **Responsive Behavior:** N/A (CLI).
|
|
127
|
+
|
|
128
|
+
### 8. Integration Requirements
|
|
129
|
+
- **Third-Party Services:** None.
|
|
130
|
+
- **APIs Consumed:** None.
|
|
131
|
+
- **APIs Provided:** CLI commands only.
|
|
132
|
+
- **Webhooks/Events:** None.
|
|
133
|
+
|
|
134
|
+
### 9. Data Specifications
|
|
135
|
+
- **Data Models:**
|
|
136
|
+
- `prompter/project.md` — project context template.
|
|
137
|
+
- Workflow files per tool, e.g., `.codex/prompts/prompter-enhance.md`.
|
|
138
|
+
- **Data Flow:** User input → CLI templates → filesystem output → AI tool reads workflow file.
|
|
139
|
+
- **Storage Requirements:** Low; markdown text files only.
|
|
140
|
+
- **Data Privacy:** No PII processing; files are local. ⚠️ ASSUMPTION: Enhanced prompts may include sensitive text, handled by repo policies.
|
|
141
|
+
|
|
142
|
+
### 10. Current Limitations & Technical Debt
|
|
143
|
+
- No validation of `--tools` inputs; invalid tool IDs are ignored silently (no error path in `src/commands/init.ts`).
|
|
144
|
+
- `prompter update` updates all known tools, even if not used in the project.
|
|
145
|
+
- No tests present (no `test/` files found).
|
|
146
|
+
- Update requires markers; files without them error (`src/core/configurators/slash/base.ts`).
|
|
147
|
+
|
|
148
|
+
### 11. Assumptions & Inferences
|
|
149
|
+
- ⚠️ ASSUMPTION: Prompter is intended to be used as a **global CLI** (`npm install -g`), inferred from README and `package.json` `bin` mapping.
|
|
150
|
+
- ⚠️ ASSUMPTION: Enhanced prompts are generated by the AI assistant following the workflow, not by this CLI.
|
|
151
|
+
- ⚠️ ASSUMPTION: Users will maintain versioned workflow files in their repos and accept managed updates.
|
package/package.json
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@dedesfr/prompter",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Enhance prompts directly in your AI coding workflow",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"bin": {
|
|
8
|
+
"prompter": "./bin/prompter.js"
|
|
9
|
+
},
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "https://github.com/Dedesfr/Prompter.git"
|
|
13
|
+
},
|
|
14
|
+
"bugs": {
|
|
15
|
+
"url": "https://github.com/Dedesfr/Prompter/issues"
|
|
16
|
+
},
|
|
17
|
+
"homepage": "https://github.com/Dedesfr/Prompter#readme",
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "node build.js",
|
|
20
|
+
"dev": "tsc --watch",
|
|
21
|
+
"dev:cli": "pnpm build && node bin/prompter.js",
|
|
22
|
+
"test": "vitest run",
|
|
23
|
+
"test:watch": "vitest",
|
|
24
|
+
"prepublishOnly": "pnpm run build"
|
|
25
|
+
},
|
|
26
|
+
"keywords": [
|
|
27
|
+
"prompt",
|
|
28
|
+
"ai",
|
|
29
|
+
"cli",
|
|
30
|
+
"workflow",
|
|
31
|
+
"specification",
|
|
32
|
+
"prompt-engineering",
|
|
33
|
+
"ai-assistant"
|
|
34
|
+
],
|
|
35
|
+
"author": "Dedesfr",
|
|
36
|
+
"license": "MIT",
|
|
37
|
+
"engines": {
|
|
38
|
+
"node": ">=20.0.0"
|
|
39
|
+
},
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"chalk": "^5.3.0",
|
|
42
|
+
"commander": "^12.1.0",
|
|
43
|
+
"@inquirer/prompts": "^7.2.3"
|
|
44
|
+
},
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"@types/node": "^22.10.7",
|
|
47
|
+
"typescript": "^5.7.3",
|
|
48
|
+
"vitest": "^2.1.8"
|
|
49
|
+
}
|
|
50
|
+
}
|
package/src/cli/index.ts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { InitCommand } from '../commands/init.js';
|
|
3
|
+
import { UpdateCommand } from '../commands/update.js';
|
|
4
|
+
import { ListCommand } from '../commands/list.js';
|
|
5
|
+
|
|
6
|
+
const program = new Command();
|
|
7
|
+
|
|
8
|
+
program
|
|
9
|
+
.name('prompter')
|
|
10
|
+
.description('Enhance prompts directly in your AI coding workflow')
|
|
11
|
+
.version('0.1.0');
|
|
12
|
+
|
|
13
|
+
program
|
|
14
|
+
.command('init')
|
|
15
|
+
.description('Initialize Prompter in your project')
|
|
16
|
+
.option('--tools <tools...>', 'Specify AI tools to configure (antigravity, claude, codex, github-copilot, opencode, kilocode)')
|
|
17
|
+
.option('--no-interactive', 'Run without interactive prompts')
|
|
18
|
+
.action(async (options) => {
|
|
19
|
+
const initCommand = new InitCommand();
|
|
20
|
+
await initCommand.execute(options);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
program
|
|
24
|
+
.command('update')
|
|
25
|
+
.description('Update Prompter workflow files to latest version')
|
|
26
|
+
.action(async () => {
|
|
27
|
+
const updateCommand = new UpdateCommand();
|
|
28
|
+
await updateCommand.execute();
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
program
|
|
32
|
+
.command('list')
|
|
33
|
+
.description('List all enhanced prompts')
|
|
34
|
+
.option('--json', 'Output as JSON')
|
|
35
|
+
.action(async (options) => {
|
|
36
|
+
const listCommand = new ListCommand();
|
|
37
|
+
await listCommand.execute(options);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
program.parse();
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { promises as fs } from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import chalk from 'chalk';
|
|
4
|
+
import { checkbox } from '@inquirer/prompts';
|
|
5
|
+
import { PROMPTER_DIR, SUPPORTED_TOOLS, PrompterConfig } from '../core/config.js';
|
|
6
|
+
import { projectTemplate, agentsTemplate } from '../core/templates/index.js';
|
|
7
|
+
import { registry } from '../core/configurators/slash/index.js';
|
|
8
|
+
|
|
9
|
+
interface InitOptions {
|
|
10
|
+
tools?: string[];
|
|
11
|
+
noInteractive?: boolean;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export class InitCommand {
|
|
15
|
+
async execute(options: InitOptions = {}): Promise<void> {
|
|
16
|
+
const projectPath = process.cwd();
|
|
17
|
+
|
|
18
|
+
console.log(chalk.blue('\n🚀 Initializing Prompter...\n'));
|
|
19
|
+
|
|
20
|
+
// Check if already initialized
|
|
21
|
+
if (await PrompterConfig.prompterDirExists(projectPath)) {
|
|
22
|
+
console.log(chalk.yellow('⚠️ Prompter is already initialized in this project.'));
|
|
23
|
+
console.log(chalk.gray(' Use `prompter update` to refresh workflow files.\n'));
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// Select tools
|
|
28
|
+
let selectedTools: string[] = [];
|
|
29
|
+
|
|
30
|
+
if (options.tools && options.tools.length > 0) {
|
|
31
|
+
selectedTools = options.tools;
|
|
32
|
+
} else if (!options.noInteractive) {
|
|
33
|
+
try {
|
|
34
|
+
selectedTools = await checkbox({
|
|
35
|
+
message: 'Select AI tools to configure:',
|
|
36
|
+
choices: SUPPORTED_TOOLS.map(tool => ({
|
|
37
|
+
name: tool.name,
|
|
38
|
+
value: tool.value,
|
|
39
|
+
checked: tool.value === 'antigravity' // Default check Antigravity
|
|
40
|
+
}))
|
|
41
|
+
});
|
|
42
|
+
} catch (error) {
|
|
43
|
+
// User cancelled
|
|
44
|
+
console.log(chalk.yellow('\nInitialization cancelled.'));
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// Create prompter directory
|
|
50
|
+
const prompterPath = await PrompterConfig.ensurePrompterDir(projectPath);
|
|
51
|
+
console.log(chalk.green('✓') + ` Created ${chalk.cyan(PROMPTER_DIR + '/')}`);
|
|
52
|
+
|
|
53
|
+
// Create project.md
|
|
54
|
+
const projectMdPath = path.join(prompterPath, 'project.md');
|
|
55
|
+
await fs.writeFile(projectMdPath, projectTemplate, 'utf-8');
|
|
56
|
+
console.log(chalk.green('✓') + ` Created ${chalk.cyan(PROMPTER_DIR + '/project.md')}`);
|
|
57
|
+
|
|
58
|
+
// Create AGENTS.md for universal support
|
|
59
|
+
const agentsMdPath = path.join(projectPath, 'AGENTS.md');
|
|
60
|
+
const agentsExists = await this.fileExists(agentsMdPath);
|
|
61
|
+
if (!agentsExists) {
|
|
62
|
+
await fs.writeFile(agentsMdPath, agentsTemplate, 'utf-8');
|
|
63
|
+
console.log(chalk.green('✓') + ` Created ${chalk.cyan('AGENTS.md')}`);
|
|
64
|
+
} else {
|
|
65
|
+
console.log(chalk.gray(' AGENTS.md already exists, skipping'));
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Generate workflow files for selected tools
|
|
69
|
+
if (selectedTools.length > 0) {
|
|
70
|
+
console.log(chalk.blue('\n📝 Creating workflow files...\n'));
|
|
71
|
+
|
|
72
|
+
for (const toolId of selectedTools) {
|
|
73
|
+
const configurator = registry.get(toolId);
|
|
74
|
+
if (configurator) {
|
|
75
|
+
try {
|
|
76
|
+
const files = await configurator.generateAll(projectPath);
|
|
77
|
+
for (const file of files) {
|
|
78
|
+
console.log(chalk.green('✓') + ` Created ${chalk.cyan(file)}`);
|
|
79
|
+
}
|
|
80
|
+
} catch (error) {
|
|
81
|
+
console.log(chalk.red('✗') + ` Failed to create files for ${toolId}: ${error}`);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// Success message
|
|
88
|
+
console.log(chalk.green('\n✅ Prompter initialized successfully!\n'));
|
|
89
|
+
console.log(chalk.blue('Next steps:'));
|
|
90
|
+
console.log(chalk.gray(' 1. Edit prompter/project.md to describe your project'));
|
|
91
|
+
console.log(chalk.gray(' 2. Use /prompter-enhance to transform prompts'));
|
|
92
|
+
console.log(chalk.gray(' 3. Run `prompter list` to see enhanced prompts\n'));
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
private async fileExists(filePath: string): Promise<boolean> {
|
|
96
|
+
try {
|
|
97
|
+
await fs.access(filePath);
|
|
98
|
+
return true;
|
|
99
|
+
} catch {
|
|
100
|
+
return false;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { promises as fs } from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import chalk from 'chalk';
|
|
4
|
+
import { PROMPTER_DIR, PrompterConfig } from '../core/config.js';
|
|
5
|
+
|
|
6
|
+
interface ListOptions {
|
|
7
|
+
json?: boolean;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
interface EnhancedPrompt {
|
|
11
|
+
id: string;
|
|
12
|
+
path: string;
|
|
13
|
+
createdAt?: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export class ListCommand {
|
|
17
|
+
async execute(options: ListOptions = {}): Promise<void> {
|
|
18
|
+
const projectPath = process.cwd();
|
|
19
|
+
|
|
20
|
+
// Check if initialized
|
|
21
|
+
if (!await PrompterConfig.prompterDirExists(projectPath)) {
|
|
22
|
+
if (options.json) {
|
|
23
|
+
console.log(JSON.stringify({ error: 'Prompter not initialized', prompts: [] }));
|
|
24
|
+
} else {
|
|
25
|
+
console.log(chalk.red('❌ Prompter is not initialized in this project.'));
|
|
26
|
+
console.log(chalk.gray(' Run `prompter init` first.\n'));
|
|
27
|
+
}
|
|
28
|
+
process.exitCode = 1;
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const prompterPath = path.join(projectPath, PROMPTER_DIR);
|
|
33
|
+
const prompts = await this.scanPrompts(prompterPath);
|
|
34
|
+
|
|
35
|
+
if (options.json) {
|
|
36
|
+
console.log(JSON.stringify(prompts, null, 2));
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (prompts.length === 0) {
|
|
41
|
+
console.log(chalk.yellow('\n📭 No enhanced prompts found.\n'));
|
|
42
|
+
console.log(chalk.gray('Use /prompter-enhance to create one.\n'));
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
console.log(chalk.blue(`\n📋 Enhanced Prompts (${prompts.length}):\n`));
|
|
47
|
+
|
|
48
|
+
for (const prompt of prompts) {
|
|
49
|
+
console.log(chalk.green(' •') + ` ${chalk.cyan(prompt.id)}`);
|
|
50
|
+
console.log(chalk.gray(` ${prompt.path}`));
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
console.log();
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
private async scanPrompts(prompterPath: string): Promise<EnhancedPrompt[]> {
|
|
57
|
+
const prompts: EnhancedPrompt[] = [];
|
|
58
|
+
|
|
59
|
+
try {
|
|
60
|
+
const entries = await fs.readdir(prompterPath, { withFileTypes: true });
|
|
61
|
+
|
|
62
|
+
for (const entry of entries) {
|
|
63
|
+
if (!entry.isDirectory() || entry.name.startsWith('.')) continue;
|
|
64
|
+
|
|
65
|
+
const enhancedPromptPath = path.join(prompterPath, entry.name, 'enhanced-prompt.md');
|
|
66
|
+
|
|
67
|
+
try {
|
|
68
|
+
const stats = await fs.stat(enhancedPromptPath);
|
|
69
|
+
prompts.push({
|
|
70
|
+
id: entry.name,
|
|
71
|
+
path: path.join(PROMPTER_DIR, entry.name, 'enhanced-prompt.md'),
|
|
72
|
+
createdAt: stats.birthtime.toISOString()
|
|
73
|
+
});
|
|
74
|
+
} catch {
|
|
75
|
+
// No enhanced-prompt.md in this directory, skip
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
} catch (error) {
|
|
79
|
+
// Directory doesn't exist or can't be read
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return prompts.sort((a, b) => a.id.localeCompare(b.id));
|
|
83
|
+
}
|
|
84
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
import { PrompterConfig } from '../core/config.js';
|
|
3
|
+
import { registry } from '../core/configurators/slash/index.js';
|
|
4
|
+
|
|
5
|
+
export class UpdateCommand {
|
|
6
|
+
async execute(): Promise<void> {
|
|
7
|
+
const projectPath = process.cwd();
|
|
8
|
+
|
|
9
|
+
console.log(chalk.blue('\n🔄 Updating Prompter workflow files...\n'));
|
|
10
|
+
|
|
11
|
+
// Check if initialized
|
|
12
|
+
if (!await PrompterConfig.prompterDirExists(projectPath)) {
|
|
13
|
+
console.log(chalk.red('❌ Prompter is not initialized in this project.'));
|
|
14
|
+
console.log(chalk.gray(' Run `prompter init` first.\n'));
|
|
15
|
+
process.exitCode = 1;
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
let updatedCount = 0;
|
|
20
|
+
|
|
21
|
+
// Update workflow files for all tools
|
|
22
|
+
for (const configurator of registry.getAvailable()) {
|
|
23
|
+
try {
|
|
24
|
+
const files = await configurator.updateExisting(projectPath);
|
|
25
|
+
for (const file of files) {
|
|
26
|
+
console.log(chalk.green('✓') + ` Updated ${chalk.cyan(file)}`);
|
|
27
|
+
updatedCount++;
|
|
28
|
+
}
|
|
29
|
+
} catch (error) {
|
|
30
|
+
console.log(chalk.red('✗') + ` Failed to update ${configurator.toolId}: ${error}`);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (updatedCount === 0) {
|
|
35
|
+
console.log(chalk.yellow('⚠️ No workflow files found to update.'));
|
|
36
|
+
console.log(chalk.gray(' Run `prompter init` to create them.\n'));
|
|
37
|
+
} else {
|
|
38
|
+
console.log(chalk.green(`\n✅ Updated ${updatedCount} file(s).\n`));
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { promises as fs } from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
|
|
4
|
+
export const PROMPTER_DIR = 'prompter';
|
|
5
|
+
|
|
6
|
+
export const PROMPTER_MARKERS = {
|
|
7
|
+
start: '<!-- prompter-managed-start -->',
|
|
8
|
+
end: '<!-- prompter-managed-end -->'
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export interface ToolChoice {
|
|
12
|
+
name: string;
|
|
13
|
+
value: string;
|
|
14
|
+
available: boolean;
|
|
15
|
+
successLabel: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const SUPPORTED_TOOLS: ToolChoice[] = [
|
|
19
|
+
{ name: 'Antigravity', value: 'antigravity', available: true, successLabel: 'Antigravity' },
|
|
20
|
+
{ name: 'Claude Code', value: 'claude', available: true, successLabel: 'Claude Code' },
|
|
21
|
+
{ name: 'Codex', value: 'codex', available: true, successLabel: 'Codex' },
|
|
22
|
+
{ name: 'GitHub Copilot', value: 'github-copilot', available: true, successLabel: 'GitHub Copilot' },
|
|
23
|
+
{ name: 'OpenCode', value: 'opencode', available: true, successLabel: 'OpenCode' },
|
|
24
|
+
{ name: 'Kilo Code', value: 'kilocode', available: true, successLabel: 'Kilo Code' }
|
|
25
|
+
];
|
|
26
|
+
|
|
27
|
+
export class PrompterConfig {
|
|
28
|
+
static async ensurePrompterDir(projectPath: string): Promise<string> {
|
|
29
|
+
const prompterPath = path.join(projectPath, PROMPTER_DIR);
|
|
30
|
+
await fs.mkdir(prompterPath, { recursive: true });
|
|
31
|
+
return prompterPath;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
static async prompterDirExists(projectPath: string): Promise<boolean> {
|
|
35
|
+
try {
|
|
36
|
+
const prompterPath = path.join(projectPath, PROMPTER_DIR);
|
|
37
|
+
await fs.access(prompterPath);
|
|
38
|
+
return true;
|
|
39
|
+
} catch {
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { SlashCommandConfigurator } from './base.js';
|
|
2
|
+
import { SlashCommandId } from '../../templates/index.js';
|
|
3
|
+
|
|
4
|
+
const FILE_PATHS: Record<SlashCommandId, string> = {
|
|
5
|
+
enhance: '.agent/workflows/prompter-enhance.md'
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
const DESCRIPTIONS: Record<SlashCommandId, string> = {
|
|
9
|
+
enhance: 'Enhance a rough prompt into a professional specification'
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export class AntigravityConfigurator extends SlashCommandConfigurator {
|
|
13
|
+
readonly toolId = 'antigravity';
|
|
14
|
+
readonly isAvailable = true;
|
|
15
|
+
|
|
16
|
+
protected getRelativePath(id: SlashCommandId): string {
|
|
17
|
+
return FILE_PATHS[id];
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
protected getFrontmatter(id: SlashCommandId): string | undefined {
|
|
21
|
+
const description = DESCRIPTIONS[id];
|
|
22
|
+
return `---\ndescription: ${description}\n---`;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { promises as fs } from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { SlashCommandId, TemplateManager } from '../../templates/index.js';
|
|
4
|
+
import { PROMPTER_MARKERS } from '../../config.js';
|
|
5
|
+
|
|
6
|
+
export interface SlashCommandTarget {
|
|
7
|
+
id: SlashCommandId;
|
|
8
|
+
path: string;
|
|
9
|
+
kind: 'slash';
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const ALL_COMMANDS: SlashCommandId[] = ['enhance'];
|
|
13
|
+
|
|
14
|
+
export abstract class SlashCommandConfigurator {
|
|
15
|
+
abstract readonly toolId: string;
|
|
16
|
+
abstract readonly isAvailable: boolean;
|
|
17
|
+
|
|
18
|
+
getTargets(): SlashCommandTarget[] {
|
|
19
|
+
return ALL_COMMANDS.map((id) => ({
|
|
20
|
+
id,
|
|
21
|
+
path: this.getRelativePath(id),
|
|
22
|
+
kind: 'slash'
|
|
23
|
+
}));
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
async generateAll(projectPath: string): Promise<string[]> {
|
|
27
|
+
const createdOrUpdated: string[] = [];
|
|
28
|
+
|
|
29
|
+
for (const target of this.getTargets()) {
|
|
30
|
+
const body = this.getBody(target.id);
|
|
31
|
+
const filePath = path.join(projectPath, target.path);
|
|
32
|
+
|
|
33
|
+
// Ensure directory exists
|
|
34
|
+
await fs.mkdir(path.dirname(filePath), { recursive: true });
|
|
35
|
+
|
|
36
|
+
if (await this.fileExists(filePath)) {
|
|
37
|
+
await this.updateBody(filePath, body);
|
|
38
|
+
} else {
|
|
39
|
+
const frontmatter = this.getFrontmatter(target.id);
|
|
40
|
+
const sections: string[] = [];
|
|
41
|
+
if (frontmatter) {
|
|
42
|
+
sections.push(frontmatter.trim());
|
|
43
|
+
}
|
|
44
|
+
sections.push(`${PROMPTER_MARKERS.start}\n${body}\n${PROMPTER_MARKERS.end}`);
|
|
45
|
+
const content = sections.join('\n') + '\n';
|
|
46
|
+
await fs.writeFile(filePath, content, 'utf-8');
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
createdOrUpdated.push(target.path);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return createdOrUpdated;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
async updateExisting(projectPath: string): Promise<string[]> {
|
|
56
|
+
const updated: string[] = [];
|
|
57
|
+
|
|
58
|
+
for (const target of this.getTargets()) {
|
|
59
|
+
const filePath = path.join(projectPath, target.path);
|
|
60
|
+
if (await this.fileExists(filePath)) {
|
|
61
|
+
const body = this.getBody(target.id);
|
|
62
|
+
await this.updateBody(filePath, body);
|
|
63
|
+
updated.push(target.path);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return updated;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
protected abstract getRelativePath(id: SlashCommandId): string;
|
|
71
|
+
protected abstract getFrontmatter(id: SlashCommandId): string | undefined;
|
|
72
|
+
|
|
73
|
+
protected getBody(id: SlashCommandId): string {
|
|
74
|
+
return TemplateManager.getSlashCommandBody(id).trim();
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
protected async updateBody(filePath: string, body: string): Promise<void> {
|
|
78
|
+
const content = await fs.readFile(filePath, 'utf-8');
|
|
79
|
+
const startIndex = content.indexOf(PROMPTER_MARKERS.start);
|
|
80
|
+
const endIndex = content.indexOf(PROMPTER_MARKERS.end);
|
|
81
|
+
|
|
82
|
+
if (startIndex === -1 || endIndex === -1 || endIndex <= startIndex) {
|
|
83
|
+
throw new Error(`Missing Prompter markers in ${filePath}`);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const before = content.slice(0, startIndex + PROMPTER_MARKERS.start.length);
|
|
87
|
+
const after = content.slice(endIndex);
|
|
88
|
+
const updatedContent = `${before}\n${body}\n${after}`;
|
|
89
|
+
|
|
90
|
+
await fs.writeFile(filePath, updatedContent, 'utf-8');
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
private async fileExists(filePath: string): Promise<boolean> {
|
|
94
|
+
try {
|
|
95
|
+
await fs.access(filePath);
|
|
96
|
+
return true;
|
|
97
|
+
} catch {
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { SlashCommandConfigurator } from './base.js';
|
|
2
|
+
import { SlashCommandId } from '../../templates/index.js';
|
|
3
|
+
|
|
4
|
+
const FILE_PATHS: Record<SlashCommandId, string> = {
|
|
5
|
+
enhance: '.claude/commands/prompter/enhance.md'
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
const DESCRIPTIONS: Record<SlashCommandId, string> = {
|
|
9
|
+
enhance: 'Enhance a rough prompt into a professional specification'
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export class ClaudeConfigurator extends SlashCommandConfigurator {
|
|
13
|
+
readonly toolId = 'claude';
|
|
14
|
+
readonly isAvailable = true;
|
|
15
|
+
|
|
16
|
+
protected getRelativePath(id: SlashCommandId): string {
|
|
17
|
+
return FILE_PATHS[id];
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
protected getFrontmatter(id: SlashCommandId): string | undefined {
|
|
21
|
+
// Claude Code uses the filename as the command name
|
|
22
|
+
return undefined;
|
|
23
|
+
}
|
|
24
|
+
}
|