Repository navigation
Conversation
AI coding tools tend to scatter history, rationale, and decision notes as inline comments throughout a file, which makes the surrounding code harder to read. The `@ai` tag gives those notes a single, predictable home inside the JSDoc comment block. The tag requires a value and can be used more than once, so notes from several tools or sessions accumulate in an `ai` array on the doclet instead of overwriting each other. The tag is added to the core (JSDoc) dictionary only; the Closure dictionary picks its tags individually and is unaffected. The default template renders the notes under an "AI Notes:" heading.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
AI coding tools tend to leave history, rationale, and decision notes as inline comments scattered through a file. Running into a note written by a tool in the middle of a function is confusing, and over time it makes the surrounding code noticeably harder to read.
There is currently no conventional place for that kind of note, so it ends up wherever the tool happened to be editing.
Proposal
Add an
@aiblock tag that gives those notes a single, predictable home inside the JSDoc comment block:To be clear about the scope: this PR only adds the tag. Getting an AI tool to actually write its notes there is up to the user's own instructions to the tool, or to the tool reading the JSDoc documentation. That part is deliberately out of scope here.
Design
The tag takes a required value and can be repeated:
mustHaveValue: true-- an empty@aiis not meaningful.aiarray on the doclet, so notes from several tools or several sessions do not overwrite each other.It is defined in
core.js, which feeds the JSDoc dictionary. The Closure dictionary picks its tags individually rather than spreading the core set, so it is unaffected --@aiis not a Closure Compiler tag and does not appear there.DOCLET_SCHEMAusesadditionalProperties: false, so theaiproperty is added to the schema as well.The default template renders the notes under an "AI Notes:" heading in
details.tmpl.Changes
packages/jsdoc-tag/lib/definitions/core.jspackages/jsdoc-doclet/lib/schema.jsaiproperty on the doclet schemapackages/jsdoc-template-legacy/tmpl/details.tmplpackages/jsdoc/test/fixtures/aitag.jspackages/jsdoc/test/specs/tags/aitag.js5 files, +56 lines, no deletions.
Testing
npm run lint-- cleannpm run license-check-- cleannpm test-- 568 suites, 1626 specs, 0 failures-XJSON output as anaiarray.On adding tags to core
I realize proposals for new core tags come up fairly often -- #1162 (
@chainable), #1277 (time complexity), #2047 (@scope) and #2139 (@legacy) are all still open -- and I could not find a written policy on where the line sits between a core tag and a plugin-defined one.So rather than asking for a merge outright, I would mostly like a direction:
@aibelongs in core, this branch is ready as-is.dictionary.defineTag()and close the PR. The implementation is nearly identical, so it costs me very little.Either way, if this lands I am happy to follow up with documentation in
jsdoc/jsdoc.github.io.