Skip to content

feat(grounding): add ts-autocode-grounding package upstreamed from HoBo - #24

Merged
Tyler-R-Kendrick merged 3 commits into
mainfrom
claude/hobo-ts-autocode-integration-0ys9yx
Jul 26, 2026
Merged

feat(grounding): add ts-autocode-grounding package upstreamed from HoBo#24
Tyler-R-Kendrick merged 3 commits into
mainfrom
claude/hobo-ts-autocode-integration-0ys9yx

Conversation

@Tyler-R-Kendrick

@Tyler-R-Kendrick Tyler-R-Kendrick commented Jul 26, 2026

Copy link
Copy Markdown
Owner

Summary

Upstreams HoBo's reusable TypeScript-codegen layer into a new provider-neutral package, ts-autocode-grounding (packages/grounding), respecting the sibling-isolation rule (no imports of root or sibling packages):

  • src/decorators.ts — granular grounding decorators @intent, @returns, @description, plus param() and composition helpers (composeOptions, granularOptionsFor, granularLegacyOptions). Dual-mode dispatch (TC39 stage-3 and legacy experimentalDecorators call shapes).
  • src/component.ts — class-level finalization (finalizeTrainableClass) against a host-provided GroundingRegistry, and component-metadata composition (createComponentDecorator, componentMetadataOf) parameterized by metadata symbols so any host runtime can wire its own.
  • src/scan.ts — AST-based scanner (scanDeclaredTrainables) for ambient @trainable declare class declarations — replaces downstream regex parsing — plus generateDeclaredRegistrations with configurable header/runtime-module emission.
  • src/text.ts — deterministic text helpers (stableStringify, normalizeText, digest, pascalCase, camelCase, union) pinned by golden tests so downstream byte-for-byte digest parity holds.

Also adds an exported flag to TrainableTarget in ts-autocode-training so consumers can filter directive-marked free functions to exported ones (additive; free-function export modifier detection, always false for class methods).

Root wiring: ts-autocode/grounding subpath export, build:grounding first in the ordered build, typecheck + vitest coverage.

Test plan

  • npm run check — typecheck all five projects, vitest (20 files / 112 tests, including new packages/grounding/test/ suites for decorators, scanning/emission, and golden text values), ordered build.

Generated by Claude Code

Summary by CodeRabbit

  • New Features

    • Added grounding APIs for decorating operations with intents, parameter details, and return descriptions.
    • Added automatic discovery and registration of trainable components and operations.
    • Added source scanning and registration code generation for declared trainables.
    • Added deterministic text, path, hashing, casing, and union-formatting utilities.
    • Added a new grounding package entry point.
  • Tests

    • Added coverage for grounding decorators, source scanning, registration generation, and text utilities.

…discovery

Add a provider-neutral grounding package upstreamed from HoBo's training
layer: @intent/@returns/@description/param decorators with dual stage-3/
legacy dispatch, class finalization against a host-provided registry,
component metadata composition, an AST-based scanner for ambient
@trainable class declarations (replacing downstream regex parsing), a
registration-source emitter with configurable header/runtime module, and
deterministic text helpers (stableStringify, digest, pascalCase, union)
pinned by golden tests.

Also record an `exported` flag on TrainableTarget so consumers can
filter directive-marked free functions to exported ones.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CgjCQ7r2tJH89PqZDU1DrV
@coderabbitai

coderabbitai Bot commented Jul 26, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@Tyler-R-Kendrick, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 34 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 11936bd0-5873-4b15-b260-1ea004ea0a76

📥 Commits

Reviewing files that changed from the base of the PR and between 6030a75 and a1ec28c.

📒 Files selected for processing (6)
  • packages/grounding/src/component.ts
  • packages/grounding/src/decorators.ts
  • packages/grounding/src/index.ts
  • packages/grounding/src/scan.ts
  • packages/grounding/test/decorators.test.ts
  • packages/grounding/test/scan.test.ts
📝 Walkthrough

Walkthrough

Adds a new ts-autocode-grounding package with decorator metadata, component registration, TypeScript declaration scanning, deterministic text utilities, public exports, build integration, and tests. Training targets now record whether their declarations are exported.

Changes

Grounding package

Layer / File(s) Summary
Package integration and public exports
packages/grounding/package.json, packages/grounding/tsconfig*.json, packages/grounding/src/index.ts, src/grounding.ts, package.json, packages/training/src/source.ts, vitest.config.ts
Adds the package manifest, build/test configuration, public exports, root subpath wiring, dependency/build integration, test discovery, and TrainableTarget.exported.
Decorator metadata and component registration
packages/grounding/src/decorators.ts, packages/grounding/src/component.ts, packages/grounding/test/decorators.test.ts
Adds stage-3 and legacy grounding decorators, pending metadata composition, component metadata, class finalization, registry registration, and corresponding tests.
Declaration scanning and registration code generation
packages/grounding/src/scan.ts, packages/grounding/src/text.ts, packages/grounding/test/scan.test.ts, packages/grounding/test/text.test.ts
Scans decorated TypeScript declarations, emits training.define source, provides deterministic serialization and text helpers, and tests scanning, generation, and normalization behavior.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant TypeScriptSource
  participant scanDeclaredTrainables
  participant generateDeclaredRegistrations
  participant training.define
  TypeScriptSource->>scanDeclaredTrainables: decorated class source
  scanDeclaredTrainables->>generateDeclaredRegistrations: declared operations and contracts
  generateDeclaredRegistrations->>training.define: generated registration source
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 47.22% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: adding the new ts-autocode-grounding package upstreamed from HoBo.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/hobo-ts-autocode-integration-0ys9yx

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (1)
packages/grounding/tsconfig.test.json (1)

4-6: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

"outDir": null is unnecessary with noEmit: true.

Since noEmit already suppresses all emission, outDir has no effect here; TypeScript tooling may still flag null as a type mismatch (expects a string) in editors. Consider just omitting the key instead.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/grounding/tsconfig.test.json` around lines 4 - 6, Remove the
unnecessary outDir setting from the test TypeScript configuration, leaving
noEmit enabled to suppress output. Preserve the existing rootDir and other
compiler options.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/grounding/src/decorators.ts`:
- Around line 126-155: Update the `description` function’s
`Object.defineProperty` calls for `description` and `example` to define both
properties as enumerable, preserving the existing conditional creation of
`example` so spread, serialization, and `Object.keys` expose the
FieldDescription values.

In `@packages/grounding/src/scan.ts`:
- Around line 88-113: Update scanOperations to validate each method name before
pushing a DeclaredOperation: throw a clear error when memberName yields a
non-identifier or when the name has already been seen in the class, including
the offending method name in the message. Track names locally within
scanOperations, while preserving normal operation collection for unique valid
identifiers.

In `@packages/grounding/src/text.ts`:
- Around line 45-48: Update the text normalization chain in the visible
formatting function to convert standalone carriage returns to line feeds as well
as CRLF sequences. Ensure all line endings are normalized to LF before trailing
whitespace cleanup and the final newline are applied, preserving digest parity.

---

Nitpick comments:
In `@packages/grounding/tsconfig.test.json`:
- Around line 4-6: Remove the unnecessary outDir setting from the test
TypeScript configuration, leaving noEmit enabled to suppress output. Preserve
the existing rootDir and other compiler options.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 9cd0dda9-a073-493b-9412-93927b0957a0

📥 Commits

Reviewing files that changed from the base of the PR and between 94093ed and 6030a75.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (15)
  • package.json
  • packages/grounding/package.json
  • packages/grounding/src/component.ts
  • packages/grounding/src/decorators.ts
  • packages/grounding/src/index.ts
  • packages/grounding/src/scan.ts
  • packages/grounding/src/text.ts
  • packages/grounding/test/decorators.test.ts
  • packages/grounding/test/scan.test.ts
  • packages/grounding/test/text.test.ts
  • packages/grounding/tsconfig.json
  • packages/grounding/tsconfig.test.json
  • packages/training/src/source.ts
  • src/grounding.ts
  • vitest.config.ts

Comment thread packages/grounding/src/decorators.ts Outdated
Comment thread packages/grounding/src/scan.ts
Comment on lines +45 to +48
return `${value
.replace(/\r\n/g, "\n")
.replace(/[ \t]+$/gm, "")
.replace(/\s+$/u, "")}\n`;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Normalize lone CR line endings too.

Line 46 handles CRLF but preserves standalone \r, so LF-only output and digest parity are not guaranteed.

Proposed fix
-		.replace(/\r\n/g, "\n")
+		.replace(/\r\n?/g, "\n")
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
return `${value
.replace(/\r\n/g, "\n")
.replace(/[ \t]+$/gm, "")
.replace(/\s+$/u, "")}\n`;
return `${value
.replace(/\r\n?/g, "\n")
.replace(/[ \t]+$/gm, "")
.replace(/\s+$/u, "")}\n`;
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/grounding/src/text.ts` around lines 45 - 48, Update the text
normalization chain in the visible formatting function to convert standalone
carriage returns to line feeds as well as CRLF sequences. Ensure all line
endings are normalized to LF before trailing whitespace cleanup and the final
newline are applied, preserving digest parity.

…e description fields

Scanned operation names become `export const <name>` in generated
registrations, so ambient overload signatures or computed member names
would silently corrupt the emitted file — refuse loudly instead. Also
make description()'s FieldDescription properties enumerable so spread,
serialization, and Object.keys expose them.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CgjCQ7r2tJH89PqZDU1DrV

Copy link
Copy Markdown
Owner Author

Addressed the review in 719997e: scanOperations now throws on duplicate (overload-signature) and non-identifier method names before codegen, and description()'s description/example properties are enumerable, both with tests.

Two items intentionally skipped:

  • normalizeText lone-\r handling: this helper is upstreamed from HoBo's codegen and must stay byte-identical to keep downstream golden-digest parity; lone CRs don't occur in the corpora it normalizes.
  • "outDir": null in tsconfig.test.json: kept for consistency with the other packages' test tsconfigs in this repo.

Generated by Claude Code

TC39 stage-3 decorators only: intent/returns are plain stage-3 method
decorators, description() is a plain FieldDescription factory (param is
an alias), and the legacy prototype-keyed pending registry, parameter
decorator shim, and granularLegacyOptions are removed. No v1 exists;
no previous patterns to support.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CgjCQ7r2tJH89PqZDU1DrV
@Tyler-R-Kendrick
Tyler-R-Kendrick merged commit 421512e into main Jul 26, 2026
3 checks passed
@Tyler-R-Kendrick
Tyler-R-Kendrick deleted the claude/hobo-ts-autocode-integration-0ys9yx branch July 26, 2026 19:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants