@0xdevabir/enhance 0.1.2 → 0.1.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.
Files changed (2) hide show
  1. package/dist/index.js +22 -10
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -3,6 +3,7 @@
3
3
  // src/cli/index.ts
4
4
  import { Command } from "commander";
5
5
  import { createInterface } from "readline";
6
+ import { createRequire } from "module";
6
7
  import ora from "ora";
7
8
  import chalk3 from "chalk";
8
9
 
@@ -73,10 +74,10 @@ async function readPackageJson(root) {
73
74
  // src/scanner/frameworks.ts
74
75
  import { stat } from "fs/promises";
75
76
  import { join as join2 } from "path";
76
- async function detectStack(pkg, root) {
77
+ async function detectStack(pkg2, root) {
77
78
  const deps = {
78
- ...pkg["dependencies"] ?? {},
79
- ...pkg["devDependencies"] ?? {}
79
+ ...pkg2["dependencies"] ?? {},
80
+ ...pkg2["devDependencies"] ?? {}
80
81
  };
81
82
  const has = (name) => name in deps;
82
83
  const frameworks = [];
@@ -204,11 +205,11 @@ async function readTsConfig(root) {
204
205
 
205
206
  // src/scanner/index.ts
206
207
  async function scanProject(root) {
207
- const [pkg, structure] = await Promise.all([
208
+ const [pkg2, structure] = await Promise.all([
208
209
  readPackageJson(root),
209
210
  scanFolderStructure(root)
210
211
  ]);
211
- const safePkg = pkg ?? {};
212
+ const safePkg = pkg2 ?? {};
212
213
  const [stack] = await Promise.all([
213
214
  detectStack(safePkg, root),
214
215
  readTsConfig(root)
@@ -1372,18 +1373,21 @@ async function fileExists(path) {
1372
1373
  }
1373
1374
 
1374
1375
  // src/cli/index.ts
1376
+ var require2 = createRequire(import.meta.url);
1377
+ var pkg = require2("../package.json");
1375
1378
  var program = new Command();
1376
- program.name("enhance").description("AI prompt middleware \u2014 upgrades vague prompts into production-quality AI instructions").version("0.1.0");
1379
+ program.name("enhance").description("AI prompt middleware \u2014 upgrades vague prompts into production-quality AI instructions").version(pkg.version);
1377
1380
  program.command("setup").description("Install the /enhance slash command for Claude Code, OpenCode, and Codex CLI").option("--force", "Overwrite existing installations").option("--all", "Install for all supported tools even if not detected in PATH").action(async (opts) => {
1378
1381
  await runSetup(opts);
1379
1382
  });
1380
- program.command("<prompt>", { isDefault: true }).description("Enhance a prompt and send to AI").addHelpText("after", `
1383
+ program.argument("[prompt]", "Prompt to enhance and send to AI").addHelpText("after", `
1381
1384
  Examples:
1382
1385
  enhance "build a login page"
1383
1386
  enhance "fix the auth bug" --dry-run
1384
1387
  enhance "create dashboard" --confirm --verbose
1385
1388
  enhance "refactor user service" --provider codex
1386
- enhance "add auth" --action add --feature auth`).option("-p, --provider <name>", "AI provider: claude | codex | opencode").option("--dry-run", "Print enhanced prompt without sending to AI").option("--print-prompt", "Print enhanced prompt before sending to AI").option("--preview", "Color-coded prompt preview with per-section token counts").option("--verbose", "Show detected stack, intent, and context stats").option("--confirm", "Show detected intent and ask for approval before enhancing").option("--plan", "Decompose complex task into sequential sub-prompts (uses AI)").option("--iteration <n>", "Angle iteration: 0=completeness, 1=production, 2=dx, 3=alternative", "0").option("--action <action>", "Override detected action (create|fix|refactor|explain|add|delete)").option("--entity <entity>", "Override detected entity (page|component|api|hook|util|config|style)").option("--feature <feature>", "Override detected feature (auth|payment|user|upload|...)").action(async (rawPrompt, opts) => {
1389
+ enhance "add auth" --action add --feature auth
1390
+ enhance "add payments" --iteration 1`).option("-p, --provider <name>", "AI provider: claude | codex | opencode").option("--dry-run", "Print enhanced prompt without sending to AI").option("--print-prompt", "Print enhanced prompt before sending to AI").option("--preview", "Color-coded prompt preview with per-section token counts").option("--verbose", "Show detected stack, intent, and context stats").option("--confirm", "Show detected intent and ask for approval before enhancing").option("--plan", "Decompose complex task into sequential sub-prompts (uses AI)").option("--iteration <n>", "Angle iteration: 0=completeness, 1=production, 2=dx, 3=alternative", "0").option("--action <action>", "Override detected action (create|fix|refactor|explain|add|delete)").option("--entity <entity>", "Override detected entity (page|component|api|hook|util|config|style)").option("--feature <feature>", "Override detected feature (auth|payment|user|upload|...)").action(async (rawPrompt, opts) => {
1387
1391
  if (!rawPrompt) {
1388
1392
  program.help();
1389
1393
  return;
@@ -1529,7 +1533,9 @@ function printColoredPreview(prompt) {
1529
1533
  "Project Context": chalk3.blue,
1530
1534
  "Task": chalk3.yellow,
1531
1535
  "Requirements": chalk3.green,
1532
- "Recent Changes": chalk3.cyan,
1536
+ "Assumptions": chalk3.cyan,
1537
+ "Watch out for": chalk3.red,
1538
+ "Recent Changes": chalk3.dim,
1533
1539
  "Relevant Code": chalk3.dim,
1534
1540
  "Code": chalk3.dim,
1535
1541
  "Expected Output": chalk3.white
@@ -1541,10 +1547,16 @@ function printColoredPreview(prompt) {
1541
1547
  console.log(chalk3.dim(`Total: ~${totalTokens} tokens
1542
1548
  `));
1543
1549
  for (const section of sections) {
1550
+ const sectionTokens = Math.ceil(section.length / CHARS_PER_TOKEN2);
1551
+ const versionMatch = section.trim().match(/^(📍.+)/);
1552
+ if (versionMatch && !section.match(/^## /m)) {
1553
+ console.log(chalk3.bold.cyan(versionMatch[1]) + chalk3.dim(` (~${sectionTokens} tok)`));
1554
+ console.log();
1555
+ continue;
1556
+ }
1544
1557
  const headerMatch = section.match(/^## (.+)/m);
1545
1558
  const headerName = headerMatch?.[1]?.trim() ?? "Section";
1546
1559
  const colorFn = SECTION_COLORS[headerName] ?? chalk3.white;
1547
- const sectionTokens = Math.ceil(section.length / CHARS_PER_TOKEN2);
1548
1560
  console.log(colorFn(chalk3.bold(`## ${headerName}`)) + chalk3.dim(` (~${sectionTokens} tok)`));
1549
1561
  const body = section.replace(/^## .+\n?/, "").trim();
1550
1562
  if (body) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@0xdevabir/enhance",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "AI prompt middleware — intelligently rewrites developer prompts before sending to coding agents",
5
5
  "bin": {
6
6
  "enhance": "./bin/enhance.js"