@riotprompt/riotprompt 0.0.3 → 0.0.4
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/.cursor/rules/focus-on-prompt.mdc +5 -0
- package/README.md +61 -72
- package/dist/builder.js +2 -2
- package/dist/builder.js.map +1 -1
- package/dist/chat.js.map +1 -1
- package/dist/formatter.js.map +1 -1
- package/dist/items/parameters.js.map +1 -1
- package/dist/items/section.js.map +1 -1
- package/dist/loader.js.map +1 -1
- package/dist/logger.js.map +1 -1
- package/dist/override.js.map +1 -1
- package/dist/parse/markdown.d.ts +1 -1
- package/dist/parse/markdown.js +3 -2
- package/dist/parse/markdown.js.map +1 -1
- package/dist/parse/text.js.map +1 -1
- package/dist/parser.d.ts +1 -1
- package/dist/parser.js +3 -3
- package/dist/parser.js.map +1 -1
- package/dist/recipes.d.ts +19 -51
- package/dist/recipes.js +36 -181
- package/dist/recipes.js.map +1 -1
- package/dist/riotprompt.cjs +48 -200
- package/dist/riotprompt.cjs.map +1 -1
- package/dist/riotprompt.d.ts +1 -1
- package/dist/riotprompt.js +1 -1
- package/dist/util/general.js.map +1 -1
- package/dist/util/markdown.js.map +1 -1
- package/dist/util/storage.js.map +1 -1
- package/dist/util/text.js.map +1 -1
- package/package.json +3 -3
package/dist/riotprompt.cjs
CHANGED
|
@@ -5,7 +5,6 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
5
5
|
const zod = require('zod');
|
|
6
6
|
const fs = require('fs/promises');
|
|
7
7
|
const path = require('path');
|
|
8
|
-
const marked = require('marked');
|
|
9
8
|
const fs$1 = require('fs');
|
|
10
9
|
const glob = require('glob');
|
|
11
10
|
const crypto = require('crypto');
|
|
@@ -495,7 +494,9 @@ const formatter = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty(
|
|
|
495
494
|
create: create$5
|
|
496
495
|
}, Symbol.toStringTag, { value: 'Module' }));
|
|
497
496
|
|
|
498
|
-
const parseMarkdown = (input, options = {})=>{
|
|
497
|
+
const parseMarkdown = async (input, options = {})=>{
|
|
498
|
+
// Dynamic import for marked (ES module)
|
|
499
|
+
const { marked } = await import('marked');
|
|
499
500
|
let markdownContent;
|
|
500
501
|
if (typeof input === 'string') {
|
|
501
502
|
markdownContent = input;
|
|
@@ -504,7 +505,7 @@ const parseMarkdown = (input, options = {})=>{
|
|
|
504
505
|
}
|
|
505
506
|
const sectionOptions = SectionOptionsSchema.parse(options);
|
|
506
507
|
// Use marked.lexer to get tokens without full parsing/rendering
|
|
507
|
-
const tokens = marked.
|
|
508
|
+
const tokens = marked.lexer(markdownContent);
|
|
508
509
|
// Create the main section (with a Title from the options)
|
|
509
510
|
const mainSection = create$8(sectionOptions);
|
|
510
511
|
// Track sections at each depth level
|
|
@@ -788,7 +789,7 @@ const create$4 = (parserOptions)=>{
|
|
|
788
789
|
const content = await fs__namespace.readFile(filePath, 'utf-8');
|
|
789
790
|
// Only use the filename as title if no title was explicitly provided
|
|
790
791
|
const fileName = path__namespace.basename(filePath, path__namespace.extname(filePath));
|
|
791
|
-
return parse(content, {
|
|
792
|
+
return await parse(content, {
|
|
792
793
|
...currentOptions,
|
|
793
794
|
title: (currentOptions === null || currentOptions === void 0 ? void 0 : currentOptions.title) || fileName
|
|
794
795
|
});
|
|
@@ -808,11 +809,11 @@ const create$4 = (parserOptions)=>{
|
|
|
808
809
|
*
|
|
809
810
|
* @param content The content to parse
|
|
810
811
|
* @returns A Section containing all content in a hierarchical structure
|
|
811
|
-
*/ const parse = (content, options = {})=>{
|
|
812
|
+
*/ const parse = async (content, options = {})=>{
|
|
812
813
|
const currentOptions = loadOptions(options);
|
|
813
814
|
let mainSection;
|
|
814
815
|
if (isMarkdown(content)) {
|
|
815
|
-
mainSection = parseMarkdown(content, currentOptions);
|
|
816
|
+
mainSection = await parseMarkdown(content, currentOptions);
|
|
816
817
|
} else if (isText(content)) {
|
|
817
818
|
mainSection = parseText(content, currentOptions);
|
|
818
819
|
} else {
|
|
@@ -1332,7 +1333,7 @@ const create = (builderOptions)=>{
|
|
|
1332
1333
|
const addContent = async (content, sectionOptions = {})=>{
|
|
1333
1334
|
logger.debug("Adding content", typeof content);
|
|
1334
1335
|
const currentOptions = loadOptions(sectionOptions);
|
|
1335
|
-
const parsedContentSection = parser$1.parse(content, currentOptions);
|
|
1336
|
+
const parsedContentSection = await parser$1.parse(content, currentOptions);
|
|
1336
1337
|
contentSection.add(parsedContentSection);
|
|
1337
1338
|
return instance;
|
|
1338
1339
|
};
|
|
@@ -1340,7 +1341,7 @@ const create = (builderOptions)=>{
|
|
|
1340
1341
|
const addContext = async (context, sectionOptions = {})=>{
|
|
1341
1342
|
logger.debug("Adding context", typeof context);
|
|
1342
1343
|
const currentOptions = loadOptions(sectionOptions);
|
|
1343
|
-
const parsedContextSection = parser$1.parse(context, currentOptions);
|
|
1344
|
+
const parsedContextSection = await parser$1.parse(context, currentOptions);
|
|
1344
1345
|
contextSection.add(parsedContextSection);
|
|
1345
1346
|
return instance;
|
|
1346
1347
|
};
|
|
@@ -1392,104 +1393,50 @@ const RecipeConfigSchema = zod.z.object({
|
|
|
1392
1393
|
]),
|
|
1393
1394
|
overrides: zod.z.boolean().optional().default(false),
|
|
1394
1395
|
parameters: ParametersSchema.optional().default({}),
|
|
1395
|
-
// Content sections
|
|
1396
|
+
// Content sections
|
|
1396
1397
|
persona: ContentItemSchema.optional(),
|
|
1397
1398
|
instructions: zod.z.array(ContentItemSchema).optional().default([]),
|
|
1398
1399
|
content: zod.z.array(ContentItemSchema).optional().default([]),
|
|
1399
1400
|
context: zod.z.array(ContentItemSchema).optional().default([]),
|
|
1400
1401
|
// Templates and inheritance
|
|
1401
1402
|
extends: zod.z.string().optional(),
|
|
1402
|
-
template: zod.z.
|
|
1403
|
-
'commit',
|
|
1404
|
-
'release',
|
|
1405
|
-
'documentation',
|
|
1406
|
-
'review',
|
|
1407
|
-
'custom'
|
|
1408
|
-
]).optional()
|
|
1403
|
+
template: zod.z.string().optional()
|
|
1409
1404
|
});
|
|
1410
|
-
// Built-in template configurations matching common patterns
|
|
1411
|
-
const DEFAULT_TEMPLATES = {
|
|
1412
|
-
commit: {
|
|
1413
|
-
persona: {
|
|
1414
|
-
path: "personas/developer.md",
|
|
1415
|
-
title: "Developer Persona"
|
|
1416
|
-
},
|
|
1417
|
-
instructions: [
|
|
1418
|
-
{
|
|
1419
|
-
path: "instructions/commit.md",
|
|
1420
|
-
title: "Commit Instructions"
|
|
1421
|
-
}
|
|
1422
|
-
]
|
|
1423
|
-
},
|
|
1424
|
-
release: {
|
|
1425
|
-
persona: {
|
|
1426
|
-
path: "personas/releaser.md",
|
|
1427
|
-
title: "Release Manager Persona"
|
|
1428
|
-
},
|
|
1429
|
-
instructions: [
|
|
1430
|
-
{
|
|
1431
|
-
path: "instructions/release.md",
|
|
1432
|
-
title: "Release Instructions"
|
|
1433
|
-
}
|
|
1434
|
-
]
|
|
1435
|
-
},
|
|
1436
|
-
documentation: {
|
|
1437
|
-
persona: {
|
|
1438
|
-
path: "personas/technical-writer.md",
|
|
1439
|
-
title: "Technical Writer Persona"
|
|
1440
|
-
},
|
|
1441
|
-
instructions: [
|
|
1442
|
-
{
|
|
1443
|
-
path: "instructions/documentation.md",
|
|
1444
|
-
title: "Documentation Instructions"
|
|
1445
|
-
}
|
|
1446
|
-
]
|
|
1447
|
-
},
|
|
1448
|
-
review: {
|
|
1449
|
-
persona: {
|
|
1450
|
-
path: "personas/reviewer.md",
|
|
1451
|
-
title: "Code Reviewer Persona"
|
|
1452
|
-
},
|
|
1453
|
-
instructions: [
|
|
1454
|
-
{
|
|
1455
|
-
path: "instructions/review.md",
|
|
1456
|
-
title: "Review Instructions"
|
|
1457
|
-
}
|
|
1458
|
-
]
|
|
1459
|
-
}
|
|
1460
|
-
};
|
|
1461
1405
|
// User-customizable template registry
|
|
1462
|
-
let TEMPLATES = {
|
|
1463
|
-
...DEFAULT_TEMPLATES
|
|
1464
|
-
};
|
|
1406
|
+
let TEMPLATES = {};
|
|
1465
1407
|
/**
|
|
1466
|
-
*
|
|
1408
|
+
* Register custom templates with the recipes system
|
|
1467
1409
|
*
|
|
1468
1410
|
* @example
|
|
1469
1411
|
* ```typescript
|
|
1470
|
-
* //
|
|
1471
|
-
*
|
|
1472
|
-
*
|
|
1473
|
-
* persona: { path:
|
|
1474
|
-
* instructions: [{ path:
|
|
1412
|
+
* // Register your own templates
|
|
1413
|
+
* registerTemplates({
|
|
1414
|
+
* myWorkflow: {
|
|
1415
|
+
* persona: { path: "personas/my-persona.md" },
|
|
1416
|
+
* instructions: [{ path: "instructions/my-instructions.md" }]
|
|
1475
1417
|
* },
|
|
1476
|
-
*
|
|
1477
|
-
* persona: {
|
|
1478
|
-
* instructions: [{
|
|
1418
|
+
* anotherTemplate: {
|
|
1419
|
+
* persona: { content: "You are a helpful assistant" },
|
|
1420
|
+
* instructions: [{ content: "Follow these steps..." }]
|
|
1479
1421
|
* }
|
|
1480
1422
|
* });
|
|
1481
1423
|
* ```
|
|
1482
|
-
*/ const
|
|
1424
|
+
*/ const registerTemplates = (templates)=>{
|
|
1483
1425
|
TEMPLATES = {
|
|
1484
|
-
...
|
|
1485
|
-
...
|
|
1426
|
+
...TEMPLATES,
|
|
1427
|
+
...templates
|
|
1486
1428
|
};
|
|
1487
1429
|
};
|
|
1488
1430
|
/**
|
|
1489
|
-
* Get
|
|
1431
|
+
* Get currently registered templates
|
|
1490
1432
|
*/ const getTemplates = ()=>({
|
|
1491
1433
|
...TEMPLATES
|
|
1492
1434
|
});
|
|
1435
|
+
/**
|
|
1436
|
+
* Clear all registered templates
|
|
1437
|
+
*/ const clearTemplates = ()=>{
|
|
1438
|
+
TEMPLATES = {};
|
|
1439
|
+
};
|
|
1493
1440
|
// ===== CORE RECIPE ENGINE =====
|
|
1494
1441
|
const cook = async (config)=>{
|
|
1495
1442
|
// Parse and validate configuration with defaults
|
|
@@ -1512,8 +1459,20 @@ const cook = async (config)=>{
|
|
|
1512
1459
|
const template = TEMPLATES[validatedConfig.template];
|
|
1513
1460
|
if (template) {
|
|
1514
1461
|
finalConfig = {
|
|
1515
|
-
...
|
|
1516
|
-
|
|
1462
|
+
...validatedConfig,
|
|
1463
|
+
persona: validatedConfig.persona || template.persona,
|
|
1464
|
+
instructions: [
|
|
1465
|
+
...template.instructions || [],
|
|
1466
|
+
...validatedConfig.instructions || []
|
|
1467
|
+
],
|
|
1468
|
+
content: [
|
|
1469
|
+
...template.content || [],
|
|
1470
|
+
...validatedConfig.content || []
|
|
1471
|
+
],
|
|
1472
|
+
context: [
|
|
1473
|
+
...template.context || [],
|
|
1474
|
+
...validatedConfig.context || []
|
|
1475
|
+
]
|
|
1517
1476
|
};
|
|
1518
1477
|
}
|
|
1519
1478
|
}
|
|
@@ -1625,109 +1584,6 @@ const processContentItem = async (item, section, type, ctx)=>{
|
|
|
1625
1584
|
section.add(sections);
|
|
1626
1585
|
}
|
|
1627
1586
|
};
|
|
1628
|
-
// ===== CONVENIENCE FUNCTIONS =====
|
|
1629
|
-
const commit = (config)=>cook({
|
|
1630
|
-
...config,
|
|
1631
|
-
template: 'commit'
|
|
1632
|
-
});
|
|
1633
|
-
const release = (config)=>cook({
|
|
1634
|
-
...config,
|
|
1635
|
-
template: 'release'
|
|
1636
|
-
});
|
|
1637
|
-
const documentation = (config)=>cook({
|
|
1638
|
-
...config,
|
|
1639
|
-
template: 'documentation'
|
|
1640
|
-
});
|
|
1641
|
-
const review = (config)=>cook({
|
|
1642
|
-
...config,
|
|
1643
|
-
template: 'review'
|
|
1644
|
-
});
|
|
1645
|
-
// ===== QUICK BUILDERS =====
|
|
1646
|
-
const quick = {
|
|
1647
|
-
/**
|
|
1648
|
-
* Create a commit prompt with minimal configuration
|
|
1649
|
-
*/ commit: async (diffContent, options)=>{
|
|
1650
|
-
return cook({
|
|
1651
|
-
basePath: options.basePath,
|
|
1652
|
-
overridePaths: options.overridePaths,
|
|
1653
|
-
overrides: options.overrides,
|
|
1654
|
-
template: 'commit',
|
|
1655
|
-
content: [
|
|
1656
|
-
...options.userDirection ? [
|
|
1657
|
-
{
|
|
1658
|
-
content: options.userDirection,
|
|
1659
|
-
title: 'User Direction',
|
|
1660
|
-
weight: 1.0
|
|
1661
|
-
}
|
|
1662
|
-
] : [],
|
|
1663
|
-
{
|
|
1664
|
-
content: diffContent,
|
|
1665
|
-
title: 'Diff',
|
|
1666
|
-
weight: 0.5
|
|
1667
|
-
}
|
|
1668
|
-
],
|
|
1669
|
-
context: [
|
|
1670
|
-
...options.context ? [
|
|
1671
|
-
{
|
|
1672
|
-
content: options.context,
|
|
1673
|
-
title: 'User Context',
|
|
1674
|
-
weight: 1.0
|
|
1675
|
-
}
|
|
1676
|
-
] : [],
|
|
1677
|
-
...options.directories ? [
|
|
1678
|
-
{
|
|
1679
|
-
directories: options.directories,
|
|
1680
|
-
weight: 0.5
|
|
1681
|
-
}
|
|
1682
|
-
] : []
|
|
1683
|
-
]
|
|
1684
|
-
});
|
|
1685
|
-
},
|
|
1686
|
-
/**
|
|
1687
|
-
* Create a release prompt with minimal configuration
|
|
1688
|
-
*/ release: async (logContent, diffContent, options)=>{
|
|
1689
|
-
return cook({
|
|
1690
|
-
basePath: options.basePath,
|
|
1691
|
-
overridePaths: options.overridePaths,
|
|
1692
|
-
overrides: options.overrides,
|
|
1693
|
-
template: 'release',
|
|
1694
|
-
content: [
|
|
1695
|
-
...options.releaseFocus ? [
|
|
1696
|
-
{
|
|
1697
|
-
content: options.releaseFocus,
|
|
1698
|
-
title: 'Release Focus',
|
|
1699
|
-
weight: 1.0
|
|
1700
|
-
}
|
|
1701
|
-
] : [],
|
|
1702
|
-
{
|
|
1703
|
-
content: logContent,
|
|
1704
|
-
title: 'Log',
|
|
1705
|
-
weight: 0.5
|
|
1706
|
-
},
|
|
1707
|
-
{
|
|
1708
|
-
content: diffContent,
|
|
1709
|
-
title: 'Diff',
|
|
1710
|
-
weight: 0.5
|
|
1711
|
-
}
|
|
1712
|
-
],
|
|
1713
|
-
context: [
|
|
1714
|
-
...options.context ? [
|
|
1715
|
-
{
|
|
1716
|
-
content: options.context,
|
|
1717
|
-
title: 'User Context',
|
|
1718
|
-
weight: 1.0
|
|
1719
|
-
}
|
|
1720
|
-
] : [],
|
|
1721
|
-
...options.directories ? [
|
|
1722
|
-
{
|
|
1723
|
-
directories: options.directories,
|
|
1724
|
-
weight: 0.5
|
|
1725
|
-
}
|
|
1726
|
-
] : []
|
|
1727
|
-
]
|
|
1728
|
-
});
|
|
1729
|
-
}
|
|
1730
|
-
};
|
|
1731
1587
|
// ===== FLUENT RECIPE BUILDER =====
|
|
1732
1588
|
const recipe = (basePath)=>({
|
|
1733
1589
|
template: (name)=>({
|
|
@@ -1775,15 +1631,11 @@ const recipe = (basePath)=>({
|
|
|
1775
1631
|
|
|
1776
1632
|
const recipes = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
|
|
1777
1633
|
__proto__: null,
|
|
1778
|
-
|
|
1779
|
-
configureTemplates,
|
|
1634
|
+
clearTemplates,
|
|
1780
1635
|
cook,
|
|
1781
|
-
documentation,
|
|
1782
1636
|
getTemplates,
|
|
1783
|
-
quick,
|
|
1784
1637
|
recipe,
|
|
1785
|
-
|
|
1786
|
-
review
|
|
1638
|
+
registerTemplates
|
|
1787
1639
|
}, Symbol.toStringTag, { value: 'Module' }));
|
|
1788
1640
|
|
|
1789
1641
|
exports.Builder = builder;
|
|
@@ -1793,8 +1645,7 @@ exports.Loader = loader;
|
|
|
1793
1645
|
exports.Override = override;
|
|
1794
1646
|
exports.Parser = parser;
|
|
1795
1647
|
exports.Recipes = recipes;
|
|
1796
|
-
exports.
|
|
1797
|
-
exports.configureTemplates = configureTemplates;
|
|
1648
|
+
exports.clearTemplates = clearTemplates;
|
|
1798
1649
|
exports.cook = cook;
|
|
1799
1650
|
exports.createContent = create$b;
|
|
1800
1651
|
exports.createContext = create$a;
|
|
@@ -1804,10 +1655,7 @@ exports.createPrompt = create$6;
|
|
|
1804
1655
|
exports.createSection = create$8;
|
|
1805
1656
|
exports.createTrait = create$7;
|
|
1806
1657
|
exports.createWeighted = create$c;
|
|
1807
|
-
exports.documentation = documentation;
|
|
1808
1658
|
exports.getTemplates = getTemplates;
|
|
1809
|
-
exports.quick = quick;
|
|
1810
1659
|
exports.recipe = recipe;
|
|
1811
|
-
exports.
|
|
1812
|
-
exports.review = review;
|
|
1660
|
+
exports.registerTemplates = registerTemplates;
|
|
1813
1661
|
//# sourceMappingURL=riotprompt.cjs.map
|