00-INDEX.txt 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. OAC CLI Fix Plans — Package Standards Review
  2. ============================================
  3. Generated: 2026-03-11
  4. Source files read: package.json, .npmignore, bin/oac.js, packages/cli/package.json,
  5. packages/cli/src/index.ts, packages/cli/src/lib/bundled.ts,
  6. packages/cli/src/lib/installer.ts, packages/cli/src/lib/manifest.ts,
  7. packages/cli/src/lib/config.ts, packages/cli/src/commands/init.ts,
  8. packages/cli/src/commands/update.ts, packages/cli/src/commands/doctor.ts,
  9. packages/cli/src/ui/logger.ts, packages/cli/src/ui/spinner.ts,
  10. packages/cli/src/lib/version.ts, README.md
  11. CRITICAL (must fix before publish):
  12. C1 .npmignore excludes built CLI from published package
  13. File: .npmignore
  14. The `packages/` and `dist/` patterns in .npmignore exclude
  15. packages/cli/dist/ — the compiled Bun binary. The package ships empty.
  16. C2 No prepublishOnly build guard
  17. Files: package.json (root), packages/cli/package.json
  18. Neither file has a prepublishOnly script. Running npm publish without
  19. building first silently ships an empty or stale dist/.
  20. C3+C4 findPackageRoot fails in production + bin/oac.js fix
  21. Files: packages/cli/src/lib/bundled.ts, bin/oac.js
  22. C3: findPackageRoot() excludes dirs with registry.json, but registry.json
  23. IS in the published package (root package.json files array, line 30).
  24. Every globally installed user gets "could not find package root" on
  25. oac init and oac update.
  26. C4: bin/oac.js knows the package root via __dirname — it should inject
  27. OAC_PACKAGE_ROOT as an env var so the Bun binary never needs to walk.
  28. C5 engines field claims Node.js but CLI requires Bun
  29. File: package.json (root)
  30. Root package declares "node": ">=18.0.0" only. The CLI binary uses
  31. Bun.file(), Bun.write(), Bun.version, import.meta.dir — none of which
  32. exist in Node.js. Should declare both node and bun engines.
  33. C6 Missing publishConfig.access for scoped package
  34. Files: package.json (root), packages/cli/package.json
  35. Both @nextsystems/oac and @nextsystems/oac-cli are scoped packages.
  36. Without "publishConfig": {"access": "public"}, npm publish fails or
  37. publishes as private. Users cannot install the package.
  38. IMPORTANT (fix before v1.0):
  39. I1 No oac clean command
  40. Files: packages/cli/src/commands/clean.ts (new), packages/cli/src/index.ts
  41. No way to remove .opencode/ and .oac/ after uninstalling the npm package.
  42. Plan includes full implementation with --force, --dry-run, --ide flags.
  43. I2 README missing npm install instructions
  44. File: README.md
  45. Quick Start shows only curl | bash. Zero mention of npm install -g,
  46. npx, or Bun as a prerequisite. npm is the primary install path.
  47. I3 No SIGINT/SIGTERM signal handlers
  48. File: packages/cli/src/index.ts
  49. Ctrl-C during a spinner operation leaves the terminal cursor hidden and
  50. color codes active. Two lines needed: process.on('SIGINT'/'SIGTERM').
  51. I4 No inline update notification
  52. Files: packages/cli/src/lib/update-check.ts (new), packages/cli/src/index.ts,
  53. packages/cli/src/commands/doctor.ts (refactor)
  54. fetchLatestNpmVersion() exists in doctor.ts but is private. Plan extracts
  55. it to a shared module, adds 24h caching in ~/.config/oac/, and calls it
  56. non-blocking after program.parseAsync() in index.ts.
  57. I5 writeManifest() missing mkdir
  58. File: packages/cli/src/lib/manifest.ts
  59. writeManifest() calls Bun.write() without ensuring .oac/ exists first.
  60. config.ts correctly calls mkdir() first. First oac init on a clean
  61. project will throw ENOENT. One-line fix: add mkdir(path.dirname(...)).
  62. I6 No examples in --help output
  63. Files: packages/cli/src/index.ts, packages/cli/src/commands/init.ts,
  64. packages/cli/src/commands/update.ts
  65. clig.dev standard: "lead with examples." addHelpText('after', ...) needed
  66. on the main program, init command, and update command.
  67. I7 packages/cli has conflicting bin field
  68. File: packages/cli/package.json
  69. "bin": {"oac": "./dist/index.js"} points to a Bun binary. If anyone
  70. installs @nextsystems/oac-cli directly, it fails under Node.js.
  71. The sub-package is not meant to be installed directly. Remove bin field.
  72. I8 Windows bun.cmd compatibility
  73. File: bin/oac.js
  74. execFileSync('bun', ...) fails on Windows where npm installs create
  75. bun.cmd wrappers. Fix: detect process.platform === 'win32' and use
  76. 'bun.cmd' as the executable name.
  77. MINOR (polish):
  78. M1 Version mismatch between root and CLI package
  79. Files: package.json (root), packages/cli/package.json,
  80. packages/cli/src/lib/version.ts
  81. Root is "0.7.1", CLI sub-package is "1.0.0". readCliVersion() reads
  82. from sub-package, so oac --version shows "1.0.0" but npm registry has
  83. "0.7.1". doctor version check is broken. Root package.json is canonical.
  84. M2 warn() writes to stdout instead of stderr
  85. File: packages/cli/src/ui/logger.ts
  86. warn() uses console.log (stdout). error() correctly uses console.error
  87. (stderr). Warnings pollute piped output. One-line fix: console.error.
  88. M3 Missing repository.directory in package.json files
  89. Files: package.json (root), packages/cli/package.json
  90. Neither file has repository.directory. npm package pages show wrong
  91. GitHub links. packages/cli/package.json has no repository field at all.
  92. RECOMMENDED FIX ORDER:
  93. 1. C6 — publishConfig (unblocks all publish attempts)
  94. 2. C1 — .npmignore (unblocks npm pack verification)
  95. 3. C2 — prepublishOnly (build guard)
  96. 4. C3+C4 — package root resolution (unblocks all users)
  97. 5. C5 — engines field
  98. 6. I5 — writeManifest mkdir (unblocks oac init on clean projects)
  99. 7. I7 — remove bin from sub-package
  100. 8. M2 — warn() stderr (trivial, do alongside I7)
  101. 9. M3 — repository.directory (trivial)
  102. 10. M1 — version sync
  103. 11. I3 — signal handlers
  104. 12. I8 — Windows bun.cmd
  105. 13. I1 — clean command
  106. 14. I4 — update notification
  107. 15. I6 — help examples
  108. 16. I2 — README npm install section (do last, after package is verified working)
  109. DISCREPANCIES FOUND vs. REVIEW DESCRIPTION:
  110. See "NOTES ON ACTUAL VS. DESCRIBED STATE" section below.
  111. NOTES ON ACTUAL VS. DESCRIBED STATE:
  112. 1. C3 description said "registry.json IS in the root package.json files array"
  113. — CONFIRMED. Line 30 of root package.json: "registry.json". The review
  114. description was accurate.
  115. 2. C4 description said "bin/oac.js knows exactly where it is (__dirname/..)"
  116. — CONFIRMED. bin/oac.js line 8: path.join(__dirname, '..', 'packages', 'cli', 'dist', 'index.js')
  117. so __dirname is the bin/ directory and __dirname/.. is the package root.
  118. 3. M1 description said root is "0.7.1" and CLI is "1.0.0" — CONFIRMED.
  119. Additionally: readCliVersion() in version.ts imports from '../../package.json'
  120. which resolves to packages/cli/package.json (not root). So oac --version
  121. returns "1.0.0" while the npm package is "0.7.1".
  122. 4. M2 description said "warn() uses console.log" — CONFIRMED. Line 28 of
  123. logger.ts: `export const warn = (msg: string): void => console.log(...)`.
  124. 5. I5 description said "config.ts correctly calls mkdir first" — CONFIRMED.
  125. config.ts line 48: `await mkdir(dirname(configPath), { recursive: true })`.
  126. manifest.ts writeManifest() has NO mkdir call.
  127. 6. I7 description said packages/cli has bin field — CONFIRMED. Lines 6-8 of
  128. packages/cli/package.json: "bin": {"oac": "./dist/index.js"}.
  129. 7. The review mentioned "import.meta.dir" in bundled.ts — CONFIRMED. Line 37:
  130. `return findPackageRoot(import.meta.dir)`. This is Bun-specific.
  131. 8. packages/cli/package.json already has "engines": {"bun": ">=1.0.0"} (lines
  132. 34-36). Only the ROOT package.json is missing the bun engine declaration.
  133. The review description was accurate.
  134. 9. index.ts has 7 commands registered (init, update, add, apply, doctor, list,
  135. status). The review's I1 plan correctly identifies that 'clean' is missing.
  136. 10. The README Quick Start section (lines 116-139) shows ONLY curl-based install.
  137. No npm install instructions anywhere in the first 140 lines. Review accurate.