Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
8aba0a4
feat(sdk): fold bitbadges-builder-mcp into the SDK
trevormil Apr 13, 2026
fb764b4
test(core): add validate.ts jest suite
trevormil Apr 13, 2026
97232b9
refactor(mcp): extract session file-store into the library
trevormil Apr 13, 2026
2f7db30
fix(mcp): address CodeQL findings in fetchDocs HTML sanitizer
trevormil Apr 13, 2026
41d63bd
feat: unified reviewCollection() — audit + standards + frontend ux ch…
trevormil Apr 13, 2026
f6f7098
feat: preserve frontend locale parity + port remaining orphan checks
trevormil Apr 13, 2026
26d261f
feat: spec-correct validators + builder defaults, replace auto-fix ba…
trevormil Apr 13, 2026
109817c
refactor: drop amountTrackerId auto-fill, let validator throw
trevormil Apr 13, 2026
179b679
refactor: rename mcp → builder across SDK surface
trevormil Apr 13, 2026
b4b2b39
refactor(cli): unify templates + tools + review under builder umbrella
trevormil Apr 13, 2026
04de963
feat(cli): terminal-friendly review output — colors, rules, boundary
trevormil Apr 13, 2026
0f976b8
feat(cli): flip review order + fold static validation into auto-review
trevormil Apr 13, 2026
cf8c379
fix(builders): satisfy validateTransaction across all 12 templates
trevormil Apr 13, 2026
14bc772
fix(metadata): remove metadata.image hot-fixes at the root + add uplo…
trevormil Apr 13, 2026
b947d78
fix(builder): route alias/wrapper image-name-desc into sidecar (Gap A) +
trevormil Apr 13, 2026
9a176fa
feat(builders): templates pre-fill metadataPlaceholders sidecar (A1+A2)
trevormil Apr 13, 2026
2c42065
feat(cli): builder verify + simulate + doctor + shared renderers (C1+…
trevormil Apr 13, 2026
364e14f
feat(cli,sdk): create/update normalization + all-msg validate + simul…
trevormil Apr 13, 2026
165d31d
Merge branch 'feat/v29-checkpoint' into feat/fold-mcp-into-sdk
trevormil Apr 13, 2026
84b35eb
checkpoint(cli,sdk): template sweep + simulate render + auto-fix bugs
trevormil Apr 13, 2026
09c8064
checkpoint(cli,sdk): round 3 — CLI crash defenses + --events flag + s…
trevormil Apr 13, 2026
da7e905
checkpoint(cli,sdk): round 4 — pre-QA hardening + doctor --with-preview
trevormil Apr 13, 2026
a9ae21a
checkpoint(cli,sdk): code-quality fixes — typed errors + central tool…
trevormil Apr 13, 2026
64ff6b2
checkpoint(cli,sdk): QA pass fixes — net changes, labels, review adapter
trevormil Apr 13, 2026
5916c99
checkpoint(sdk): template parity pass — rewrite 12 builders to match …
trevormil Apr 13, 2026
d65bde7
checkpoint(sdk): review-item consolidation — audience filter + audit …
trevormil Apr 13, 2026
6d76e3d
checkpoint(cli): untruncate terminal output, rename coin→ICS20 / badg…
trevormil Apr 13, 2026
461f279
Merge remote-tracking branch 'origin/main' into feat/fold-mcp-into-sdk
trevormil Apr 13, 2026
2263255
Merge remote-tracking branch 'origin/main' into feat/fold-mcp-into-sdk
trevormil Apr 13, 2026
26cbe13
remove(builder): drop deprecated audit_collection tool + all backlinks
trevormil Apr 13, 2026
6d5c2cd
refactor(simulate): migrate simulateMessages to single-tx agent JSON …
trevormil Apr 13, 2026
7c18e1b
fix(builders): parity re-review findings + stale test assertions
trevormil Apr 14, 2026
3e3fa6d
fix(builders): prediction-market push burn ratio, rename emptyPermiss…
trevormil Apr 14, 2026
6dfc5b0
chore(builder-tools): remove deprecated verify_standards MCP tool
trevormil Apr 14, 2026
5c4e961
fix(review-ux): string parity + standards-based skill gating
trevormil Apr 14, 2026
afd43fc
chore(review): drop dead ReviewContext fields (selectedSkills, applie…
trevormil Apr 14, 2026
e0c99db
fix(review-ux): detect updates structurally, not via ctx.onChainColle…
trevormil Apr 14, 2026
af9b502
fix(review): consolidate orderCalculationMethod check in verify-stand…
trevormil Apr 14, 2026
bcdfc57
refactor(review): unified Finding shape with required Localized strings
trevormil Apr 14, 2026
7cb0eca
fix(review): single normalization pass + NFT-gate maxSupply + hide pe…
trevormil Apr 14, 2026
120c066
fix(review): structural unbacking + soulbound + pre-apply metadata de…
trevormil Apr 14, 2026
49b7331
refactor(review): class-based BigIntify normalization, remove public-…
trevormil Apr 14, 2026
74c9429
fix(review): reattach WithDetails fields stripped by proto classes
trevormil Apr 14, 2026
bd702c5
fix(review): tone down forceful, quest escrow, amount-scaling; drop a…
trevormil Apr 14, 2026
1b2cf39
fix(review): remove mint_escrow_unfunded + directed_transfer_channel …
trevormil Apr 14, 2026
aa0dcb3
fix(review): forceful finding cases + parallel transfer mutability + …
trevormil Apr 14, 2026
1d1bda8
fix(review): strict 8-field blanket-lock detection + message cleanup
trevormil Apr 14, 2026
8665c65
fix(review): accurate forceful_transfers_not_locked text for explicit…
trevormil Apr 14, 2026
1408a3d
fix(review): upgrade all non-silent forceful cases to critical
trevormil Apr 14, 2026
ce42e29
chore(review): neutralize mint-centric language for smart-token colle…
trevormil Apr 14, 2026
944149e
fix(review): soften forceful_transfers_not_locked title for zero-matc…
trevormil Apr 14, 2026
5433fa6
security(builders): drop redundant override flags on auction/PM/crowd…
trevormil Apr 14, 2026
3929df3
feat(migration): consolidate metadataPlaceholders onto msg.value._met…
trevormil Apr 14, 2026
df97987
chore(scripts): port gen-skill-docs.ts to SDK + refresh auction/PM/cr…
trevormil Apr 14, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
112 changes: 112 additions & 0 deletions packages/bitbadgesjs-sdk/scripts/gen-skill-docs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
#!/usr/bin/env tsx
/**
* Generate docs pages from builder skill instructions.
*
* Source of truth: src/builder/resources/skillInstructions.ts
* Output: ../bitbadges-docs/x-tokenization/examples/skills/
*
* Ported from the old bitbadges-builder-mcp/scripts/gen-skill-docs.ts
* when the MCP server was folded into the SDK. The only real change is
* the import path — SKILL_INSTRUCTIONS now lives under the SDK's builder
* subpath. Output shape + docs destination are unchanged so the existing
* SUMMARY.md entries and any review diffs stay stable.
*
* Usage: npx tsx scripts/gen-skill-docs.ts
* (optional) DOCS_OUTPUT_DIR=/path/to/override npx tsx scripts/gen-skill-docs.ts
*/

import { SKILL_INSTRUCTIONS } from '../src/builder/resources/skillInstructions.js';
import { writeFileSync, mkdirSync } from 'fs';
import { dirname, join } from 'path';
import { fileURLToPath } from 'url';

// Resolve __dirname in a way that works both when tsx runs this file as
// ESM (import.meta.url present) and when it transpiles to CJS (falls
// back to __dirname if already defined). The docs output path is
// resolved relative to this script's location so running from any cwd
// produces the same result.
const here =
typeof __dirname !== 'undefined'
? __dirname
: dirname(fileURLToPath(import.meta.url));

const DOCS_DIR =
process.env.DOCS_OUTPUT_DIR ||
join(here, '../../../../bitbadges-docs/x-tokenization/examples/skills');

mkdirSync(DOCS_DIR, { recursive: true });

const categoryLabels: Record<string, string> = {
'token-type': 'Token Types',
standard: 'Standards',
approval: 'Approval Patterns',
feature: 'Features',
advanced: 'Advanced',
};

// Group skills by category for the README
const byCategory = new Map<string, typeof SKILL_INSTRUCTIONS>();
for (const skill of SKILL_INSTRUCTIONS) {
const list = byCategory.get(skill.category) || [];
list.push(skill);
byCategory.set(skill.category, list);
}

// Generate individual skill pages
for (const skill of SKILL_INSTRUCTIONS) {
const filename = `${skill.id}.md`;
const refs = skill.referenceCollectionIds?.length
? `\n\n## Reference Collections\n\n${skill.referenceCollectionIds
.map((id) => `- [Collection ${id}](https://bitbadges.io/collections/${id})`)
.join('\n')}`
: '';

const content = `# ${skill.name}

> ${skill.description}

**Category:** ${categoryLabels[skill.category] || skill.category}

## Summary

${skill.summary}

## Instructions

${skill.instructions}${refs}
`;

writeFileSync(join(DOCS_DIR, filename), content);
}

// Generate README index
const categoryOrder = ['token-type', 'standard', 'approval', 'feature', 'advanced'];
let readme = `# 🤖 Builder Skills

These pages document every guided build skill available in the BitBadges Builder (shipped as part of [bitbadgesjs-sdk](https://github.com/BitBadges/bitbadgesjs)). Each skill provides step-by-step instructions for building a specific type of token or configuring a specific feature.

> **Tip:** If you're using the BitBadges builder in Claude, Cursor, or another AI tool via the MCP server (\`npx bitbadgesjs-sdk-mcp\`) or the \`bitbadges-cli builder\` command surface, these instructions are loaded automatically when you select a skill. These pages are provided as a human-readable reference.

`;

for (const cat of categoryOrder) {
const skills = byCategory.get(cat);
if (!skills?.length) continue;
readme += `## ${categoryLabels[cat] || cat}\n\n`;
for (const skill of skills) {
readme += `- [${skill.name}](${skill.id}.md) — ${skill.description}\n`;
}
readme += '\n';
}

writeFileSync(join(DOCS_DIR, 'README.md'), readme);

// Print SUMMARY.md lines for easy copy-paste
console.log('\n=== Add these lines to SUMMARY.md as a top-level section ===\n');
console.log('## 🤖 Builder Skills\n');
console.log('* [Overview](x-tokenization/examples/skills/README.md)');
for (const skill of SKILL_INSTRUCTIONS) {
console.log(` * [${skill.name}](x-tokenization/examples/skills/${skill.id}.md)`);
}

console.log(`\n✅ Generated ${SKILL_INSTRUCTIONS.length} skill pages + README in ${DOCS_DIR}`);
10 changes: 7 additions & 3 deletions packages/bitbadgesjs-sdk/src/builder/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
#!/usr/bin/env node

/**
* BitBadges Builder MCP Server
* BitBadges Builder — Model Context Protocol (MCP) stdio server bin.
*
* Enable natural language collection creation via MCP.
* Entry point when users run `bitbadges-builder` or point Claude Desktop at
* this package as an MCP server. The actual tool/resource handlers live in
* `./tools/registry.ts` and `./resources/registry.ts` — this file is just
* the stdio transport + lifecycle wrapper. For in-process use, import the
* registry directly or call `bitbadges-cli builder …`.
*
* Example usage:
* Example natural-language usage (via an MCP client):
* > "Create a 1:1 backed USDC stablecoin with 100 USDC/day spend limit"
*
* Supported collection types:
Expand Down
86 changes: 45 additions & 41 deletions packages/bitbadgesjs-sdk/src/builder/resources/examplesDocs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,31 +130,33 @@ Create a collection of 100 unique NFTs with a public mint approval.
"cosmosCoinBackedPath": null
},
"aliasPathsToAdd": [],
"cosmosCoinWrapperPathsToAdd": []
"cosmosCoinWrapperPathsToAdd": [],
"_meta": {
"metadataPlaceholders": {
"ipfs://METADATA_COLLECTION": {
"name": "My NFT Collection",
"description": "A collection of 100 unique NFTs.",
"image": "ipfs://QmCollectionImage..."
},
"ipfs://METADATA_TOKEN_{id}": {
"name": "My NFT Collection Token",
"description": "A unique NFT from the My NFT Collection.",
"image": "ipfs://QmTokenImage..."
},
"ipfs://METADATA_APPROVAL_mint": {
"name": "Public Mint",
"description": "Allows anyone to mint one NFT for 5 BADGE.",
"image": ""
}
}
}
}
}
],
"memo": "",
"fee": {
"amount": [{ "denom": "ubadge", "amount": "5000" }],
"gas": "500000"
},
"metadataPlaceholders": {
"ipfs://METADATA_COLLECTION": {
"name": "My NFT Collection",
"description": "A collection of 100 unique NFTs.",
"image": "ipfs://QmCollectionImage..."
},
"ipfs://METADATA_TOKEN_{id}": {
"name": "My NFT Collection Token",
"description": "A unique NFT from the My NFT Collection.",
"image": "ipfs://QmTokenImage..."
},
"ipfs://METADATA_APPROVAL_mint": {
"name": "Public Mint",
"description": "Allows anyone to mint one NFT for 5 BADGE.",
"image": ""
}
}
}
\`\`\``,
Expand Down Expand Up @@ -253,36 +255,38 @@ Create a fungible token with unlimited supply.
"cosmosCoinBackedPath": null
},
"aliasPathsToAdd": [],
"cosmosCoinWrapperPathsToAdd": []
"cosmosCoinWrapperPathsToAdd": [],
"_meta": {
"metadataPlaceholders": {
"ipfs://METADATA_COLLECTION": {
"name": "My Token",
"description": "A fungible token with unlimited supply.",
"image": "ipfs://QmTokenImage..."
},
"ipfs://METADATA_TOKEN": {
"name": "MY",
"description": "The MY token unit.",
"image": "ipfs://QmTokenImage..."
},
"ipfs://METADATA_APPROVAL_mint": {
"name": "Public Mint",
"description": "Allows anyone to mint tokens freely.",
"image": ""
},
"ipfs://METADATA_APPROVAL_transfer": {
"name": "Free Transfer",
"description": "Allows free transfer between users.",
"image": ""
}
}
}
}
}
],
"memo": "",
"fee": {
"amount": [{ "denom": "ubadge", "amount": "5000" }],
"gas": "500000"
},
"metadataPlaceholders": {
"ipfs://METADATA_COLLECTION": {
"name": "My Token",
"description": "A fungible token with unlimited supply.",
"image": "ipfs://QmTokenImage..."
},
"ipfs://METADATA_TOKEN": {
"name": "MY",
"description": "The MY token unit.",
"image": "ipfs://QmTokenImage..."
},
"ipfs://METADATA_APPROVAL_mint": {
"name": "Public Mint",
"description": "Allows anyone to mint tokens freely.",
"image": ""
},
"ipfs://METADATA_APPROVAL_transfer": {
"name": "Free Transfer",
"description": "Allows free transfer between users.",
"image": ""
}
}
}
\`\`\``,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const FRONTEND_DOCS_CONTENT = {

### Address Handling
- Always validate addresses before use (0x or bb1 format)
- Use \`convert_address\` MCP tool or SDK's \`ethToCosmos\`/\`cosmosToEth\` for format conversion
- Use the \`convert_address\` builder tool or SDK's \`ethToCosmos\`/\`cosmosToEth\` for format conversion
- Display resolved names when available

### Amount Display
Expand All @@ -37,7 +37,7 @@ const FRONTEND_DOCS_CONTENT = {
- Show both the human-readable amount and denomination

### Transaction Flow
- Build transaction JSON (via MCP tools or manually)
- Build transaction JSON (via builder tools or manually)
- Present to user for review before signing
- User signs with their wallet (MetaMask for EVM, Keplr for Cosmos)
- Broadcast the signed transaction
Expand All @@ -46,7 +46,7 @@ const FRONTEND_DOCS_CONTENT = {
collectionPatterns: `## Working with Collections

### Fetching Collection Data
Use the BitBadges API (via SDK or MCP \`query_collection\` tool):
Use the BitBadges API (via SDK or the builder's \`query_collection\` tool):
\`\`\`typescript
import { BitBadgesAPI } from 'bitbadgesjs-sdk';

Expand Down Expand Up @@ -79,7 +79,7 @@ const protocolData = JSON.parse(collection.customData || '{}');
transactionPatterns: `## Transaction Patterns

### Building and Submitting
1. Build transaction JSON using MCP tools or construct manually
1. Build transaction JSON using builder tools or construct manually
2. Validate with \`validate_transaction\` tool
3. Present to user for review
4. User signs with their wallet
Expand Down
Loading
Loading