promptarch 1.0.3 → 1.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.
Files changed (2) hide show
  1. package/dist/index.js +45 -28
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -4,7 +4,7 @@
4
4
  import { Command } from "commander";
5
5
 
6
6
  // src/commands/init.ts
7
- import { access, mkdir as mkdir2, writeFile as writeFile2 } from "fs/promises";
7
+ import { access, mkdir as mkdir2, readdir as readdir2, writeFile as writeFile2 } from "fs/promises";
8
8
  import { dirname, join as join3, resolve } from "path";
9
9
 
10
10
  // ../packages/core/context-model/types.ts
@@ -451,6 +451,26 @@ async function fileExists(path) {
451
451
  return false;
452
452
  }
453
453
  }
454
+ var STATIC_OUTPUTS = [
455
+ "AGENTS.md",
456
+ "CLAUDE.md",
457
+ ".github/copilot-instructions.md"
458
+ ];
459
+ var OUTPUT_DIRS = [".cursor/rules", ".github/instructions"];
460
+ async function existingOutputs(outDir) {
461
+ const hits = [];
462
+ for (const p of STATIC_OUTPUTS) {
463
+ if (await fileExists(join3(outDir, p))) hits.push(p);
464
+ }
465
+ for (const d of OUTPUT_DIRS) {
466
+ try {
467
+ const entries = await readdir2(join3(outDir, d));
468
+ if (entries.length > 0) hits.push(`${d}/ (${entries.length} file(s))`);
469
+ } catch {
470
+ }
471
+ }
472
+ return hits;
473
+ }
454
474
  async function initCmd(opts) {
455
475
  const cwd = process.cwd();
456
476
  const info = await extractRepo(cwd);
@@ -481,6 +501,29 @@ async function initCmd(opts) {
481
501
  process.exitCode = 1;
482
502
  return;
483
503
  }
504
+ const outDir = opts.out ? resolve(cwd, opts.out) : cwd;
505
+ if (!opts.force) {
506
+ const existing = await existingOutputs(outDir);
507
+ if (existing.length > 0) {
508
+ console.log(
509
+ `
510
+ init writes agent config files into ${outDir}, overwriting:
511
+ ${existing.join("\n ")}`
512
+ );
513
+ if (!process.stdin.isTTY) {
514
+ console.error(
515
+ "\nAborted (non-interactive). Re-run with --force to overwrite, or --out <dir> to write elsewhere."
516
+ );
517
+ process.exitCode = 1;
518
+ return;
519
+ }
520
+ const ok = await confirm("\nContinue? Generating uses one credit. [y/N]");
521
+ if (!ok) {
522
+ console.log("Aborted. No credit used, no files written.");
523
+ return;
524
+ }
525
+ }
526
+ }
484
527
  const url = `${resolveApiUrl(cfg)}/api/build`;
485
528
  let res;
486
529
  try {
@@ -523,32 +566,6 @@ async function initCmd(opts) {
523
566
  }
524
567
  const pack = parseContextModel(body.prompt);
525
568
  const files = exportPack(pack, ALL_EXPORT_FORMATS);
526
- const outDir = opts.out ? resolve(cwd, opts.out) : cwd;
527
- if (!opts.force) {
528
- const existing = [];
529
- for (const f of files) {
530
- if (await fileExists(join3(outDir, f.path))) existing.push(f.path);
531
- }
532
- if (existing.length > 0) {
533
- console.log(
534
- `
535
- These file(s) already exist in ${outDir}:
536
- ${existing.join("\n ")}`
537
- );
538
- if (!process.stdin.isTTY) {
539
- console.error(
540
- "\nAborted (non-interactive). Re-run with --force to overwrite, or --out <dir> to write elsewhere."
541
- );
542
- process.exitCode = 1;
543
- return;
544
- }
545
- const ok = await confirm("\nOverwrite them? [y/N]");
546
- if (!ok) {
547
- console.log("Aborted. No files written.");
548
- return;
549
- }
550
- }
551
- }
552
569
  for (const f of files) {
553
570
  const dest = join3(outDir, f.path);
554
571
  await mkdir2(dirname(dest), { recursive: true });
@@ -1064,7 +1081,7 @@ async function login(opts) {
1064
1081
  var program = new Command();
1065
1082
  program.name("promptarch").description(
1066
1083
  "Generate and lint AI coding-agent context files (CLAUDE.md, AGENTS.md, Cursor rules) from your repo."
1067
- ).version("1.0.3");
1084
+ ).version("1.0.4");
1068
1085
  program.command("login").description("Store a PromptArch API key (pk_...) in ~/.config/promptarch").option("--key <key>", "API key (non-interactive; for CI)").action(login);
1069
1086
  program.command("lint").description("Lint agent context files offline (deterministic, free, CI-friendly)").argument("<files...>", "Files to lint (CLAUDE.md, AGENTS.md, *.mdc, ...)").option("--strict", "Fail on warnings too, not just errors").action((files, opts) => lintCmd(files, opts));
1070
1087
  program.command("init").description("Extract repo context and generate CLAUDE.md / AGENTS.md / Cursor / Copilot files").option("--dry-run", "Print the extracted payload without calling the API").option("--out <dir>", "Output directory (default: current directory)").option("--force", "Overwrite existing files without prompting").action(initCmd);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "promptarch",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "Generate and lint AI coding-agent context files (CLAUDE.md, AGENTS.md, Cursor rules) from your repo.",
5
5
  "keywords": [
6
6
  "claude",