@dtlabs/ai-toolkit 0.10.1 → 0.12.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 (49) hide show
  1. package/CHANGELOG.md +108 -0
  2. package/bin/cli.js +1457 -143
  3. package/docs/installation.md +74 -8
  4. package/docs/reference.md +60 -12
  5. package/lib/asset-catalog.js +52 -0
  6. package/lib/execution-ledger.js +515 -0
  7. package/package.json +9 -7
  8. package/{.claude → src/claude}/agents/define-feature.md +36 -60
  9. package/{.claude → src/claude}/agents/install-toolkit.md +30 -103
  10. package/{.claude → src/claude}/scripts/wb-render.js +101 -2
  11. package/{.claude → src/claude}/scripts/wb-validate.js +32 -2
  12. package/{.claude → src/claude}/skills/implement-feature/SKILL.md +4 -2
  13. package/{.claude → src/claude}/workflows/am-phase1.js +9 -12
  14. package/{.claude → src/claude}/workflows/pm-phase1.js +25 -75
  15. package/{.claude → src/claude}/workflows/pm-phase2.js +57 -108
  16. package/{.claude → src/claude}/workflows/pm-phase3.js +162 -75
  17. package/.claude/scripts/.gitkeep +0 -0
  18. /package/{.claude → src/claude}/agents/concurrency-safety-assessment.md +0 -0
  19. /package/{.claude → src/claude}/agents/dependency-injection-refactoring.md +0 -0
  20. /package/{.claude → src/claude}/agents/dependency-supply-chain-security.md +0 -0
  21. /package/{.claude → src/claude}/agents/developer-backend.md +0 -0
  22. /package/{.claude → src/claude}/agents/developer-frontend.md +0 -0
  23. /package/{.claude → src/claude}/agents/developer-testing.md +0 -0
  24. /package/{.claude → src/claude}/agents/domain-model-refactoring.md +0 -0
  25. /package/{.claude → src/claude}/agents/generate-requirements.md +0 -0
  26. /package/{.claude → src/claude}/agents/generate-tech-spec.md +0 -0
  27. /package/{.claude → src/claude}/agents/generate-work-breakdown.md +0 -0
  28. /package/{.claude → src/claude}/agents/generic-software-assessment.md +0 -0
  29. /package/{.claude → src/claude}/agents/god-class-decomposition.md +0 -0
  30. /package/{.claude → src/claude}/agents/init-agents-md.md +0 -0
  31. /package/{.claude → src/claude}/agents/intervention-documentation-standard.md +0 -0
  32. /package/{.claude → src/claude}/agents/layered-architecture-assessment.md +0 -0
  33. /package/{.claude → src/claude}/agents/review-solution.md +0 -0
  34. /package/{.claude → src/claude}/agents/security-hardening.md +0 -0
  35. /package/{.claude → src/claude}/agents/validate-feature-docs.md +0 -0
  36. /package/{.claude → src/claude}/agents/validate-work-breakdown-semantic.md +0 -0
  37. /package/{.claude → src/claude}/commands/assessment-status.md +0 -0
  38. /package/{.claude → src/claude}/commands/check-docs.md +0 -0
  39. /package/{.claude → src/claude}/commands/check-interventions.md +0 -0
  40. /package/{.claude → src/claude}/commands/feature-status.md +0 -0
  41. /package/{.claude → src/claude}/commands/next-intervention.md +0 -0
  42. /package/{.claude → src/claude}/commands/next-task.md +0 -0
  43. /package/{.claude → src/claude}/commands/pr-description.md +0 -0
  44. /package/{.claude → src/claude}/skills/assess-codebase/SKILL.md +0 -0
  45. /package/{.claude → src/claude}/skills/define-feature/SKILL.md +0 -0
  46. /package/{.claude → src/claude}/skills/hi-gaia/SKILL.md +0 -0
  47. /package/{.claude → src/claude}/skills/init-agents/SKILL.md +0 -0
  48. /package/{.claude → src/claude}/skills/install-toolkit/SKILL.md +0 -0
  49. /package/{.claude → src/claude}/workflows/am-phase2.js +0 -0
@@ -13,7 +13,8 @@ No authentication setup required — it is a public package.
13
13
 
14
14
  ### Local installation (default)
15
15
 
16
- Copies `.claude/`, `docs/`, and `CLAUDE.md` into the current directory:
16
+ Copies all asset categories from the toolkit's `src/claude/` tree into the target project's `.claude/`
17
+ directory, plus `docs/` and `CLAUDE.md`:
17
18
 
18
19
  ```bash
19
20
  npx @dtlabs/ai-toolkit
@@ -31,9 +32,15 @@ Overwrite existing files without confirmation:
31
32
  npx @dtlabs/ai-toolkit --local . --force
32
33
  ```
33
34
 
35
+ Preview what would change without writing any files (dry run):
36
+
37
+ ```bash
38
+ npx @dtlabs/ai-toolkit --local . --dry-run
39
+ ```
40
+
34
41
  ### Global installation
35
42
 
36
- Merges `.claude/agents`, `.claude/skills`, `.claude/commands`, `docs/`, and `CLAUDE.md` into `~/.claude/`:
43
+ Merges all asset categories into `~/.claude/<category>/`, plus `docs/` and `CLAUDE.md`:
37
44
 
38
45
  ```bash
39
46
  npm install -g @dtlabs/ai-toolkit
@@ -46,20 +53,79 @@ Force overwrite:
46
53
  ai-toolkit --global --force
47
54
  ```
48
55
 
56
+ Preview the global install without writing any files:
57
+
58
+ ```bash
59
+ ai-toolkit --global --dry-run
60
+ ```
61
+
62
+ ### Asset catalog
63
+
64
+ The installer derives the list of installable directories from the **asset catalog**
65
+ (`lib/asset-catalog.js`). Each catalog entry defines:
66
+
67
+ | Field | Description |
68
+ |---|---|
69
+ | `name` | Category name (e.g. `agents`, `skills`) |
70
+ | `sourceDir` | Location inside the package (`src/claude/<name>`) |
71
+ | `runtimeDir` | Destination inside the installed `.claude/` folder (`.claude/<name>`) |
72
+
73
+ Adding a new category to the catalog automatically includes it in every install — no
74
+ changes to `bin/cli.js` are required.
75
+
49
76
  ### What gets copied where
50
77
 
51
78
  | Mode | Source (in package) | Destination |
52
79
  |---|---|---|
53
- | Local | `.claude/` | `<target>/.claude/` |
80
+ | Local | `src/claude/agents/` | `<target>/.claude/agents/` |
81
+ | Local | `src/claude/skills/` | `<target>/.claude/skills/` |
82
+ | Local | `src/claude/commands/` | `<target>/.claude/commands/` |
83
+ | Local | `src/claude/workflows/` | `<target>/.claude/workflows/` |
84
+ | Local | `src/claude/scripts/` | `<target>/.claude/scripts/` |
54
85
  | Local | `docs/` | `<target>/docs/` |
55
86
  | Local | `CLAUDE.md` | `<target>/CLAUDE.md` |
56
- | Global | `.claude/agents/` | `~/.claude/agents/` |
57
- | Global | `.claude/skills/` | `~/.claude/skills/` |
58
- | Global | `.claude/commands/` | `~/.claude/commands/` |
87
+ | Global | `src/claude/agents/` | `~/.claude/agents/` |
88
+ | Global | `src/claude/skills/` | `~/.claude/skills/` |
89
+ | Global | `src/claude/commands/` | `~/.claude/commands/` |
90
+ | Global | `src/claude/workflows/` | `~/.claude/workflows/` |
91
+ | Global | `src/claude/scripts/` | `~/.claude/scripts/` |
59
92
  | Global | `docs/` | `~/.claude/docs/` |
60
- | Global | `CLAUDE.md` | `~/.claude/CLAUDE.md` |
93
+ | Global | `CLAUDE.global.md` | `~/.claude/CLAUDE.md` |
94
+
95
+ > The toolkit sources assets from `src/claude/` (versioned, purity-guarded), not from
96
+ > `.claude/` at the project root. The `.claude/` folder in the toolkit repository is for
97
+ > personal configuration only (gitignored).
61
98
 
62
- > The asymmetry is intentional: locally you mirror the package layout, globally you merge into Claude Code's standard folder structure.
99
+ ---
100
+
101
+ ## Upgrade path
102
+
103
+ When a newer version of the toolkit is installed over an existing one, the installer
104
+ automatically detects and removes **orphaned files** — files that were part of a previous
105
+ installation but no longer exist in the current package.
106
+
107
+ Orphaned files are moved to `.claude/.ai-toolkit-trash/<timestamp>/` rather than
108
+ deleted outright, so they can be recovered if needed. Each upgrade session uses a
109
+ unique ISO-timestamp subdirectory, ensuring that repeated upgrades never overwrite
110
+ previously trashed files.
111
+
112
+ The manifest (`.claude/.ai-toolkit-manifest.json`) is updated after each install to
113
+ reflect the current file set. The trash directory is excluded from the manifest automatically.
114
+
115
+ ---
116
+
117
+ ## Developer workflow
118
+
119
+ When developing the toolkit itself, use the convenience scripts in `package.json`:
120
+
121
+ ```bash
122
+ # Preview global install without writing files
123
+ npm run toolkit:dev-install-global
124
+ # (this runs --global --dry-run first, then --global)
125
+
126
+ # Validate that no test files have crept into src/claude/
127
+ npm run toolkit:validate-purity
128
+ ```
63
129
 
64
130
  ---
65
131
 
package/docs/reference.md CHANGED
@@ -41,7 +41,7 @@ Cheatsheet of every skill, command, agent, and procedure shipped with this toolk
41
41
 
42
42
  ---
43
43
 
44
- ## Skills (in `.claude/skills/`)
44
+ ## Skills (in `src/claude/skills/`, installed to `.claude/skills/`)
45
45
 
46
46
  Invoked as `/<name>`. Comprehensive workflows that may chain multiple agents.
47
47
 
@@ -68,7 +68,7 @@ Invoked as `/<name>`. Comprehensive workflows that may chain multiple agents.
68
68
 
69
69
  ---
70
70
 
71
- ## Commands (in `.claude/commands/`)
71
+ ## Commands (in `src/claude/commands/`, installed to `.claude/commands/`)
72
72
 
73
73
  Invoked as `/<name>`. Lightweight shortcuts focused on the current state of the repo. Do **not** spawn long-running workflows.
74
74
 
@@ -89,7 +89,7 @@ Invoked as `/<name>`. Lightweight shortcuts focused on the current state of the
89
89
 
90
90
  ---
91
91
 
92
- ## Agents (in `.claude/agents/`)
92
+ ## Agents (in `src/claude/agents/`, installed to `.claude/agents/`)
93
93
 
94
94
  Invoked via the Agent tool with `subagent_type`. Specialised sub-conversations that produce a single deliverable.
95
95
 
@@ -160,6 +160,52 @@ Reusable text procedures referenced by agents. **Override locally** by placing a
160
160
 
161
161
  ---
162
162
 
163
+ ## CLI Commands (`ai-toolkit <command>`)
164
+
165
+ The `ai-toolkit` binary (from `bin/cli.js`) provides commands for runtime asset resolution, script execution, and diagnostics.
166
+
167
+ ### Asset resolution
168
+
169
+ | Command | Purpose | Exit |
170
+ |---|---|---|
171
+ | `ai-toolkit resolve-asset <relativePath> [--project <dir>] [--home <dir>]` | Resolve a runtime asset path using the six-phase algorithm; stdout=resolved path | 0 success / 1 error |
172
+ | `ai-toolkit run-asset <relativePath> [--project <dir>] [--home <dir>] [-- ...args]` | Resolve and execute a `scripts/*.js` asset; propagates exit code | script exit code |
173
+ | `ai-toolkit list-assets [--category <name>] [--format json\|plain] [--project <dir>] [--home <dir>]` | List installed runtime assets from `.claude/<category>/`; exit 0 even when empty | 0 always |
174
+ | `ai-toolkit doctor-resolution [--project <dir>] [--home <dir>]` | Doctor resolution diagnostics: reports presence mode, install mode, version, completeness gaps | 0 / 1 |
175
+ | `ai-toolkit validate-purity [<sourceDir>]` | Check that `src/claude/` contains no test or fixture files | 0 clean / 1 violations |
176
+
177
+ ### `resolveClaudeRuntimeAsset(relativePath, options)` — resolver API
178
+
179
+ The core runtime resolution algorithm exposed from `bin/cli.js`:
180
+
181
+ ```javascript
182
+ const { resolveClaudeRuntimeAsset } = require('@dtlabs/ai-toolkit/bin/cli');
183
+ const resolvedPath = resolveClaudeRuntimeAsset('agents/developer-backend.md', {
184
+ projectDir: '/path/to/project', // optional; defaults to process.cwd()
185
+ home: '/path/to/home', // optional; defaults to os.homedir()
186
+ });
187
+ ```
188
+
189
+ Six-phase algorithm:
190
+ - **Phase 0**: Input validation (relativePath must be a non-empty string)
191
+ - **Phase A**: Presence detection — checks manifest (condA), version stamp (condB), payload files (condC)
192
+ - **Phase B**: Mode decision — local (project `.claude/`) vs global (`~/.claude/`)
193
+ - **Phase C**: Metadata warnings (version stamp missing, mode ambiguity)
194
+ - **Phase D**: Completeness check — verifies requested file exists, validates catalog membership
195
+ - **Phase E**: Return resolved absolute path with confinement check
196
+
197
+ ### Doctor resolution
198
+
199
+ `ai-toolkit doctor-resolution` reports the full resolution diagnosis for a project:
200
+ - Detected presence mode (manifest / stamp / payload / none)
201
+ - Install mode (local / global)
202
+ - Installed version
203
+ - Catalog completeness gaps (files present in asset catalog but missing from runtime)
204
+
205
+ Used by workflow agents to verify installation via doctor resolution before dispatching asset-dependent tasks.
206
+
207
+ ---
208
+
163
209
  ## Typical flows
164
210
 
165
211
  ### Flow 1 — Brand new feature, end-to-end
@@ -217,12 +263,14 @@ Then delegate manually to the suggested agent, or rerun `/implement-feature` to
217
263
 
218
264
  ## File locations
219
265
 
220
- | What | Local install | Global install |
221
- |---|---|---|
222
- | Agents | `<project>/.claude/agents/` | `~/.claude/agents/` |
223
- | Skills | `<project>/.claude/skills/` | `~/.claude/skills/` |
224
- | Commands | `<project>/.claude/commands/` | `~/.claude/commands/` |
225
- | Procedures | `<project>/docs/procedures/` | `~/.claude/docs/procedures/` |
226
- | Feature docs | `<project>/docs/features/FTR-NNN-slug/` | — |
227
- | Assessment docs | `<project>/docs/assessments/ASSESS-NNN/` | — |
228
- | This reference | `<project>/docs/reference.md` | `~/.claude/docs/reference.md` |
266
+ | What | Source (toolkit repo) | Local install | Global install |
267
+ |---|---|---|---|
268
+ | Agents | `src/claude/agents/` | `<project>/.claude/agents/` | `~/.claude/agents/` |
269
+ | Skills | `src/claude/skills/` | `<project>/.claude/skills/` | `~/.claude/skills/` |
270
+ | Commands | `src/claude/commands/` | `<project>/.claude/commands/` | `~/.claude/commands/` |
271
+ | Workflows | `src/claude/workflows/` | `<project>/.claude/workflows/` | `~/.claude/workflows/` |
272
+ | Scripts | `src/claude/scripts/` | `<project>/.claude/scripts/` | `~/.claude/scripts/` |
273
+ | Procedures | `docs/procedures/` | `<project>/docs/procedures/` | `~/.claude/docs/procedures/` |
274
+ | Feature docs | — | `<project>/docs/features/FTR-NNN-slug/` | — |
275
+ | Assessment docs | — | `<project>/docs/assessments/ASSESS-NNN/` | — |
276
+ | This reference | `docs/reference.md` | `<project>/docs/reference.md` | `~/.claude/docs/reference.md` |
@@ -0,0 +1,52 @@
1
+ 'use strict';
2
+
3
+ const ASSET_CATEGORIES = [
4
+ {
5
+ name: 'agents',
6
+ sourceDir: 'src/claude/agents',
7
+ runtimeDir: '.claude/agents',
8
+ description: 'Agent definition files (.md with YAML frontmatter)',
9
+ },
10
+ {
11
+ name: 'commands',
12
+ sourceDir: 'src/claude/commands',
13
+ runtimeDir: '.claude/commands',
14
+ description: 'Slash command definition files',
15
+ },
16
+ {
17
+ name: 'skills',
18
+ sourceDir: 'src/claude/skills',
19
+ runtimeDir: '.claude/skills',
20
+ description: 'User-invocable skill directories with SKILL.md',
21
+ },
22
+ {
23
+ name: 'workflows',
24
+ sourceDir: 'src/claude/workflows',
25
+ runtimeDir: '.claude/workflows',
26
+ description: 'Claude Code Workflow orchestrator scripts (.js)',
27
+ },
28
+ {
29
+ name: 'scripts',
30
+ sourceDir: 'src/claude/scripts',
31
+ runtimeDir: '.claude/scripts',
32
+ description: 'Utility and helper scripts',
33
+ },
34
+ ];
35
+
36
+ function getAssetCategories() {
37
+ return ASSET_CATEGORIES;
38
+ }
39
+
40
+ function getCategoryByName(name) {
41
+ return ASSET_CATEGORIES.find(cat => cat.name === name);
42
+ }
43
+
44
+ if (require.main === module) {
45
+ console.log(JSON.stringify(ASSET_CATEGORIES, null, 2));
46
+ } else {
47
+ module.exports = {
48
+ ASSET_CATEGORIES,
49
+ getAssetCategories,
50
+ getCategoryByName,
51
+ };
52
+ }