@erclx/aitk 0.8.0 → 0.10.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 (46) hide show
  1. package/README.md +17 -13
  2. package/claude/.claude-plugin/plugin.json +1 -1
  3. package/claude/skills/claude-address-review/REQUIREMENT.md +39 -0
  4. package/claude/skills/claude-address-review/SKILL.md +3 -4
  5. package/claude/skills/claude-autoship/REQUIREMENT.md +41 -0
  6. package/claude/skills/claude-autoship/SKILL.md +1 -1
  7. package/claude/skills/claude-diagram/SKILL.md +70 -40
  8. package/claude/skills/claude-docs/REQUIREMENT.md +39 -0
  9. package/claude/skills/claude-docs/SKILL.md +1 -1
  10. package/claude/skills/claude-memory-review/SKILL.md +1 -1
  11. package/claude/skills/claude-pr-review/REQUIREMENT.md +38 -0
  12. package/claude/skills/claude-pr-review/SKILL.md +1 -1
  13. package/claude/skills/claude-review/REQUIREMENT.md +39 -0
  14. package/claude/skills/claude-review/SKILL.md +1 -1
  15. package/claude/skills/claude-seed-sync/SKILL.md +1 -1
  16. package/claude/skills/claude-ui-test/SKILL.md +1 -1
  17. package/claude/skills/claude-ux-audit/SKILL.md +1 -1
  18. package/claude/skills/claude-worktree/SKILL.md +2 -2
  19. package/claude/skills/git-followup/SKILL.md +1 -1
  20. package/claude/skills/git-issue/SKILL.md +1 -6
  21. package/claude/skills/git-pr/SKILL.md +1 -6
  22. package/claude/skills/git-split/REQUIREMENT.md +2 -1
  23. package/claude/skills/git-split/SKILL.md +2 -0
  24. package/docs/agents.md +26 -0
  25. package/docs/ai-workflow.md +1 -1
  26. package/docs/target-projects.md +2 -2
  27. package/governance/rules/claude/560-diagrams.md +10 -2
  28. package/governance/rules/claude/570-skill.md +1 -1
  29. package/package.json +1 -1
  30. package/scripts/core/install-check.sh +1 -1
  31. package/src/claude/seeds.ts +7 -1
  32. package/src/cli.ts +4 -0
  33. package/src/commands/comments.ts +234 -0
  34. package/src/comments/scan.ts +338 -0
  35. package/src/comments/trend.ts +207 -0
  36. package/src/comments/vocabulary.ts +85 -0
  37. package/src/git-env.ts +36 -0
  38. package/src/git-ignore.ts +46 -0
  39. package/src/indexes/walk.ts +1 -29
  40. package/standards/diagrams.md +65 -15
  41. package/standards/index.md +2 -2
  42. package/standards/prose.md +14 -1
  43. package/standards/readme.md +15 -1
  44. package/standards/skill.md +14 -0
  45. package/tooling/claude/reference.md +5 -0
  46. package/tooling/claude/seeds/.claude/diagrams/index.md +8 -0
@@ -1,6 +1,6 @@
1
1
  import { existsSync, statSync } from 'node:fs'
2
2
  import { dirname, resolve } from 'node:path'
3
- import { $ } from 'bun'
3
+ import { listIgnored } from '@/git-ignore'
4
4
 
5
5
  const INDEX_FILE = 'index.md'
6
6
 
@@ -42,34 +42,6 @@ export async function listIndexes(root: string): Promise<string[]> {
42
42
  return candidates.filter((path) => !ignored.has(path))
43
43
  }
44
44
 
45
- async function listIgnored(
46
- root: string,
47
- candidates: string[],
48
- ): Promise<Set<string>> {
49
- const isRepo = await $`git -C ${root} rev-parse --git-dir`
50
- .quiet()
51
- .nothrow()
52
- .then((result) => result.exitCode === 0)
53
-
54
- if (!isRepo) return new Set()
55
-
56
- const stdin = Buffer.from(`${candidates.join('\n')}\n`)
57
-
58
- const result = await $`git -C ${root} check-ignore --stdin < ${stdin}`
59
- .quiet()
60
- .nothrow()
61
-
62
- if (result.exitCode > 1) return new Set()
63
-
64
- return new Set(
65
- result
66
- .text()
67
- .split('\n')
68
- .filter(Boolean)
69
- .map((path) => resolve(root, path)),
70
- )
71
- }
72
-
73
45
  /**
74
46
  * Reports whether git ignores `path`.
75
47
  *
@@ -1,34 +1,83 @@
1
1
  ---
2
2
  title: Diagram reference
3
- description: Conventions for Mermaid diagrams in .claude/DIAGRAMS.md
3
+ description: Shape and content rules for .claude/diagrams/<kind>.md files
4
4
  ---
5
5
 
6
6
  # Diagram reference
7
7
 
8
- Applies to Mermaid diagrams in `.claude/DIAGRAMS.md`. Goal: diagrams that render cleanly in narrow-column renderers (VS Code preview, GitHub PR view, Cursor) and read pedagogically without surrounding prose.
8
+ Applies to per-kind entries under `.claude/diagrams/`. Skip for `index.md`, which is regenerated by `aitk indexes regen`.
9
+
10
+ A diagram entry answers one question about the system with one or more Mermaid diagrams and the prose that makes them readable. It is not a rendering of the file tree. The check for any single line: does it tell a reader something the code layout would not have told them? If not, it belongs in `.claude/context/`.
11
+
12
+ ## What a working entry looks like
13
+
14
+ An entry works when a reader who has not opened the repository can answer its question:
15
+
16
+ - What are the parts, and which ones talk to each other?
17
+ - Which direction does the work flow, and where does it start?
18
+ - What would break if one box were removed?
19
+
20
+ An entry that fails these is non-conforming regardless of whether it satisfies every section rule below. The fences are the means. These three questions are the test.
21
+
22
+ ## Frontmatter
23
+
24
+ - `title` (required): sentence case, names what the entry answers (`System context`, `Request flow`), not what it draws.
25
+ - `description` (required): one line on which question the entry settles and which source signal drives it.
26
+ - `category` (required): the diagram kind, one of the five in Entry kinds. It is the grouping field `aitk indexes regen` renders headings from.
27
+
28
+ All three feed `.claude/diagrams/index.md` when regenerated. The catalog sorts categories alphabetically rather than in narrative order, so an entry cannot rely on its position to introduce another. Each entry names its own starting point, and the catalog's subtitle routes a first-time reader to the system context entry.
29
+
30
+ ## Entry kinds
31
+
32
+ Five kinds, each with a fixed filename and a fixed `category` value. Write a kind only when its source signal exists, and leave the rest absent rather than padding the folder.
33
+
34
+ - `system-context.md`, category `System context` (`flowchart TB`): who uses the system, what it talks to, and where its boundary sits. Drawn from `.claude/REQUIREMENTS.md`. This is the entry a reader outside the team opens first, and the only kind that draws the world outside the boundary.
35
+ - `components.md`, category `Components` (`flowchart TB` with `subgraph` boundaries): the layered structure inside the boundary. Drawn from `.claude/ARCHITECTURE.md`.
36
+ - `request-flow.md`, category `Request flow` (`sequenceDiagram`): a request lifecycle, an agent loop, or an interaction between actors.
37
+ - `data-pipeline.md`, category `Data pipeline` (`flowchart TB`): retrieval, ranking, queues, or ETL.
38
+ - `deployment.md`, category `Deployment` (`flowchart TB`): hosts, services, and infrastructure config.
39
+
40
+ The filenames are fixed rather than free, so a session refreshing one kind finds the file it is meant to overwrite instead of writing a second entry beside it under a name of its own.
41
+
42
+ Stay inside `flowchart` and `sequenceDiagram`. C4, state, ER, and class diagrams render inconsistently across viewers.
43
+
44
+ The kinds drift at rates spanning roughly an order of magnitude, which is why they are separate files. A deploy change rewrites one entry and leaves the other four untouched.
45
+
46
+ A second entry for one kind takes a suffixed name (`request-flow-admin.md`) and repeats the kind's `category` verbatim, which is what the grouping field is for. One entry per kind is the ordinary case, so most catalogs show one entry under each heading.
9
47
 
10
48
  ## Layout
11
49
 
12
50
  - Declare `flowchart TB` by default. Mermaid ignores a subgraph's direction whenever that subgraph links outward, and an architecture diagram links across its subgraphs as the normal case, so top-bottom is a declaration rather than a guarantee.
13
51
  - Restructure a diagram that renders diagonal or left-to-right. Repeating the direction keyword does not fix it.
14
- - Render a component, context, or pipeline diagram taller than wide. A `sequenceDiagram` is wide by construction and is exempt.
52
+ - Render a context, component, or pipeline diagram taller than wide. A `sequenceDiagram` is wide by construction and is exempt.
15
53
  - Do not let independent nodes render in a row. A row of siblings reads as a sequential chain and asserts a pipeline the system does not have.
16
54
  - Do not converge many edges on one node from one side. A crossing bundle is unreadable whatever it encodes.
17
55
  - Keep node labels short. Three or four words max. Detail goes in the paragraph below the diagram.
18
56
  - Use `<br/>` for a second short line on a node when the label is two ideas, never for a sentence.
19
- - Subgraphs are for grouping unrelated lanes (offline versus online, browser versus server). Do not subgraph a single linear flow.
57
+ - Subgraphs are for grouping unrelated lanes such as offline versus online or browser versus server. Do not subgraph a single linear flow.
20
58
 
21
59
  ## Budgets
22
60
 
23
61
  - Hold a diagram to roughly 5 to 10 nodes. Split it past 15.
24
62
  - Watch edge count harder than node count. It binds first, and a diagram whose edges outnumber its nodes is already too dense to read.
25
63
  - Treat a diagram that cannot be described in one sentence as two diagrams.
64
+ - Keep an entry to one diagram by default. A second fence in the same file needs its own H2 naming what it adds, and a third is a sign the entry covers two kinds.
26
65
  - Warn rather than refuse on a budget, and name the split that would fix it. These numbers come from published Mermaid practice rather than from a measurement in this repository, so a hard refusal on them will be wrong sometimes and unarguable when it is.
27
66
 
28
67
  ## Accessibility
29
68
 
30
69
  - Give every diagram `accTitle` and `accDescr`. `accTitle` names what the diagram answers. `accDescr` states the structure in one sentence for a reader who cannot see the render.
31
70
 
71
+ ## Explanation
72
+
73
+ - One to three short paragraphs below each diagram. Plain English and pedagogical.
74
+ - Lead with what the diagram shows. Follow with why this shape was chosen and what alternative was rejected, when the choice was non-obvious.
75
+ - Reference one or two specific code paths the reader can open. Do not enumerate every file.
76
+ - Do not duplicate prose across entries. An entry that restates its neighbor has taken the neighbor's job.
77
+ - The audience is mixed, so vocabulary runs as a gradient across the set. `System context` assumes no knowledge of the repository. `Deployment` may assume the reader has read the others.
78
+
79
+ This section states the voice for the surface, which is what claims the yield `standards/prose.md` grants to a surface whose own standard sets it. Explanation prose is pedagogical here and the default developer-facing voice does not apply. The yield covers voice alone. Punctuation, formatting, and language bans stay in force, and the standards-audit hook enforces them on every write.
80
+
32
81
  ## Verification
33
82
 
34
83
  - Judge a diagram from its rendered image, not from its source. Direction, sibling rows, and edge bundles are visible only in the output.
@@ -36,20 +85,21 @@ Applies to Mermaid diagrams in `.claude/DIAGRAMS.md`. Goal: diagrams that render
36
85
  - Apply four tests as a reviewer, the same ones the author applied: direction held, no sibling row reading as a chain, no crossing edge bundle, taller than wide outside a sequence diagram.
37
86
  - State which verification was skipped when no renderer is available. A diagram written without a render is still shippable, and one reported as verified without a render is not.
38
87
 
39
- ## Narrative
88
+ ## What moves to .claude/context/
40
89
 
41
- - Build a narrative arc across the file, not a parallel list of unrelated views. Start with the whole system in five or six boxes. Drill into one phase per section.
42
- - Order sections chronologically when possible: framing, then setup, then a query travels through, then measurement.
43
- - One H2 per diagram. The H2 names what the diagram answers, not what it shows ("How the corpus gets populated", not "Corpus ingestion").
90
+ Implementation detail that answers how a component is built belongs in a `.claude/context/` entry, not a diagram:
44
91
 
45
- ## Explanation
92
+ - Function names, call signatures, and lifecycle ordering
93
+ - Library versions, config keys, and environment variable names
94
+ - Retry counts, timeouts, and batch sizes
95
+ - Workarounds and rejected approaches that need more than one sentence
46
96
 
47
- - One to three short paragraphs below each diagram. Plain English, pedagogical, no marketing copy.
48
- - Lead with what the diagram shows. Follow with why this shape was chosen and what alternative was rejected, when the choice was non-obvious.
49
- - Reference one or two specific code paths the reader can open. Do not enumerate every file.
50
- - Do not duplicate prose between sections. Each paragraph earns its line.
97
+ Reference the context entry by path when a reader needs the mechanism. The diagram stays answerable on its own for structure and flow.
51
98
 
52
99
  ## Maintenance
53
100
 
54
- - When the system changes (new layer, new provider, new deploy posture), audit `.claude/DIAGRAMS.md` in the same PR. A diagram showing a defunct host or library is worse than no diagram.
55
- - Mermaid blocks are inside fenced code, so the prose-standards hook ignores them. The explanation paragraph below is still prose. Follow `standards/prose.md`.
101
+ - When the system changes, update the entries whose source signal changed and leave the rest alone. Rewriting the folder wholesale reproduces the defect the per-kind split exists to end.
102
+ - A diagram showing a defunct host or library is worse than no diagram. Audit the affected entry in the same PR.
103
+ - `System context` has no named source signal beyond `.claude/REQUIREMENTS.md`, so nothing tells a session it went stale. Re-read it when the boundary or the set of external dependencies moves.
104
+ - Mermaid blocks are inside fenced code, so the prose-standards hook ignores them. The explanation paragraphs around them are still prose. Follow `standards/prose.md`.
105
+ - The punctuation bans still apply to node and subgraph labels, and nothing checks them there. An em dash in a label passes every gate the repository has, so read the labels before shipping the entry.
@@ -10,9 +10,9 @@ Reference docs for consistent authoring across the toolkit and target projects.
10
10
  - [Architecture reference](architecture.md): Shape and content rules for .claude/ARCHITECTURE.md
11
11
  - [Context entry reference](context.md): Shape and content rules for .claude/context/<domain>.md entries
12
12
  - [Design reference](design.md): Shape and content rules for .claude/DESIGN.md
13
- - [Diagram reference](diagrams.md): Conventions for Mermaid diagrams in .claude/DIAGRAMS.md
13
+ - [Diagram reference](diagrams.md): Shape and content rules for .claude/diagrams/<kind>.md files
14
14
  - [Prose reference](prose.md): Voice, structure, formatting, and language rules for reference markdown
15
- - [Readme reference](readme.md): Readme structure and content conventions
15
+ - [Readme reference](readme.md): Readme voice, structure, and content conventions
16
16
  - [Requirements reference](requirements.md): Shape and content rules for .claude/REQUIREMENTS.md
17
17
  - [Governance rule reference](rule.md): Rule frontmatter, body shape, and voice for .claude/rules files
18
18
  - [Claude skill reference](skill.md): Claude skill structure and authoring rules
@@ -5,7 +5,7 @@ description: Voice, structure, formatting, and language rules for reference mark
5
5
 
6
6
  # Prose reference
7
7
 
8
- Applies to markdown reference docs, READMEs, and inline documentation in repos. It is the default voice for `.md` files and yields to any surface with its own voice, such as blogs, emails, changelogs, or commit messages.
8
+ Applies to markdown reference docs, READMEs, and inline documentation in repos. It is the default voice for `.md` files and yields to any surface with its own voice, such as blogs, emails, changelogs, or commit messages. It also yields wherever another standard states the voice for the surface it governs, which is how a surface claims the exemption without this file having to name it. The yield covers voice alone. Punctuation, formatting, and language rules below stay in force on every surface, including the surfaces no automated check reaches, which is what the scan below is for.
9
9
 
10
10
  ## Voice
11
11
 
@@ -74,6 +74,19 @@ Applies to markdown reference docs, READMEs, and inline documentation in repos.
74
74
  - Do not address the reader as a participant (`Let's`, `Here's`, `Here are`). State the content directly.
75
75
  - Commit to a position. Do not hedge in clusters (`It might be worth considering`) or use false balance (`While X is true, Y is also important`). Recommend, or state the tradeoff.
76
76
 
77
+ ## Banned-character scan
78
+
79
+ Wherever text leaves through a channel no automated check covers, the author is the only gate and runs this scan. Text sent to another service, written to a path the project's checks exclude, and text inside a fenced block are the usual cases. The surface that publishes the text is what knows which gap applies, so it names its own rather than reading one here.
80
+
81
+ Scan the drafted text and rewrite each occurrence:
82
+
83
+ - `—` (em dash): split into two sentences, or use a comma
84
+ - `;` (semicolon): split into two sentences
85
+
86
+ Restructure the sentence rather than substituting the character. A semicolon swapped for a period leaves both clauses in the order the semicolon chose, which is the shape the ban exists to remove.
87
+
88
+ Run the scan as an explicit step against the finished text. Having read this file before drafting does not cover it, because the check has to happen after the text exists.
89
+
77
90
  ## Frontmatter descriptions
78
91
 
79
92
  When frontmatter carries a short `title` or `description` used for catalog display:
@@ -1,10 +1,24 @@
1
1
  ---
2
2
  title: Readme reference
3
- description: Readme structure and content conventions
3
+ description: Readme voice, structure, and content conventions
4
4
  ---
5
5
 
6
6
  # Readme reference
7
7
 
8
+ Applies to every `README.md`. The `## Voice` section states the voice for a repository's root README, so `prose.md` yields to it there. The yield covers voice alone. The punctuation bans, spelling rules, banned words, and formatting rules in `prose.md` stay in force, so the warmer register ships with the same hygiene: no em dashes, no semicolons, no buzzwords.
9
+
10
+ The reader is what changes. Reference prose serves someone who already committed to the project and is scanning for a fact. A root README meets someone deciding whether to commit at all, and it is often the only file they read.
11
+
12
+ ## Voice
13
+
14
+ Scoped to the README at a repository root. A nested README documenting a folder, a harness, or an internal tool keeps the reference voice in `prose.md`, since its reader has already committed and arrived looking for a fact.
15
+
16
+ - Address the reader in second person. First-person plural needs an authoring organization as its antecedent, so a single-maintainer project has none to use.
17
+ - Use contractions wherever the sentence reads better for one. Do not force them in.
18
+ - Write with a point of view. State what the project chose and why, not a neutral survey of the options it passed over.
19
+ - Ground a claim in something concrete rather than an adjective. A command, a number, or a named constraint carries more than a description of quality.
20
+ - Be honest about limits. Naming what the project does not do reads as more credible, not less.
21
+
8
22
  ## Structure
9
23
 
10
24
  - H1 title, H2 major sections, H3 subsections. Maintain proper hierarchy for GitHub's auto-generated table of contents.
@@ -173,6 +173,18 @@ Without this skill, a session <observed failure>, <observed failure>.
173
173
  - When a skill gathers user input or pre-seeds a template, attach a concrete proposed default to every question, derived from project context. Accept "use defaults" as a bulk-confirm.
174
174
  - Separate correctness axes (routing, sourcing, escalation, decline) from shape axes (line count, formatting, variant sprawl) when tuning a skill. Tighten only on correctness regressions. Do not convert soft caps to hard caps for aesthetic drift when correctness passes.
175
175
 
176
+ ### Deriving the branch slug
177
+
178
+ Run `git branch --show-current` and replace every `/` with `-`. The result is `<slug>`. Anything reading a branch-derived name uses this transform, so two skills cannot spell it differently.
179
+
180
+ A skill that persists output under `.claude/` carries the slug in the filename, which is what keeps parallel worktrees from overwriting each other's output.
181
+
182
+ The empty result is a detached HEAD, and the skill picks one of three responses rather than inheriting a default. State the choice in the body, since the transform is shared and this is not.
183
+
184
+ - Fall back to `latest`, so a read-only pass still writes somewhere predictable
185
+ - Stop, when the skill commits or opens a pull request. There is no branch to put the work on, so `latest` would bury the problem instead of reporting it. State the stop in the skill's guards.
186
+ - Fall through to the next source, when the slug is one candidate among several rather than the name of an output file
187
+
176
188
  ## Scripts
177
189
 
178
190
  - Use `scripts/` for operations that must be deterministic or repetitive
@@ -199,6 +211,8 @@ A standard reaches a skill by two routes, and a body that names only the first b
199
211
  - State the fallback once per body, at the site that reads the standard. A later mention of a standard the body already read stays bare, since repeating the fallback at every mention is noise rather than instruction.
200
212
  - A guard on a standard's presence names the file and tests both paths before it stops. A guard that tests only `.claude/standards/` refuses to run in a plugin-only project that has the file, and a guard that tests the directory passes in the partial-install case it exists to catch.
201
213
  - Use `${CLAUDE_SKILL_DIR}`, never a bare `../../` and never `${CLAUDE_PLUGIN_ROOT}`. Only `${CLAUDE_SKILL_DIR}` is expanded before the body reaches the model. The other two leave the model to infer a base path, which it may resolve against the session cwd instead.
214
+ - Cite a shared procedure, never restate it. A procedure two or more skills execute gets one definition in a standard and a citation in each body. Nothing catches a restatement that drifts, because the drift assertion covers generated copies and a hand-written one is not generated, so the guarantee is only that a single definition exists to correct.
215
+ - Keep the trigger in the body and the procedure in the standard. The citing skill states when the procedure runs and what it runs against, since that varies per skill and the standard cannot know it.
202
216
 
203
217
  ## Invocation
204
218
 
@@ -14,6 +14,7 @@ The claude stack installs the `.claude/` workflow directory into a project. Stat
14
14
  ├── ARCHITECTURE.md ← seeded. Technical design decisions and open questions
15
15
  ├── DESIGN.md ← seeded. Visual intent and the decisions behind it
16
16
  ├── wireframes/ ← seeded. Per-surface ASCII layouts. `index.md` is the discovery anchor; `<surface>.md` files hold the sketches and behavior bullets.
17
+ ├── diagrams/ ← seeded. Per-kind Mermaid views. `index.md` is the discovery anchor. `<kind>.md` files hold one diagram each, grouped by the `category` frontmatter field.
17
18
  ├── GOV.md ← retired. Removed by `aitk gov sync` if present from a prior install
18
19
  ├── settings.json ← seeded. Project-level Claude Code config (PreToolUse and PostToolUse hooks). User-level config installed separately via `aitk claude setup`.
19
20
  ├── plans/ ← execution detail for multi-step tasks, gitignored. `feature-*.md` entries swept by claude-docs.
@@ -32,6 +33,10 @@ Convert by hand, once per project:
32
33
  2. Run `aitk indexes regen --no-stage --root . .claude/tasks/<any-task>.md` to build the catalog.
33
34
  3. Delete `.claude/TASKS.md`, and swap its `.gitignore` entry for `.claude/tasks/`.
34
35
 
36
+ ## Upgrading from a single-file diagram set
37
+
38
+ A project installed before the diagram surface became a folder still holds `.claude/DIAGRAMS.md`. Unlike the board, this one migrates itself. The `claude-diagram` skill reads the flat file when `.claude/diagrams/` holds no entries, splits it by kind into the folder, and reports what it wrote. The old file stays on disk so the split can be compared against its source, and deleting it is a manual step once that check passes.
39
+
35
40
  ## Gitignore
36
41
 
37
42
  - `# Claude`: `.claude/.tmp/`, `.claude/memory/`, `.claude/plans/`, `.claude/review/`, `.claude/worktrees/`, `.claude/tasks/`
@@ -0,0 +1,8 @@
1
+ ---
2
+ title: Diagrams
3
+ subtitle: Per-kind Mermaid views loaded on demand. Start with system context.
4
+ ---
5
+
6
+ # Diagrams
7
+
8
+ Per-kind Mermaid views loaded on demand. Start with system context.