@git.zone/tsdoc

Documentation for @git.zone/tsdoc

readme.md for @git.zone/tsdoc

AI-Powered Documentation & Commit Intelligence for TypeScript Projects 🚀

Issue Reporting and Security

For reporting bugs, issues, or security vulnerabilities, please visit community.foss.global/. This is the central community hub for all issue reporting. Developers who sign and comply with our contribution agreement and go through identification can also get a code.foss.global/ account to submit Pull Requests directly.

Install

# Global installation (recommended for CLI usage)
pnpm add -g @git.zone/tsdoc

# Or use with npx (no install needed)
npx @git.zone/tsdoc

# Or install locally as a project dependency
pnpm add @git.zone/tsdoc

Usage

@git.zone/tsdoc is a TypeScript documentation powerhouse that combines traditional TypeDoc API docs with AI-powered documentation workflows. It uses OpenAI models via @push.rocks/smartai and autonomous agents via @push.rocks/smartagent to generate READMEs, project descriptions, keywords, and semantic commit messages — all by intelligently exploring your project's codebase with scoped filesystem tools.

CLI Commands

Command Description
tsdoc 🔍 Auto-detects project type and runs TypeDoc
tsdoc aidoc 🤖 Generates AI-powered README + description/keywords
tsdoc readme 📝 Generates AI-powered README only
tsdoc description 🏷️ Generates AI-powered description and keywords only
tsdoc commit 💬 Generates a semantic commit message from uncommitted changes
tsdoc typedoc 📚 Generates traditional TypeDoc API documentation

🤖 AI-Powered Documentation (aidoc)

The aidoc command is the all-in-one workflow that combines README generation and description/keyword generation:

# In your project root
tsdoc aidoc

This will:

  1. Spin up an AI agent with read-only filesystem access scoped to your project
  2. The agent autonomously explores your project structure, reads source files, and understands the API
  3. Generate a comprehensive readme.md with install instructions, usage examples, and architecture overview
  4. Update package.json and .smartconfig.json with an AI-generated description and keywords

You can also run these steps individually:

# Generate only the README
tsdoc readme

# Generate only the description and keywords
tsdoc description

💬 Smart Commit Messages (commit)

The commit command analyzes your uncommitted changes and produces a structured commit object following Conventional Commits:

tsdoc commit

Output is a JSON object:

{
  "recommendedNextVersionLevel": "feat",
  "recommendedNextVersionScope": "core",
  "recommendedNextVersionMessage": "add smart diff processing for large changesets",
  "recommendedNextVersionDetails": [
    "implemented intelligent diff sampling with head/tail extraction",
    "added file prioritization by importance score"
  ],
  "recommendedNextVersion": "1.13.0",
  "changelog": "# Changelog\n\n## 2026-03-24 - 1.13.0 - core\n..."
}

Under the hood, the commit flow:

📚 TypeDoc Generation (typedoc)

For traditional API documentation:

# Generate to default ./public directory
tsdoc typedoc

# Generate to a specific subdirectory
tsdoc typedoc --publicSubdir docs

TypeDoc generation auto-detects your source directories (ts/ and ts_web/) and creates a temporary tsconfig for compilation.

🏗️ Monorepo Support

When generating READMEs, tsdoc automatically detects monorepo submodules via @git.zone/tspublish conventions. Each submodule directory containing a tspublish.json gets its own generated README with the legal section appended.

Programmatic API

You can use tsdoc programmatically in your own tools:

import { AiDoc } from '@git.zone/tsdoc';

const aidoc = new AiDoc();

// Initialize — prompts for OpenAI token on first run, then persists it
await aidoc.start();

// Generate a comprehensive README for a project
const readmeContent = await aidoc.buildReadme('/path/to/project');

// Generate description and keywords, updating package.json and .smartconfig.json
await aidoc.buildDescription('/path/to/project');

// Generate a structured commit message object from uncommitted changes
const commitObj = await aidoc.buildNextCommitObject('/path/to/project');
console.log(commitObj.recommendedNextVersionLevel); // 'fix' | 'feat' | 'BREAKING CHANGE'
console.log(commitObj.recommendedNextVersionMessage);
console.log(commitObj.changelog);

// Get gathered project files (package.json, source files, tests, config)
const context = await aidoc.getProjectContext('/path/to/project');

// Get token count for a project's context
const tokenCount = await aidoc.getProjectContextTokenCount('/path/to/project');

// Estimate tokens in arbitrary text
const tokens = aidoc.countTokens('some text here');

await aidoc.stop();

You can also pass the OpenAI token directly via the constructor:

const aidoc = new AiDoc({ OPENAI_TOKEN: 'sk-...' });
await aidoc.start();

Configuration

OpenAI Token

An OpenAI API key is required for all AI features. It can be provided in three ways (checked in order):

  1. Environment variable: Set OPENAI_TOKEN in your environment or .env file
  2. Constructor argument: Pass { OPENAI_TOKEN: 'sk-...' } to new AiDoc()
  3. Interactive prompt: On first run, tsdoc will prompt for the token and persist it

The token is persisted at ~/.smartconfig/kv/@git.zone/tsdoc.json for subsequent runs.

.smartconfig.json

tsdoc uses .smartconfig.json for project metadata. The tsdoc key holds legal information that gets appended to generated READMEs:

{
  "tsdoc": {
    "legal": "\n## License and Legal Information\n\n..."
  },
  "gitzone": {
    "module": {
      "githost": "gitlab.com",
      "gitscope": "gitzone",
      "gitrepo": "tsdoc",
      "npmPackagename": "@git.zone/tsdoc",
      "description": "...",
      "keywords": ["..."]
    }
  }
}

The description command writes updated description/keywords to both gitzone.module in .smartconfig.json and to package.json.

Architecture

Core Components

@git.zone/tsdoc
├── AiDoc                 # Main orchestrator — manages AI model, delegates to task classes
├── TypeDoc               # Traditional TypeDoc API documentation generation
├── ProjectContext        # Gathers project files (package.json, source, tests, config)
├── DiffProcessor         # Intelligent git diff processing with prioritization & sampling
├── Readme                # AI agent-driven README generation with filesystem tools
├── Commit                # AI agent-driven commit message generation with diff analysis
├── Description           # AI agent-driven description and keyword generation
└── CLI                   # Command-line interface built on @push.rocks/smartcli

🧠 AI Agent Architecture

Each documentation task (readme, commit, description) runs an autonomous AI agent via @push.rocks/smartagent's runAgent():

  1. System prompt defines the agent's role, constraints, and output format
  2. Filesystem tools give the agent scoped, read-only access to the project directory
  3. Autonomous exploration — the agent decides which files to read, in what order
  4. Structured output — README markdown, commit JSON, or description JSON

The agents use @push.rocks/smartai's getModel() to create a language model instance backed by OpenAI.

⚡ Diff Processing Pipeline

The DiffProcessor handles large git diffs without blowing up token budgets:

File Category Threshold Treatment
Small < 300 lines changed Included in full
Medium < 800 lines changed Head (75 lines) + tail (75 lines) sampling
Large ≥ 800 lines changed Metadata only (filepath + stats)

Files are scored by importance:

Token budget is calculated dynamically: context_limit - safety_margin - overhead - prompt_size.

Requirements

This repository contains open-source code licensed under the MIT License. A copy of the license can be found in the LICENSE file.

Please note: The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.

Trademarks

This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH or third parties, and are not included within the scope of the MIT license granted herein.

Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines or the guidelines of the respective third-party owners, and any usage must be approved in writing. Third-party trademarks used herein are the property of their respective owners and used only in a descriptive manner, e.g. for an implementation of an API or similar.

Company Information

Task Venture Capital GmbH Registered at District Court Bremen HRB 35230 HB, Germany

By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.

changelog.md for @git.zone/tsdoc

2026-03-24 - 2.0.2 - fix(smartconfig)

migrate project metadata and config handling to .smartconfig.json

2026-03-24 - 2.0.1 - fix(aidocs, config)

migrate aidocs configuration handling from npmextra to smartconfig

2026-03-11 - 2.0.0 - BREAKING CHANGE(aidoc)

migrate agent orchestration to new runAgent API and filesystem tools; refactor model handling and update README and tests

2026-01-04 - 1.12.0 - feat(commit)

add token budgeting and dynamic diff token calculation to avoid OpenAI context limit issues

2025-12-16 - 1.11.4 - fix(aidocs_classes)

clarify recommendedNextVersionMessage field to require only the description body without the type(scope) prefix

2025-12-15 - 1.11.0 - feat(commit)

Integrate DualAgentOrchestrator for commit message generation and improve diff/context handling

2025-12-02 - 1.10.0 - feat(diff-processor)

Improve diff sampling and file prioritization: increase inclusion thresholds, expand sampled context, and boost priority for interface/type and entry-point files

2025-11-04 - 1.9.2 - fix(deps)

Update dependencies and devDependencies to newer versions (bump multiple packages)

2025-11-04 - 1.9.1 - fix(iterative-context-builder)

Rely on DiffProcessor for git diff pre-processing; remove raw char truncation, raise diff token safety, and improve logging

2025-11-04 - 1.9.0 - feat(context)

Add intelligent DiffProcessor to summarize and prioritize git diffs and integrate it into the commit context pipeline

2025-11-04 - 1.8.3 - fix(context)

Prevent enormous git diffs and OOM during context building by adding exclusion patterns, truncation, and diagnostic logging

2025-11-03 - 1.8.0 - feat(context)

Wire OpenAI provider through task context factory and add git-diff support to iterative context builder

2025-11-03 - 1.7.0 - feat(IterativeContextBuilder)

Add iterative AI-driven context builder and integrate into task factory; add tests and iterative configuration

2025-11-03 - 1.6.1 - fix(context)

Improve context building, caching and test robustness

2025-11-02 - 1.6.0 - feat(context)

Introduce smart context system: analyzer, lazy loader, cache and README/docs improvements

2025-09-07 - 1.5.2 - fix(package)

Bump dependencies, refine test script and imports, and overhaul README and docs

2025-08-16 - 1.5.1 - fix(aidoc)

Bump dependencies, add pnpm workspace config, and add AiDoc.stop()

2025-05-14 - 1.5.0 - feat(docs)

Update project metadata and documentation to reflect comprehensive AI-enhanced features and improved installation and usage instructions

2025-05-13 - 1.4.5 - fix(dependencies)

Upgrade various dependency versions and update package manager configuration

2025-02-25 - 1.4.4 - fix(dependencies)

Update dependencies to latest versions

2025-01-14 - 1.4.3 - fix(aidocs_classes)

Improve readme generation instructions to ensure correct markdown formatting.

2024-10-28 - 1.4.2 - fix(cli)

Ensure async completion for aidoc readme and description generation

2024-10-28 - 1.4.1 - fix(readme)

Correct async call to getModuleSubDirs in readme generation.

2024-10-28 - 1.4.0 - feat(aidocs)

Added support for building readmes for sub-modules in aidocs

2024-06-24 - 1.3.12 - fix(aidocs)

Fix changelog generation by handling leading newlines

2024-06-23 - 1.3.11 - fix(core)

Fixed new changelog formatting issue to retain consistent spacing.

2024-06-23 - 1.3.10 - fix(aidocs_classes)

Fix changelog format to remove extra newline

2024-06-23 - 1.3.9 - fix(aidoc)

Fix changelog generation by properly stripping markdown code fences

2024-06-23 - 1.3.8 - fix(changelog)

Fix changelog generation by properly stripping markdown code fences

2024-06-23 - 1.3.7 - fix(aidoc)

Update to include package-lock.json in uncommitted changes check

2024-06-23 - 1.3.6 - fix(commit)

Fixed issue with retrieving uncommitted diffs in git repository

2024-06-23 - 1.3.5 - fix(aidocs_classes)

Refactor and enhance changelog formatting

## 2024-06-23 - 1.3.3 - fix(aidocs_classes)
Fix changelog formatting issue in commit class

## 2024-06-23 - 1.3.2 - fix(aidocs_classes)
Fix minor bugs and update dependencies in aidocs_classes

## 2024-06-23 - 1.3.1 - fix(aidocs_classes)
Fix typo in INextCommitObject interface and update date format in changelog generation.

## 2024-06-23 - 1.3.0 - fix(aidocs_classes)
Fix typo in INextCommitObject interface

## 2024-06-23 - 1.2.4 - feat(core)
Added smarttime dependency and improved changelog generation

## 2024-06-23 - 1.2.3 - fix(logging)
Refactor logger initialization to use commitinfo data

## 2024-06-23 - 1.2.2 - fix(aidocs)
Fix bug in AiDoc class causing undefined token handling

## 2024-06-23 - 1.2.0 - fix(core)
Fixed usage of plugins in project context and readme generation

## 2024-06-23 - 1.1.42 - feat(aidocs_classes)
Enhance changelog generation by supporting complete generation in the absence of previous changelog files

## 2024-06-23 - 1.1.41 - fix(aidocs_classes)
Improve commit message generation by handling empty diffs and updating changelog instructions