Skip to content

Commit 40c43bb

Browse files
authored
feat: add scaffolding for github releases (#79)
1 parent 96be779 commit 40c43bb

File tree

92 files changed

+9942
-1142
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+9942
-1142
lines changed

.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ ovsx-*.log
3030
# Build outputs
3131
out/
3232
dist/
33-
lib/
3433
build/
3534
*.tsbuildinfo
3635
*.js.map
@@ -57,7 +56,6 @@ dist/
5756
downloads/
5857
eggs/
5958
.eggs/
60-
lib/
6159
lib64/
6260
parts/
6361
sdist/

AGENTS.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,20 @@
22

33
These are short, actionable notes to help an AI coding assistant be productive in this repository.
44

5+
**🚨 FIRST STEP: Read Folder-Specific Guidance 🚨**
6+
7+
Before working in any folder, **MUST READ** the corresponding AGENTS.md file:
8+
- Working with tests? → Read `test/AGENTS.md` first
9+
- Writing E2E tests? → Read `test/e2e/AGENTS.md` first
10+
- Creating adapters? → Read `src/adapters/AGENTS.md` first
11+
- Building services? → Read `src/services/AGENTS.md` first
12+
13+
**Failure to read these guides will result in:**
14+
- Broken tests due to incorrect VS Code mocking
15+
- Duplicated utilities that already exist
16+
- Missing critical debugging strategies
17+
- Wasted time on solved problems
18+
519
---
620

721
## Development Methodology

CONTRIBUTING.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,10 @@ prompt-registry/
117117
│ ├── types/ # TypeScript type definitions
118118
│ ├── utils/ # Utility functions
119119
│ └── extension.ts # Extension entry point
120+
├── templates/
121+
│ └── scaffolds/ # Project scaffolding templates
122+
│ ├── github/ # GitHub scaffold with CI/CD publishing
123+
│ └── apm/ # APM package template
120124
├── test/
121125
│ ├── adapters/ # Adapter unit tests
122126
│ ├── services/ # Service unit tests
@@ -132,9 +136,30 @@ prompt-registry/
132136

133137
- **`src/extension.ts`**: Extension activation and setup
134138
- **`src/types/registry.ts`**: Core type definitions
139+
- **`src/commands/ScaffoldCommand.ts`**: Project scaffolding command
135140
- **[Architecture](docs/contributor-guide/architecture.md)**: Detailed architecture documentation
136141
- **[Core Flows](docs/contributor-guide/core-flows.md)**: Key system flows and processes
137142

143+
### Scaffolding System
144+
145+
The extension includes a scaffolding system for creating new prompt projects:
146+
147+
| Scaffold Type | Description | Template Location |
148+
|--------------|-------------|-------------------|
149+
| **GitHub** | Full-featured template with GitHub Releases CI for automated collection publishing | `templates/scaffolds/github/` |
150+
| **APM** | APM package template | `templates/scaffolds/apm/` |
151+
152+
**GitHub Scaffold Features:**
153+
- GitHub Actions workflows for automated publishing
154+
- Collection validation scripts
155+
- Example prompts, instructions, and agents
156+
- Pre-commit hooks for validation
157+
158+
When contributing to scaffolding:
159+
- Templates use `{{variable}}` syntax for substitution
160+
- Test changes with `npm run test:unit` (scaffold tests in `test/commands/`)
161+
- Ensure all generated files are valid and functional
162+
138163
---
139164

140165
## How to Contribute

docs/author-guide/validation.md

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,10 @@ Validate your collection files before publishing to catch errors early.
88
Ctrl+Shift+P → "Prompt Registry: Validate Collections"
99
```
1010

11-
Validates all `.collection.yml` files in your `collections/` directory.
12-
13-
## Validation with File References
14-
15-
```bash
16-
Ctrl+Shift+P → "Prompt Registry: Validate Collections (Check File References)"
17-
```
18-
19-
Also verifies that all referenced files (prompts, instructions, etc.) exist.
11+
Validates all `.collection.yml` files in your `collections/` directory, including:
12+
- Schema validation (required fields, formats)
13+
- File reference checking (all referenced files exist)
14+
- Duplicate detection (no duplicate IDs or names across collections)
2015

2116
## What Gets Validated
2217

@@ -25,8 +20,10 @@ Also verifies that all referenced files (prompts, instructions, etc.) exist.
2520
| Required fields | `id`, `name`, `description`, `items` |
2621
| ID format | Lowercase letters, numbers, hyphens only |
2722
| Item paths | Valid relative paths |
28-
| Item kinds | One of: `prompt`, `instruction`, `chat-mode`, `agent` |
29-
| File references | Referenced files exist (with Check File References) |
23+
| Item kinds | One of: `prompt`, `instruction`, `agent`, `skill` |
24+
| File references | Referenced files exist |
25+
| Duplicate IDs | No two collections share the same ID |
26+
| Duplicate names | No two collections share the same name |
3027

3128
## Common Errors
3229

@@ -37,11 +34,17 @@ Also verifies that all referenced files (prompts, instructions, etc.) exist.
3734
→ Use only lowercase letters, numbers, and hyphens (e.g., `my-collection`)
3835

3936
**Invalid item kind**
40-
→ Use one of: `prompt`, `instruction`, `chat-mode`, `agent`
37+
→ Use one of: `prompt`, `instruction`, `agent`, `skill`
4138

4239
**File not found**
4340
→ Check that the path in `items[].path` points to an existing file
4441

42+
**Duplicate collection ID**
43+
→ Each collection must have a unique ID across the repository
44+
45+
**Duplicate collection name**
46+
→ Each collection must have a unique name across the repository
47+
4548
## See Also
4649

4750
- [Collection Schema](./collection-schema.md) — Full YAML reference

docs/contributor-guide/architecture/scaffolding.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export enum ScaffoldType {
2323
**Awesome Copilot Template:**
2424
```mermaid
2525
graph TD
26-
A["templates/scaffolds/awesome-copilot/"]
26+
A["templates/scaffolds/github/"]
2727
B["manifest.json<br/># Template metadata"]
2828
C["package.template.json<br/># Project package (with variables)"]
2929
D["README.template.md"]

docs/contributor-guide/architecture/validation.md

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,14 @@ flowchart TD
4848
C --> D[SchemaValidator.validateCollection]
4949
D --> E[1. Schema validation AJV]
5050
D --> F[2. Format errors to user-friendly messages]
51-
D --> G[3. Check file references optional]
51+
D --> G[3. Check file references]
5252
D --> H[4. Generate best practice warnings]
53-
E --> I[Display in Output Channel + VS Code Diagnostics]
54-
F --> I
55-
G --> I
56-
H --> I
53+
D --> I[5. Detect duplicate IDs/names]
54+
E --> J[Display in Output Channel + VS Code Diagnostics]
55+
F --> J
56+
G --> J
57+
H --> J
58+
I --> J
5759
```
5860

5961
## Error Formatting
@@ -62,16 +64,18 @@ flowchart TD
6264
|------------|---------|
6365
| Required field | `Missing required field: description` |
6466
| Pattern mismatch | `/id: must match pattern ^[a-z0-9-]+$` |
65-
| Enum violation | `kind: must be one of: prompt, instruction, chat-mode, agent` |
67+
| Enum violation | `kind: must be one of: prompt, instruction, agent, skill` |
6668
| Type mismatch | `/version: must be string` |
6769
| Length violation | `description: must be at most 500 characters` |
6870
| Additional property | `/: has unexpected property 'foo'` |
71+
| Duplicate ID | `Duplicate collection ID 'my-id' (also in other.collection.yml)` |
72+
| Duplicate name | `Duplicate collection name 'My Name' (also in other.collection.yml)` |
6973

7074
## Performance
7175

7276
- **Schema Caching**: Compiled schemas cached in Map
7377
- **Lazy Loading**: Schemas loaded on first use
74-
- **Efficient File Checking**: Only when `checkFileReferences` enabled
78+
- **File Reference Checking**: Always enabled for complete validation
7579

7680
## Validation Schemas
7781

@@ -95,7 +99,7 @@ The extension provides JSON Schema validation for all major configuration file t
9599
- `mcp` — Model Context Protocol server configurations
96100
- `display` — UI display preferences (color, icon, ordering)
97101

98-
**Item types supported:** `prompt`, `instruction`, `chat-mode`, `agent`
102+
**Item types supported:** `prompt`, `instruction`, `agent`, `skill`
99103

100104
**Validation features:**
101105
- File reference checking (when `checkFileReferences` enabled)

docs/migration-guide.md

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# Migration Guide
2+
3+
This guide helps you migrate from deprecated project structures to the current GitHub scaffold format.
4+
5+
## Adding GitHub Releases CI to Existing Collections
6+
7+
If you have a repository with a `collections/` folder but no GitHub Actions workflow for publishing releases, follow these steps:
8+
9+
### Quick Setup
10+
11+
1. Run the scaffold command in your existing project directory:
12+
```bash
13+
# From VS Code Command Palette: "Prompt Registry: Scaffold Project" → "GitHub"
14+
```
15+
16+
2. Delete the generated example files:
17+
```bash
18+
rm -rf prompts/example.prompt.md instructions/example.instructions.md agents/example.agent.md collections/example.collection.yml skills/example-skill
19+
```
20+
21+
3. Push to main branch to trigger the first release.
22+
23+
### What Gets Added
24+
25+
- `.github/workflows/publish.yml` - Automated release workflow
26+
- `.github/actions/` - Reusable GitHub Actions
27+
- `scripts/` - Build and validation scripts
28+
- `package.json` - npm dependencies for validation
29+
30+
## Migrating Chatmode Files to Agent Files {#chatmode-to-agent}
31+
32+
The `chatmode` kind has been replaced by `agent`. If your collection files reference `.chatmode.md` files or use `kind: chatmode`, follow these steps:
33+
34+
### Step 1: Rename Files
35+
36+
Rename all `.chatmode.md` files to `.agent.md`:
37+
38+
```bash
39+
# Find and rename all chatmode files
40+
find . -name "*.chatmode.md" -exec sh -c 'mv "$1" "${1%.chatmode.md}.agent.md"' _ {} \;
41+
```
42+
43+
### Step 2: Update Collection YAML Files
44+
45+
In your collection YAML files, change:
46+
47+
```yaml
48+
# Before
49+
items:
50+
- kind: chatmode
51+
path: chatmodes/my-mode.chatmode.md
52+
53+
# After
54+
items:
55+
- kind: agent
56+
path: agents/my-mode.agent.md
57+
```
58+
59+
### Step 3: Move Files to Agents Directory
60+
61+
If you have a `chatmodes/` directory, rename it to `agents/`:
62+
63+
```bash
64+
mv chatmodes agents
65+
```
66+
67+
### Step 4: Update File References
68+
69+
Search your codebase for any remaining references to chatmode files and update them.
70+
71+
## Need Help?
72+
73+
- [GitHub Scaffold Documentation](https://github.com/prompt-registry/docs)
74+
- [Collection Schema Reference](../docs/author-guide/collection-schema.md)

docs/reference/commands.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,7 @@ This document lists all VS Code commands provided by the Prompt Registry extensi
8585
| Command | Title | Description |
8686
|---------|-------|-------------|
8787
| `promptRegistry.createCollection` | Create New Collection | Create a new prompt collection |
88-
| `promptRegistry.validateCollections` | Validate Collections | Validate collection YAML files |
89-
| `promptRegistry.validateCollectionsWithRefs` | Validate Collections (Check File References) | Validate collections including file references |
88+
| `promptRegistry.validateCollections` | Validate Collections | Validate collection YAML files including file references and duplicate detection |
9089
| `promptRegistry.validateApm` | Validate APM Package | Validate an APM package |
9190
| `promptRegistry.listCollections` | List All Collections | Display all collections |
9291

package.json

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,6 @@
105105
"title": "Validate APM Package",
106106
"category": "Prompt Registry"
107107
},
108-
{
109-
"command": "promptRegistry.validateCollectionsWithRefs",
110-
"title": "Validate Collections (Check File References)",
111-
"category": "Prompt Registry"
112-
},
113108
{
114109
"command": "promptRegistry.listCollections",
115110
"title": "List All Collections",
@@ -712,7 +707,7 @@
712707
"lint": "eslint src --ext ts",
713708
"test": "npm run test:all",
714709
"test:one": "node scripts/run-single-test.js",
715-
"test:unit": "npx mocha --ui tdd --require ./test/mocha.setup.js --require ./test/unit.setup.js 'test-dist/test/{adapters,commands,services,utils}/**/*.test.js' --timeout 5000",
710+
"test:unit": "npx mocha --ui tdd --require ./test/mocha.setup.js --require ./test/unit.setup.js 'test-dist/test/{adapters,commands,services,utils,scripts}/**/*.test.js' --timeout 5000",
716711
"test:integration": "npm run compile-tests && node ./test/runExtensionTests.js",
717712
"test:all": "npm run compile-tests && npm run test:unit && npm run test:integration",
718713
"test:coverage": "npm run compile-tests && c8 npm run test:all",

src/adapters/GitHubAdapter.ts

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { promisify } from 'util';
1010
import { RepositoryAdapter } from './RepositoryAdapter';
1111
import { Bundle, SourceMetadata, ValidationResult, RegistrySource } from '../types/registry';
1212
import { Logger } from '../utils/logger';
13+
import { generateGitHubBundleId, formatByteSize } from '../utils/bundleNameUtils';
1314

1415
const execAsync = promisify(exec);
1516

@@ -522,8 +523,16 @@ export class GitHubAdapter extends RepositoryAdapter {
522523
// Create bundle metadata
523524
// Use manifest data if available, otherwise fall back to release data
524525
// Use API URL instead of browser_download_url for proper authentication
526+
// Bundle ID uses canonical generation function for consistency
527+
const bundleId = generateGitHubBundleId(
528+
owner,
529+
repo,
530+
release.tag_name,
531+
manifest?.id,
532+
manifest?.version
533+
);
525534
const bundle: Bundle = {
526-
id: `${owner}-${repo}-${release.tag_name}`,
535+
id: bundleId,
527536
name: manifest?.name || release.name || `${repo} ${release.tag_name}`,
528537
version: manifest?.version || release.tag_name.replace(/^v/, ''),
529538
description: manifest?.description || this.extractDescription(release.body),
@@ -532,14 +541,19 @@ export class GitHubAdapter extends RepositoryAdapter {
532541
environments: manifest?.environments || this.extractEnvironments(release.body),
533542
tags: manifest?.tags || this.extractTags(release.body),
534543
lastUpdated: release.published_at,
535-
size: this.formatSize(bundleAsset.size),
544+
size: formatByteSize(bundleAsset.size),
536545
dependencies: manifest?.dependencies || [],
537546
license: manifest?.license || 'Unknown',
538547
manifestUrl: manifestAsset.url,
539548
downloadUrl: bundleAsset.url,
540549
repository: this.source.url,
541550
};
542551

552+
// Attach prompts array from manifest for content breakdown display
553+
if (manifest?.prompts && Array.isArray(manifest.prompts)) {
554+
(bundle as any).prompts = manifest.prompts;
555+
}
556+
543557
bundles.push(bundle);
544558
}
545559

@@ -732,17 +746,4 @@ export class GitHubAdapter extends RepositoryAdapter {
732746

733747
return tags;
734748
}
735-
736-
/**
737-
* Format byte size to human readable
738-
*/
739-
private formatSize(bytes: number): string {
740-
if (bytes < 1024) {
741-
return `${bytes} B`;
742-
}
743-
if (bytes < 1024 * 1024) {
744-
return `${(bytes / 1024).toFixed(1)} KB`;
745-
}
746-
return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
747-
}
748749
}

0 commit comments

Comments
 (0)