harness-auto-docs 0.1.0

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 (67) hide show
  1. package/.nvmrc +1 -0
  2. package/AGENTS.md +69 -0
  3. package/ARCHITECTURE.md +123 -0
  4. package/README.md +52 -0
  5. package/dist/ai/anthropic.d.ts +7 -0
  6. package/dist/ai/anthropic.js +20 -0
  7. package/dist/ai/interface.d.ts +3 -0
  8. package/dist/ai/interface.js +1 -0
  9. package/dist/ai/minimax.d.ts +7 -0
  10. package/dist/ai/minimax.js +21 -0
  11. package/dist/ai/openai.d.ts +7 -0
  12. package/dist/ai/openai.js +16 -0
  13. package/dist/cli.d.ts +2 -0
  14. package/dist/cli.js +103 -0
  15. package/dist/core/diff.d.ts +17 -0
  16. package/dist/core/diff.js +46 -0
  17. package/dist/core/generator.d.ts +10 -0
  18. package/dist/core/generator.js +238 -0
  19. package/dist/core/relevance.d.ts +3 -0
  20. package/dist/core/relevance.js +29 -0
  21. package/dist/core/writer.d.ts +2 -0
  22. package/dist/core/writer.js +23 -0
  23. package/dist/providers/github.d.ts +13 -0
  24. package/dist/providers/github.js +43 -0
  25. package/dist/providers/gitlab.d.ts +9 -0
  26. package/dist/providers/gitlab.js +6 -0
  27. package/dist/providers/interface.d.ts +8 -0
  28. package/dist/providers/interface.js +1 -0
  29. package/docs/DESIGN.md +94 -0
  30. package/docs/QUALITY_SCORE.md +74 -0
  31. package/docs/design-docs/core-beliefs.md +71 -0
  32. package/docs/design-docs/index.md +32 -0
  33. package/docs/exec-plans/tech-debt-tracker.md +26 -0
  34. package/docs/product-specs/index.md +39 -0
  35. package/docs/references/anthropic-sdk-llms.txt +40 -0
  36. package/docs/references/octokit-rest-llms.txt +44 -0
  37. package/docs/references/openai-sdk-llms.txt +38 -0
  38. package/docs/superpowers/plans/2026-04-03-harness-engineering-auto-docs.md +1863 -0
  39. package/docs/superpowers/specs/2026-04-03-harness-engineering-auto-docs-design.md +169 -0
  40. package/examples/github-workflow.yml +32 -0
  41. package/markdown/harness-engineering-codex-agent-first-world.md +215 -0
  42. package/package.json +30 -0
  43. package/src/ai/anthropic.ts +23 -0
  44. package/src/ai/interface.ts +3 -0
  45. package/src/ai/minimax.ts +25 -0
  46. package/src/ai/openai.ts +20 -0
  47. package/src/cli.ts +122 -0
  48. package/src/core/diff.ts +77 -0
  49. package/src/core/generator.ts +294 -0
  50. package/src/core/relevance.ts +53 -0
  51. package/src/core/writer.ts +25 -0
  52. package/src/providers/github.ts +53 -0
  53. package/src/providers/gitlab.ts +16 -0
  54. package/src/providers/interface.ts +9 -0
  55. package/tests/core/anthropic.test.ts +33 -0
  56. package/tests/core/diff.test.ts +49 -0
  57. package/tests/core/generator.test.ts +93 -0
  58. package/tests/core/openai.test.ts +38 -0
  59. package/tests/core/relevance.test.ts +62 -0
  60. package/tests/core/writer.test.ts +56 -0
  61. package/tests/fixtures/diff-frontend.txt +11 -0
  62. package/tests/fixtures/diff-schema.txt +12 -0
  63. package/tests/fixtures/diff-small.txt +16 -0
  64. package/tests/integration/generate.test.ts +49 -0
  65. package/tests/providers/github.test.ts +69 -0
  66. package/tsconfig.json +15 -0
  67. package/vitest.config.ts +7 -0
@@ -0,0 +1,26 @@
1
+ # Tech Debt Tracker
2
+
3
+ Tracks known technical debt in `harness-engineering-auto-docs`.
4
+ Updated automatically on each release. See `docs/QUALITY_SCORE.md` for graded gap tracking.
5
+
6
+ ---
7
+
8
+ ## Baseline (v0.1.0 — 2026-04-03)
9
+
10
+ ### Active debt
11
+
12
+ | ID | Area | Description | Priority | Notes |
13
+ |----|------|-------------|----------|-------|
14
+ | TD-001 | Platform | GitLab MR support not implemented | Medium | `src/providers/gitlab.ts` throws on any call; placeholder only |
15
+ | TD-002 | CLI | Git operations in `cli.ts` use bare `execSync` with no error recovery | Low | A failed push leaves the branch dangling; no cleanup logic |
16
+ | TD-003 | Generator | Prompts are hardcoded strings with no versioning or regression testing | Low | Prompt quality can degrade silently across model updates |
17
+ | TD-004 | Providers | `owner/repo` parsing from git remote URL is fragile | Low | Breaks on SSH remotes (`git@github.com:…`) and non-GitHub hosts |
18
+ | TD-005 | Generator | Diff truncation at 8 000 chars may slice mid-hunk | Low | Large releases may produce incomplete context for the LLM |
19
+
20
+ ### Resolved debt
21
+
22
+ _None yet — first baseline._
23
+
24
+ ---
25
+
26
+ <!-- harness-engineering-auto-docs appends sections here on each release -->
@@ -0,0 +1,39 @@
1
+ # Product Specs Index
2
+
3
+ Feature specifications for `harness-engineering-auto-docs`.
4
+ Each entry links to a spec document for a significant feature addition.
5
+
6
+ <!-- harness-engineering-auto-docs appends entries here when new features are detected in a release -->
7
+
8
+ ## Shipped features
9
+
10
+ ### Auto-documentation pipeline (v0.1.0)
11
+
12
+ **What it does**: On every `git tag` push, diffs the last two tags, classifies changed files,
13
+ selects relevant documentation targets, calls an LLM to generate content, writes Markdown files,
14
+ and opens a GitHub PR with the updates.
15
+
16
+ **Trigger**: `git tag v*` → GitHub Actions workflow → `npx harness-engineering-auto-docs`
17
+
18
+ **Inputs**: `AI_MODEL`, `AI_API_KEY`, `GITHUB_TOKEN` (environment variables)
19
+
20
+ **Outputs**: Updated Markdown files in target repository + open GitHub PR
21
+
22
+ **Supported AI models**: `claude-sonnet-4-6`, `claude-opus-4-6`, `claude-haiku-4-5-20251001`,
23
+ `gpt-4o`, `gpt-4o-mini`, `o3`
24
+
25
+ **Supported platforms**: GitHub (via Octokit). GitLab is a stub.
26
+
27
+ ### Conditional documentation routing (v0.1.0)
28
+
29
+ **What it does**: Only generates documentation for domains that have actual changes.
30
+ Frontend docs only when frontend files changed; security docs only when auth files changed, etc.
31
+
32
+ **Routing heuristics**: Defined in `src/core/diff.ts:groupFiles` and `src/core/relevance.ts:selectTargets`.
33
+
34
+ **Core targets** (always generated): `AGENTS.md`, `ARCHITECTURE.md`, `docs/DESIGN.md`,
35
+ `docs/QUALITY_SCORE.md`, `changelog/vX.Y.Z.md`, `docs/design-docs/vX.Y.Z.md`, design-doc-index,
36
+ tech-debt-tracker.
37
+
38
+ **Conditional targets**: `docs/FRONTEND.md`, `docs/SECURITY.md`, `docs/RELIABILITY.md`, `db-schema`,
39
+ `product-specs-index`, `references`.
@@ -0,0 +1,40 @@
1
+ # @anthropic-ai/sdk
2
+
3
+ ## What it is
4
+
5
+ `@anthropic-ai/sdk` is the official Anthropic TypeScript SDK for calling Claude models via
6
+ the Anthropic Messages API.
7
+
8
+ ## How it is used in this codebase
9
+
10
+ Used in `src/ai/anthropic.ts` to implement the `AIProvider` interface.
11
+
12
+ ```typescript
13
+ import Anthropic from '@anthropic-ai/sdk';
14
+
15
+ const client = new Anthropic({ apiKey });
16
+ const message = await client.messages.create({
17
+ model,
18
+ max_tokens: 4096,
19
+ messages: [{ role: 'user', content: prompt }],
20
+ });
21
+ ```
22
+
23
+ The response content is extracted from `message.content[0]` (type `'text'`).
24
+
25
+ ## Model names used in this codebase
26
+
27
+ - `claude-sonnet-4-6` — default recommended model (good balance of quality and speed)
28
+ - `claude-opus-4-6` — highest quality, slower and more expensive
29
+ - `claude-haiku-4-5-20251001` — fastest and cheapest
30
+
31
+ Model is selected by the `AI_MODEL` environment variable. The prefix `claude-` routes to
32
+ this provider (see `src/cli.ts:selectAI`).
33
+
34
+ ## Key constraints
35
+
36
+ - `max_tokens` is hardcoded to `4096` — sufficient for the 2–4 paragraph documentation
37
+ sections this tool generates
38
+ - Single-turn only — no conversation history is maintained between doc targets
39
+ - Each doc target generates an independent `messages.create` call (via `Promise.all` in
40
+ `src/core/generator.ts:generateDocs`)
@@ -0,0 +1,44 @@
1
+ # @octokit/rest
2
+
3
+ ## What it is
4
+
5
+ `@octokit/rest` is the official GitHub REST API client for Node.js maintained by the Octokit
6
+ organization. It wraps the GitHub REST API with typed methods, automatic pagination, and
7
+ authentication handling.
8
+
9
+ ## How it is used in this codebase
10
+
11
+ Used exclusively in `src/providers/github.ts` to:
12
+
13
+ 1. List existing pull requests on the target branch:
14
+ ```typescript
15
+ octokit.pulls.list({ owner, repo, head: `${owner}:${branch}` })
16
+ ```
17
+
18
+ 2. Update an existing PR if one already targets the same branch:
19
+ ```typescript
20
+ octokit.pulls.update({ owner, repo, pull_number, title, body })
21
+ ```
22
+
23
+ 3. Create a new PR when none exists:
24
+ ```typescript
25
+ octokit.pulls.create({ owner, repo, head: branch, base: baseBranch, title, body })
26
+ ```
27
+
28
+ ## Authentication
29
+
30
+ Instantiated with a GitHub token:
31
+ ```typescript
32
+ import { Octokit } from '@octokit/rest';
33
+ const octokit = new Octokit({ auth: token });
34
+ ```
35
+
36
+ The token is provided via `GITHUB_TOKEN` environment variable — either a GitHub Actions token
37
+ or a personal access token with `repo` scope.
38
+
39
+ ## Key constraints in this codebase
40
+
41
+ - `owner` and `repo` are parsed from `git remote get-url origin` output in `github.ts`
42
+ - The parser handles HTTPS remotes (`https://github.com/owner/repo.git`) but not SSH remotes —
43
+ this is tracked as TD-004 in `docs/exec-plans/tech-debt-tracker.md`
44
+ - All Octokit calls are awaited directly; no retry logic is implemented
@@ -0,0 +1,38 @@
1
+ # openai
2
+
3
+ ## What it is
4
+
5
+ `openai` is the official OpenAI Node.js / TypeScript SDK for calling GPT and other OpenAI
6
+ models via the Chat Completions API.
7
+
8
+ ## How it is used in this codebase
9
+
10
+ Used in `src/ai/openai.ts` to implement the `AIProvider` interface.
11
+
12
+ ```typescript
13
+ import OpenAI from 'openai';
14
+
15
+ const client = new OpenAI({ apiKey });
16
+ const completion = await client.chat.completions.create({
17
+ model,
18
+ messages: [{ role: 'user', content: prompt }],
19
+ });
20
+ ```
21
+
22
+ The response text is extracted from `completion.choices[0].message.content`.
23
+
24
+ ## Model names used in this codebase
25
+
26
+ - `gpt-4o` — recommended GPT model (strong reasoning, good documentation quality)
27
+ - `gpt-4o-mini` — faster and cheaper; suitable for simpler doc targets
28
+ - `o3` — most capable; use for complex architectural documentation
29
+
30
+ Model is selected by the `AI_MODEL` environment variable. The prefix `gpt-` routes to
31
+ this provider (see `src/cli.ts:selectAI`).
32
+
33
+ ## Key constraints
34
+
35
+ - No `max_tokens` override — relies on model default (sufficient for 2–4 paragraph outputs)
36
+ - Single-turn only — no conversation history maintained
37
+ - Each doc target is an independent `chat.completions.create` call (via `Promise.all` in
38
+ `src/core/generator.ts:generateDocs`)