feat: add --print-prompt flag to output AI prompt to stdout

Allows piping prompt to other AI tools or saving to file:
  yarn docs:create --print-prompt draft.md > prompt.txt
  yarn docs:create --print-prompt draft.md | llm -m gpt-4

The flag:
- Prepares context and selects products
- Generates the full AI prompt
- Outputs to stdout and exits
- Works with both URL-based and draft-based workflows
jts-multifile-plugins-guide
Jason Stirnaman 2025-11-01 10:09:01 -05:00
parent 70272534a8
commit 4288c3b1aa
3 changed files with 60 additions and 1 deletions

View File

@ -78,5 +78,8 @@
"test": "test" "test": "test"
}, },
"keywords": [], "keywords": [],
"author": "" "author": "",
"optionalDependencies": {
"copilot": "^0.0.2"
}
} }

View File

@ -99,6 +99,7 @@ function parseArguments() {
ai: { type: 'string', default: 'claude' }, ai: { type: 'string', default: 'claude' },
execute: { type: 'boolean', default: false }, execute: { type: 'boolean', default: false },
'context-only': { type: 'boolean', default: false }, 'context-only': { type: 'boolean', default: false },
'print-prompt': { type: 'boolean', default: false },
proposal: { type: 'string' }, proposal: { type: 'string' },
'dry-run': { type: 'boolean', default: false }, 'dry-run': { type: 'boolean', default: false },
yes: { type: 'boolean', default: false }, yes: { type: 'boolean', default: false },
@ -153,6 +154,8 @@ ${colors.bright}Options:${colors.reset}
only local documentation links are followed. only local documentation links are followed.
--context-only Stop after context preparation --context-only Stop after context preparation
(for non-Claude tools) (for non-Claude tools)
--print-prompt Output the AI prompt to stdout and exit
(for piping to other tools)
--proposal <path> Import and execute proposal from JSON file --proposal <path> Import and execute proposal from JSON file
--dry-run Show what would be created without creating --dry-run Show what would be created without creating
--yes Skip confirmation prompt --yes Skip confirmation prompt
@ -214,6 +217,10 @@ ${colors.bright}Examples:${colors.reset}
cat drafts/quick-note.md | yarn docs:create --products influxdb3_core cat drafts/quick-note.md | yarn docs:create --products influxdb3_core
echo "# Test Content" | yarn docs:create --products influxdb3_core echo "# Test Content" | yarn docs:create --products influxdb3_core
# Output prompt for use with other AI tools
yarn docs:create --print-prompt drafts/new-feature.md > prompt.txt
yarn docs:create --print-prompt drafts/new-feature.md | llm -m gpt-4
# Preview changes # Preview changes
yarn docs:create --from-draft drafts/new-feature.md --dry-run yarn docs:create --from-draft drafts/new-feature.md --dry-run
@ -1214,6 +1221,25 @@ async function main() {
process.exit(0); process.exit(0);
} }
if (options['print-prompt']) {
// Generate and print prompt
const selectedProducts = await selectProducts(context, options);
const mode = context.urls?.length > 0 ? 'create' : 'create';
const isURLBased = true;
const hasExistingContent =
context.existingContent && Object.keys(context.existingContent).length > 0;
const prompt = generateClaudePrompt(
context,
selectedProducts,
mode,
isURLBased,
hasExistingContent
);
console.log(prompt);
process.exit(0);
}
// Continue with AI analysis (Phase 2) // Continue with AI analysis (Phase 2)
log('\n🤖 Running AI analysis with specialized agents...\n', 'bright'); log('\n🤖 Running AI analysis with specialized agents...\n', 'bright');
await runAgentAnalysis(context, options); await runAgentAnalysis(context, options);
@ -1229,6 +1255,24 @@ async function main() {
process.exit(0); process.exit(0);
} }
if (options['print-prompt']) {
// Generate and print prompt
const selectedProducts = await selectProducts(context, options);
const mode = 'create';
const isURLBased = false;
const hasExistingContent = false;
const prompt = generateClaudePrompt(
context,
selectedProducts,
mode,
isURLBased,
hasExistingContent
);
console.log(prompt);
process.exit(0);
}
// Continue with AI analysis (Phase 2) // Continue with AI analysis (Phase 2)
log('\n🤖 Running AI analysis with specialized agents...\n', 'bright'); log('\n🤖 Running AI analysis with specialized agents...\n', 'bright');
await runAgentAnalysis(context, options); await runAgentAnalysis(context, options);

View File

@ -194,6 +194,11 @@
resolved "https://registry.yarnpkg.com/@evilmartians/lefthook/-/lefthook-1.12.3.tgz#081eca59a6d33646616af844244ce6842cd6b5a5" resolved "https://registry.yarnpkg.com/@evilmartians/lefthook/-/lefthook-1.12.3.tgz#081eca59a6d33646616af844244ce6842cd6b5a5"
integrity sha512-MtXIt8h+EVTv5tCGLzh9UwbA/LRv6esdPJOHlxr8NDKHbFnbo8PvU5uVQcm3PAQTd4DZN3HoyokqrwGwntoq6w== integrity sha512-MtXIt8h+EVTv5tCGLzh9UwbA/LRv6esdPJOHlxr8NDKHbFnbo8PvU5uVQcm3PAQTd4DZN3HoyokqrwGwntoq6w==
"@github/copilot@latest":
version "0.0.353"
resolved "https://registry.yarnpkg.com/@github/copilot/-/copilot-0.0.353.tgz#3c8d8a072b3defbd2200c9fe4fb636d633ac7f1e"
integrity sha512-OYgCB4Jf7Y/Wor8mNNQcXEt1m1koYm/WwjGsr5mwABSVYXArWUeEfXqVbx+7O87ld5b+aWy2Zaa2bzKV8dmqaw==
"@humanfs/core@^0.19.1": "@humanfs/core@^0.19.1":
version "0.19.1" version "0.19.1"
resolved "https://registry.yarnpkg.com/@humanfs/core/-/core-0.19.1.tgz#17c55ca7d426733fe3c561906b8173c336b40a77" resolved "https://registry.yarnpkg.com/@humanfs/core/-/core-0.19.1.tgz#17c55ca7d426733fe3c561906b8173c336b40a77"
@ -1364,6 +1369,13 @@ confbox@^0.2.2:
resolved "https://registry.yarnpkg.com/confbox/-/confbox-0.2.2.tgz#8652f53961c74d9e081784beed78555974a9c110" resolved "https://registry.yarnpkg.com/confbox/-/confbox-0.2.2.tgz#8652f53961c74d9e081784beed78555974a9c110"
integrity sha512-1NB+BKqhtNipMsov4xI/NnhCKp9XG9NamYp5PVm9klAT0fsrNPjaFICsCFhNhwZJKNh7zB/3q8qXz0E9oaMNtQ== integrity sha512-1NB+BKqhtNipMsov4xI/NnhCKp9XG9NamYp5PVm9klAT0fsrNPjaFICsCFhNhwZJKNh7zB/3q8qXz0E9oaMNtQ==
copilot@^0.0.2:
version "0.0.2"
resolved "https://registry.yarnpkg.com/copilot/-/copilot-0.0.2.tgz#4712810c9182cd784820ed44627bedd32dd377f9"
integrity sha512-nedf34AaYj9JnFhRmiJEZemAno2WDXMypq6FW5aCVR0N+QdpQ6viukP1JpvJDChpaMEVvbUkMjmjMifJbO/AgQ==
dependencies:
"@github/copilot" latest
core-util-is@1.0.2: core-util-is@1.0.2:
version "1.0.2" version "1.0.2"
resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7" resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7"