Commit Graph

1 Commits (73fd5ceabd6fd1621742b0a169a9baced4a19ace)

Author SHA1 Message Date
Jason Stirnaman b204de8ffe
chore: improve docs-cli with unified flag syntax and YAML config (#6778)
* chore(instruction): Add content-editing skill documentation workflow
guide

* Phase 1: Add CLI configuration system

- Add config-loader.js with .env support and smart repo detection
- Add config/.env.example template (no real values)
- Add config/README.md with comprehensive configuration docs
- Configuration uses generic flags (DOCS_ENTERPRISE_ACCESS) not private repo names
- All .env files already gitignored via existing .gitignore pattern

Validation:
 Config loads and finds docs-v2 repo automatically
 Defaults work without .env file (hasEnterpriseAccess=false)
 .env files properly gitignored

* Phase 2: Migrate libraries with security fix and quick wins

**Shared Libraries Added:**
- content-utils.js - Shared content detection and management
- api-auditor.js - API documentation auditing (WITH SECURITY FIX)
- api-audit-reporter.js - API audit report generation
- api-parser.js - Parse API definitions from code
- api-request-parser.js - Parse API request/response specs
- api-doc-scanner.js - Scan documentation for API coverage
- telegraf-auditor.js - Telegraf plugin auditing
- telegraf-audit-reporter.js - Telegraf audit reports
- version-utils.js (NEW) - Version normalization utilities

**SECURITY FIX APPLIED:**
 Removed: hardcoded 'https://github.com/influxdata/influxdb_pro.git'
 Removed: directory name 'influxdb-pro-clone'
 Added: Uses process.env.INFLUXDB_PRO_REPO_URL from config
 Added: Clear error message if not configured
 Added: Generic directory name 'enterprise-clone'

**Quick Wins Added:**
1. Version normalization (version-utils.js)
   - Handles v3.9, 3.9, v3.9.0, 3.9.0 automatically
   - Suggests matching tags when version not found

2. Enhanced path discovery (config-loader.js)
   - Searches parent directories (up to 3 levels)
   - Finds sibling repositories automatically

3. Progress indicators (deferred to Phase 3)
   - Will add ora package with commands

Validation:
 grep shows NO 'influxdb_pro' or 'influxdb-pro' references
 api-auditor.js uses process.env.INFLUXDB_PRO_REPO_URL
 All library files import successfully

* Phase 3: Add new commands

**Commands Added:**
- audit.js - API and Telegraf documentation auditing
- release-notes.js - Generate release notes from git commits
- add-placeholders.js - Add placeholder syntax to code blocks (moved from scripts/)

**Changes:**
- Created scripts/docs-cli/commands/ directory
- Wrapped add-placeholders.js for CLI router compatibility
- Updated package.json: docs:add-placeholders script path
- Added CLI-MIGRATION-DESIGN.md documentation

**Command Structure:**
All commands export default async function for unified CLI router:
  export default async function commandName({ args, command }) { ... }

Validation:
 All three command files present in commands/
 add-placeholders.js has export wrapper
 package.json points to new location

* Phase 4: Update existing commands (create, edit)

**Commands Updated:**
- Moved docs-create.js → commands/create.js
- Moved docs-edit.js → commands/edit.js

**Changes:**
Both commands now:
- Located in commands/ directory for consistency
- Use unified CLI structure (export default async function)
- Maintain findDocsV2Root() for portability
- Can be called via router or directly

**Files Removed:**
- scripts/docs-cli/docs-create.js (moved to commands/)
- scripts/docs-cli/docs-edit.js (moved to commands/)

Validation:
 Old files removed
 New files in commands/ directory
 Git detected as rename (preserves history)
 Both have proper export wrappers for CLI router

* Phase 5: Update router with dynamic command loading

**Router Updated:**
- Replaced basic router with enhanced version from docs-tooling
- Dynamic command loading from ./commands/ directory
- Comprehensive help with all commands listed
- Better error handling with DEBUG mode support
- Version flag (--version) support

**Changes:**
- Updated help text for docs-v2 (was docs-tooling)
- Added add-placeholders command to help
- Fixed configuration path references
- Updated GitHub URL to docs-v2

**Features:**
- Handles --help, --version, unknown commands
- Shows usage on error
- DEBUG env var for stack traces
- Clean error messages for missing commands

Validation:
 docs --help shows all 5 commands
 Help text references correct paths
 Router loads commands dynamically
 Error handling works correctly

* Fix: Correct package.json path for --version flag

The router was looking in scripts/package.json instead of repo root.
Updated to go up two levels: docs-cli -> scripts -> repo root

Test: npx docs --version now works correctly

* feat: Enhance docs CLI with placeholders alias and update documentation

- Add command alias support to router (placeholders -> add-placeholders)
- Update docs-cli-workflow SKILL.md with all 5 CLI commands
- Update content-editing SKILL.md quick reference with new commands
- Create consolidated influxdb3-tech-writer agent for all v3 products
- Document tech-writer agent consolidation recommendation

* chore(claude): Consolidate tech-writer agents:

1. **influxdb3-tech-writer** (consolidated) - Handles ALL InfluxDB 3
products
   - InfluxDB 3 Core (self-hosted, open source)
   - InfluxDB 3 Enterprise (self-hosted, licensed)
   - InfluxDB 3 Cloud Dedicated (managed, dedicated)
   - InfluxDB 3 Cloud Serverless (managed, serverless)
   - InfluxDB 3 Clustered (Kubernetes)

2. **influxdb1-tech-writer** (unchanged) - Handles InfluxDB v1 legacy
products
   - InfluxDB v1 OSS
   - InfluxDB v1 Enterprise
   - Chronograf, Kapacitor

* fix: Fix CLI import paths and add npm run scripts

- Fix create.js imports: content-scaffolding, file-operations, url-parser
  now correctly reference ../../lib/ (scripts/lib/)
- Fix edit.js import: url-parser now references ../../lib/
- Fix create.js REPO_ROOT: change const to let for reassignment
- Update package.json with all docs:* npm scripts routing through unified CLI
- Improve error handling: distinguish unknown commands from runtime errors

* fix: Fix remaining dynamic import paths in create.js, add integration tests

- Fix dynamic imports in create.js (lines 487, 1286) using wrong paths
- Add cli-integration.test.js that catches import/module errors by
  actually executing commands, not just testing --help
- Tests verify commands load and run without ERR_MODULE_NOT_FOUND
- Update run-tests.sh to include integration tests

This would have caught the import path errors that broke 'docs create'.

* fix: Fix argument parsing for CLI router, improve integration tests

- create.js: Pass args from router to parseArgs() instead of re-reading
  process.argv (which includes 'create' as first positional)
- add-placeholders.js: Refactor to defer argument parsing to main()
  instead of parsing at module load time
- cli-integration.test.js: Stricter tests that check exit codes and
  error patterns, not just import errors
- Tests now verify commands actually execute successfully, catching
  runtime errors that --help tests would miss

* fix: Fix .tmp directory location and worktree detection

- findDocsV2Root(): Fix package.json name check (@influxdata/docs-site)
- findDocsV2Root(): Prioritize cwd walk-up over env var to find worktrees
- create.js: Change path constants to let for proper reassignment
- .tmp now correctly created in repo root, not scripts/docs-cli/

* chore(docs-cli): Handle piping in create command with helpful errors and
skips

* refactor(docs-cli): unify flag syntax and improve configuration

- Separate --products (product keys) from --repos (paths/URLs) in
  release-notes and audit commands
- Use consistent <positional> --flags syntax across commands
- Replace INFLUXDB_PRO with INFLUXDB_ENTERPRISE naming
- Move config from .env to YAML format (~/.influxdata-docs/docs-cli.yml)
- Output release notes to .tmp/release-notes/ (gitignored)
- Add integration tests for new flag syntax
- Update help text to reflect unified CLI usage

* chore: remove deprecated release-notes script and configs

- Remove helper-scripts/common/generate-release-notes.js (migrated to unified CLI)
- Remove orphaned config files (influxdb-v1.json, influxdb-v2.json, etc.)
- Update workflows to reference unified CLI (docs release-notes)
- Update helper-scripts READMEs to remove deprecated documentation

* feat(docs-cli): add path support to --products flag

Add a unified product-resolver module that accepts content paths
(e.g., /influxdb3/core) in addition to product keys (influxdb3_core)
for the --products flag across all docs CLI commands.

Changes:
- Add lib/product-resolver.js for path-to-key resolution
- Update audit command: remove positional args, use --products/--repos
- Update release-notes: add path support, enforce mutual exclusion
- Update create: add path support via resolveProducts()
- Update main CLI help text with new syntax examples
- Add 30 unit tests for product-resolver module
- Update integration tests for new audit syntax

BREAKING CHANGE: audit command no longer accepts positional arguments.
Use `docs audit --products influxdb3_core` instead of `docs audit core`.

* Update skills and commands for new docs CLI syntax

- Update content-editing skill with new --products flag syntax
  - Document path-to-key resolution (e.g., /influxdb3/core -> influxdb3_core)
  - Update Quick Reference table with correct command examples

- Update docs-cli-workflow skill
  - Add examples showing both product keys and content paths
  - Document mutual exclusion between --products and --repos
  - Update audit command syntax (removed positional arguments)

- Replace enhance-release-notes.md with prepare-release-notes.md
  - New command documents docs release-notes CLI usage
  - Includes examples with --products and --repos flags

* feat(github): add Copilot instructions management and DRY refactor

- Add copilot-instructions-agent.md for creating/managing Copilot instructions
- DRY refactor of copilot-instructions.md (485→240 lines, 50% reduction)
- Update all pattern-specific instructions to reference Claude skills
- Add comprehensive cross-references between Copilot and Claude resources
- Document unified docs CLI with non-blocking defaults
- Add COPILOT-INSTRUCTIONS-UPDATE.md summary document

Key improvements:
- Single source of truth (Claude skills) with focused Copilot summaries
- Concise, scannable instructions with links to detailed resources
- Consistent structure across all instruction files
- Better guidance on when to use CLI tools vs direct editing

* refactor(docs-cli): fix unused code and env var naming

Address PR feedback from Copilot code review:

- Rename INFLUXDB_ENTERPRISE_REPO_URL to INFLUXDB3_ENTERPRISE_REPO_URL
  for consistency with InfluxDB 3 naming conventions
- Fix misleading error message to point to correct config location
- Remove unused detectEnterpriseEndpoints import from api-auditor.js
- Remove unused endpointParams variable from api-auditor.js
- Remove unused auditType variable in audit.js loop
- Remove unused assertDeepEquals function from product-resolver tests
2026-02-04 16:44:35 -06:00