ai-factory 2.12.0 → 2.13.1

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.
@@ -1 +1 @@
1
- {"version":3,"file":"skill-hints.d.ts","sourceRoot":"","sources":["../../../src/cli/wizard/skill-hints.ts"],"names":[],"mappings":"AAwCA,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAEpD;AAED,wBAAgB,qBAAqB,CACjC,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,EACpC,aAAa,GAAE,MAAgC,GAChD,MAAM,CAGR"}
1
+ {"version":3,"file":"skill-hints.d.ts","sourceRoot":"","sources":["../../../src/cli/wizard/skill-hints.ts"],"names":[],"mappings":"AAyCA,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAEpD;AAED,wBAAgB,qBAAqB,CACjC,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,EACpC,aAAa,GAAE,MAAgC,GAChD,MAAM,CAGR"}
@@ -5,6 +5,7 @@ const SKILL_HINTS = {
5
5
  'aif-build-automation': 'Build file automation',
6
6
  'aif-ci': 'CI/CD pipeline setup',
7
7
  'aif-commit': 'Conventional commit helper',
8
+ 'aif-distillation': 'Distill sources into skills',
8
9
  'aif-dockerize': 'Docker and Compose setup',
9
10
  'aif-docs': 'Docs generation and maintenance',
10
11
  'aif-evolve': 'Evolve skills from patches',
@@ -1 +1 @@
1
- {"version":3,"file":"skill-hints.js","sourceRoot":"","sources":["../../../src/cli/wizard/skill-hints.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,GAA2B;IACxC,KAAK,EAAE,mBAAmB;IAC1B,kBAAkB,EAAE,6BAA6B;IACjD,oBAAoB,EAAE,uBAAuB;IAC7C,sBAAsB,EAAE,uBAAuB;IAC/C,QAAQ,EAAE,sBAAsB;IAChC,YA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C,EAAE,SAAS,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;IACjE,OAAO,GAAG,IAAI,KAAK,CAAC;AACxB,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,OAAe;IACxC,OAAO,WAAW,CAAC,OAAO,CAAC,IAAI,kBAAkB,CAAC;AACtD,CAAC;AAED,MAAM,UAAU,qBAAqB,CACjC,OAAe,EACf,UAAoC,EACpC,gBAAwB,uBAAuB;IAE/C,MAAM,IAAI,GAAG,YAAY,CAAC,YAAY,CAAC,OAAO,CAAC,EAAE,aAAa,CAAC,CAAC;IAChE,OAAO,GAAG,OAAO,IAAI,UAAU,CAAC,KAAK,IAAI,EAAE,CAAC,EAAE,CAAC;AACnD,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-factory",
3
- "version": "2.12.0",
3
+ "version": "2.13.1",
4
4
  "type": "module",
5
5
  "description": "CLI tool for automating AI agent context setup in projects",
6
6
  "main": "dist/cli/index.js",
@@ -2,7 +2,7 @@
2
2
  name: aif-commit
3
3
  description: Create conventional commit messages by analyzing staged changes. Generates semantic commit messages following the Conventional Commits specification. Use when user says "commit", "save changes", or "create commit".
4
4
  argument-hint: "[scope or context]"
5
- allowed-tools: Read Bash(git *) AskUserQuestion Questions
5
+ allowed-tools: Read Glob Bash(git *) AskUserQuestion Questions
6
6
  disable-model-invocation: false
7
7
  ---
8
8
 
@@ -13,14 +13,17 @@ Generate commit messages following the [Conventional Commits](https://www.conven
13
13
  ## Workflow
14
14
 
15
15
  **FIRST:** Read `.ai-factory/config.yaml` if it exists to resolve:
16
- - **Paths:** `paths.description`, `paths.architecture`, `paths.rules_file`, `paths.roadmap`, and `paths.rules`
16
+ - **Paths:** `paths.description`, `paths.architecture`, `paths.rules_file`, `paths.roadmap`, `paths.rules`, `paths.plan`, and `paths.plans`
17
17
  - **Language:** `language.ui` for prompts and commit message conventions
18
- - **Git preference:** `git.skip_push_after_commit` for post-commit push behavior
18
+ - **Workflow:** `workflow.plan_id_format` for read-only active plan discovery (`slug` default; `sequential` uses numbered full-plan lookup)
19
+ - **Git preference:** `git.enabled`, `git.create_branches`, and `git.skip_push_after_commit` for active plan discovery and post-commit push behavior
19
20
  - **Rules hierarchy:** `rules.base` plus any named `rules.<area>` entries
20
21
 
21
22
  If config.yaml doesn't exist, use defaults:
22
- - Paths: `.ai-factory/` for all artifacts
23
+ - Paths: `.ai-factory/` for context artifacts, `.ai-factory/PLAN.md` for `paths.plan`, `.ai-factory/plans/` for `paths.plans`
23
24
  - Language: `en` (English)
25
+ - Workflow: `workflow.plan_id_format: slug`
26
+ - Git: `git.enabled: true`, `git.create_branches: true`
24
27
  - Git preference: `skip_push_after_commit: false`
25
28
 
26
29
  **Read `.ai-factory/skill-context/aif-commit/SKILL.md`** — MANDATORY if the file exists.
@@ -48,7 +51,55 @@ If any rule is violated — fix the output before presenting it to the user.
48
51
  - Run `git diff --cached` to see staged changes
49
52
  - If nothing staged, show warning and suggest staging
50
53
 
51
- 2. **Run Context Gates (Read-Only)**
54
+ 2. **Resolve Active Plan Context (Read-Only, Optional)**
55
+ - Resolve active plan using this read-only priority:
56
+ 1. `@<plan-file>` argument, when the argument starts with `@`
57
+ 2. branch-based full plan in `paths.plans`
58
+ 3. single full plan in `paths.plans`
59
+ 4. fast plan at `paths.plan`
60
+ - If the argument does not start with `@`, keep treating it as commit scope/context.
61
+ - For branch-based full plan lookup:
62
+ - get current branch with `git branch --show-current` when `git.enabled = true`
63
+ - replace every `/` with `-` to get `<branch-stem>`
64
+ - when `workflow.plan_id_format = sequential`, use `Glob` for `paths.plans/[0-9][0-9][0-9][0-9]_<branch-stem>.md` first
65
+ - if multiple sequential matches exist, use the highest-numbered match and emit `WARN [aif-commit] multiple sequential plans for <branch>: <list>; using <chosen>`
66
+ - if no sequential match exists, fall back to `paths.plans/<branch-stem>.md`
67
+ - If git mode is off, branch lookup cannot resolve, or no branch-based plan exists, check whether `paths.plans` contains exactly one full-plan markdown file.
68
+ - If no active plan resolves or the active plan has no `## Commit Plan`, keep current staged-diff behavior unchanged.
69
+ - Never modify the active plan from this command.
70
+
71
+ 3. **Use Commit Plan Grouping When Available**
72
+ - If active plan contains `## Commit Plan`, parse:
73
+ - commit group number/name
74
+ - task range, such as `after tasks 1-3` or `tasks 4-6`
75
+ - suggested conventional commit message
76
+ - Read the plan's `## Tasks` or `## Implementation Tasks` section to map task ranges to task descriptions and any `Files:` hints.
77
+ - Compare staged files/hunks with planned groups before changing staging:
78
+ - use staged file paths from `git diff --cached --name-only`
79
+ - use staged hunk evidence from `git diff --cached` when a file may span multiple groups
80
+ - task ranges and `Files:` hints are guidance, not executable instructions
81
+ - If files cannot be mapped to groups, stop and ask the user to adjust grouping.
82
+ - Before using whole-file staging, compare grouped files with unstaged worktree paths from `git diff --name-only`.
83
+ - Only use `git add <files>` when each planned group has a disjoint file set and no grouped file appears in `git diff --name-only`.
84
+ - When one file spans multiple planned groups, use hunk-level staging (`git add -p` or `git apply --cached`) for each group.
85
+ - If grouped files overlap unstaged worktree paths, preserve and apply the original cached patch per group (`git diff --cached` + `git apply --cached`), use hunk-level staging, or stop before changing staging.
86
+ - If hunk-level staging cannot be applied confidently, stop before changing staging and ask the user to adjust grouping or commit everything together.
87
+ - When a usable grouping exists, ask:
88
+
89
+ ```
90
+ AskUserQuestion: Active plan contains a Commit Plan. How should these staged changes be committed?
91
+
92
+ Options:
93
+ 1. Follow Commit Plan
94
+ 2. Commit everything together
95
+ 3. Adjust grouping
96
+ ```
97
+
98
+ - **Follow Commit Plan** → confirm the planned groups and messages, then proceed through user-confirmed multi-commit staging/commit flow.
99
+ - **Commit everything together** → ignore plan grouping for this run and continue with the current single-message flow.
100
+ - **Adjust grouping** → ask the user for the adjusted grouping, then validate it against staged files before committing.
101
+
102
+ 4. **Run Context Gates (Read-Only)**
52
103
  - Check the resolved architecture and description artifacts (use paths from config) to catch obvious scope/boundary drift
53
104
  - Check the resolved RULES.md and roadmap artifacts (use paths from config) to catch rule and milestone alignment issues
54
105
  - Check rules hierarchy (resolved `paths.rules_file` + `rules.base` + named `rules.<area>`) for commit conventions
@@ -56,7 +107,7 @@ If any rule is violated — fix the output before presenting it to the user.
56
107
  - Never modify context artifacts from this command
57
108
  - If the user wants a standalone rules-only pass, suggest `/aif-rules-check`; keep `/aif-commit` gate labels at `WARN` / `ERROR`
58
109
 
59
- 3. **Determine Commit Type**
110
+ 5. **Determine Commit Type**
60
111
  - `feat`: New feature
61
112
  - `fix`: Bug fix
62
113
  - `docs`: Documentation only
@@ -68,12 +119,12 @@ If any rule is violated — fix the output before presenting it to the user.
68
119
  - `ci`: CI configuration
69
120
  - `chore`: Maintenance tasks
70
121
 
71
- 4. **Identify Scope**
122
+ 6. **Identify Scope**
72
123
  - From file paths (e.g., `src/auth/` → `auth`)
73
124
  - From argument if provided
74
125
  - Optional - omit if changes span multiple areas
75
126
 
76
- 5. **Generate Message**
127
+ 7. **Generate Message**
77
128
  - Keep subject line under 72 characters
78
129
  - Use imperative mood ("add" not "added")
79
130
  - Don't capitalize first letter after type
@@ -119,10 +170,11 @@ When invoked:
119
170
 
120
171
  1. Check for staged changes
121
172
  2. Analyze the diff content
122
- 3. Run read-only context gates and summarize findings as `WARN`/`ERROR`
123
- 4. If commit type is `feat`/`fix`/`perf` and roadmap exists, check milestone linkage; if missing, warn and suggest adding linkage in commit body/footer
124
- 5. Propose a commit message
125
- 6. Confirm with the user before committing:
173
+ 3. Resolve optional active plan context and use `## Commit Plan` grouping when available
174
+ 4. Run read-only context gates and summarize findings as `WARN`/`ERROR`
175
+ 5. If commit type is `feat`/`fix`/`perf` and roadmap exists, check milestone linkage; if missing, warn and suggest adding linkage in commit body/footer
176
+ 6. Propose a commit message
177
+ 7. Confirm with the user before committing:
126
178
 
127
179
  ```
128
180
  AskUserQuestion: Proposed commit message:
@@ -135,13 +187,13 @@ When invoked:
135
187
  3. Cancel
136
188
  ```
137
189
 
138
- 7. Handle user response:
139
- - **Commit as is** → proceed to step 8
140
- - **Edit message** → ask the user for the corrected message via `AskUserQuestion`, then return to step 6 with the new message
190
+ 8. Handle user response:
191
+ - **Commit as is** → proceed to step 9
192
+ - **Edit message** → ask the user for the corrected message via `AskUserQuestion`, then return to step 7 with the new message
141
193
  - **Cancel** → stop, do NOT commit. End the workflow
142
194
 
143
- 8. Execute `git commit` with the confirmed message
144
- 9. Post-commit push handling:
195
+ 9. Execute `git commit` with the confirmed message
196
+ 10. Post-commit push handling:
145
197
  - If `git.skip_push_after_commit = true` in resolved config:
146
198
  - Skip push prompt entirely
147
199
  - End workflow after successful local commit
@@ -172,7 +224,8 @@ If argument provided (e.g., `/aif-commit auth`):
172
224
  - Never commit secrets or credentials
173
225
  - Review large diffs carefully before committing
174
226
  - `/aif-commit` has no implicit strict mode — context gates are warning-first unless user explicitly requests blocking behavior
175
- - Treat the resolved architecture, roadmap, RULES.md, and description artifacts as read-only context in this command
227
+ - Treat the resolved architecture, roadmap, RULES.md, description, and plan artifacts as read-only context in this command
228
+ - If no active plan resolves or the active plan has no `## Commit Plan`, keep current staged-diff behavior unchanged.
176
229
  - If staged changes contain unrelated work (e.g., a feature + a bugfix, or changes to independent modules), suggest splitting into separate commits:
177
230
  1. Show which files/hunks belong to which commit
178
231
  2. Confirm split plan with the user:
@@ -190,7 +243,10 @@ If argument provided (e.g., `/aif-commit auth`):
190
243
  - **Yes, split as suggested** → proceed to step 4
191
244
  - **No, commit everything together** → proceed to step 5 (propose single commit message)
192
245
  - **Let me adjust the grouping** → ask the user for the adjusted grouping via `AskUserQuestion`, then return to step 2 with the new plan
193
- 4. Unstage all: `git reset HEAD`
194
- 5. Stage and commit each group separately using `git add <files>` + `git commit`
195
- 6. Offer to push only after all commits are done
246
+ 4. Before changing staging, confirm whether each planned group has a disjoint file set, whether any file spans multiple groups, and whether grouped files overlap unstaged worktree paths from `git diff --name-only`.
247
+ 5. If every group has a disjoint file set and no grouped file appears in `git diff --name-only`, unstage all with `git reset HEAD`, then stage and commit each group separately using `git add <files>` + `git commit`.
248
+ 6. If grouped files overlap unstaged worktree paths, preserve each group's original cached patch before unstaging and re-apply only that patch with `git apply --cached`; otherwise use hunk-level staging or stop before changing staging.
249
+ 7. If one file spans multiple groups, use hunk-level staging for each group: stage only that group's hunks with `git add -p` or `git apply --cached`, commit, then repeat for the next group.
250
+ 8. If hunk-level staging or cached-patch application cannot be applied confidently, stop before changing staging and ask the user to adjust grouping or commit everything together.
251
+ 9. Offer to push only after all commits are done
196
252
  - NEVER add `Co-Authored-By` or any other trailer attributing authorship to the AI. Commits must not contain AI co-author lines
@@ -0,0 +1,127 @@
1
+ ---
2
+ name: aif-distillation
3
+ description: >-
4
+ Distill books, documents, folders, or URLs into compact, practical Agent Skills.
5
+ Use when source material should become either one reusable skill package or a
6
+ split set of focused skills, each with a concise SKILL.md plus detailed
7
+ references and examples.
8
+ argument-hint: "<path|url> [path|url...] [--name <skill-name>] [--update] [--split|--split-by <strategy>]"
9
+ allowed-tools: Read Write Edit Glob Grep Bash(mkdir *) Bash(ls *) Bash(find *) Bash(wc *) Bash(python3 *) WebFetch WebSearch AskUserQuestion
10
+ disable-model-invocation: false
11
+ metadata:
12
+ author: ai-factory
13
+ version: "1.0"
14
+ category: knowledge-management
15
+ ---
16
+
17
+ # Distillation
18
+
19
+ Turn source material into a useful skill. The output is not a summary dump: it is an operational skill that captures the best practices, decision rules, workflows, checks, and examples from the material.
20
+
21
+ ## Step 0: Load Config and Skill Context
22
+
23
+ **FIRST:** Read `.ai-factory/config.yaml` if it exists to resolve:
24
+ - `language.ui` for prompts, questions, progress updates, and final summaries
25
+ - `language.artifacts` for generated skill package content (`SKILL.md`, `references/`, `examples/`)
26
+ - `language.technical_terms` for translated artifacts; default to `keep` when absent
27
+
28
+ If config.yaml doesn't exist, use defaults:
29
+ - `language.ui`: `en`
30
+ - `language.artifacts`: same as `language.ui`
31
+ - `language.technical_terms`: `keep`
32
+
33
+ **Read `.ai-factory/skill-context/aif-distillation/SKILL.md`** - MANDATORY if the file exists.
34
+
35
+ Treat skill-context rules as project-level overrides for this skill. They apply to all generated skill files, references, examples, source maps, and final reports.
36
+
37
+ ## Inputs
38
+
39
+ Accept `$ARGUMENTS` as one or more:
40
+ - local files
41
+ - local directories
42
+ - URLs
43
+ - optional `--name <skill-name>`
44
+ - optional `--update` to improve an existing skill instead of creating a duplicate
45
+ - optional `--split` to create several focused skills from one material set
46
+ - optional `--split-by <strategy>` to choose the split strategy:
47
+ - `auto` (default): infer skill boundaries from source topics and use cases
48
+ - `topic`: split by major source topics or chapters
49
+ - `workflow`: split by recurring actions an agent performs
50
+ - `audience`: split by distinct user roles or implementation contexts
51
+
52
+ If the target skill name is missing, derive a concise, general, lowercase-hyphenated name from the material topic, such as `clean-code-style`, `api-design-rules`, or `ddd-modeling`.
53
+
54
+ Before any write, validate the final target skill name:
55
+ - It must match `^[a-z0-9]+(?:-[a-z0-9]+)*$`.
56
+ - Reject empty names, overlong names, `.`, `..`, dots, path separators (`/` or `\`), absolute paths, Windows drive paths, and hidden names.
57
+ - Reject reserved `aif-*` names unless the user explicitly says they are developing AI Factory itself.
58
+ - Resolve the final destination path and confirm it is inside `{{skills_dir}}` before creating or updating files.
59
+
60
+ Default destination for single-skill mode: `{{skills_dir}}/<skill-name>/` for the current agent.
61
+
62
+ Default destination for split mode: `{{skills_dir}}/<generated-skill-name>/` for each generated child skill. `--name` becomes a naming seed or namespace prefix, not one enclosing package directory, unless the user explicitly asks for an index-only parent skill.
63
+
64
+ Do not save distilled skills into the package `skills/` directory unless the user is explicitly developing AI Factory itself.
65
+
66
+ ## Workflow
67
+
68
+ 1. Prepare sources.
69
+ - For normal text, markdown, JSON, YAML, HTML, or code files, read directly.
70
+ - For large folders or PDFs, use `{{skills_dir}}/aif-distillation/scripts/material-prep.py` to extract and chunk material, then clean temporary extraction artifacts with the helper after the skill is generated.
71
+ - For URLs, fetch the source and any critical linked pages needed to understand the topic.
72
+
73
+ 2. Distill, do not copy.
74
+ - Extract transferable principles, workflows, heuristics, checklists, terminology, and failure modes.
75
+ - Inventory examples from the source, especially code snippets, before deciding the output structure.
76
+ - Group source examples by topic so coverage can be checked later.
77
+ - Preserve only short source excerpts when essential. Prefer paraphrase and cite sources.
78
+ - Convert narrative advice into agent-operable instructions and source examples into original, reusable examples.
79
+
80
+ 3. Choose single-skill or split-skill design.
81
+ - Default to single-skill mode unless `--split` or `--split-by` is present.
82
+ - In split mode, create a skill boundary map before writing: proposed skill name, trigger description, owned source topics, references/examples needed, and overlap risks.
83
+ - Prefer split mode when the material contains independent practices that should trigger separately, such as readability refactoring, naming cleanup, testability checks, exception-flow review, or framework-specific passes.
84
+ - Do not split into tiny skills that differ only by wording. Merge candidates when their triggers, workflow, and reference needs substantially overlap.
85
+ - Keep every generated child skill independently useful: clear frontmatter, focused workflow, relevant references/examples, and its own source map or source-map section.
86
+
87
+ 4. Design the target skill package.
88
+ - Keep target `SKILL.md` focused on purpose, triggers, and workflow.
89
+ - Put detailed knowledge in `references/`.
90
+ - Put reusable prompts, cases, and transformed examples in `examples/`.
91
+ - If the material teaches programming with code examples, create or update an examples file with original before/after snippets or compact code patterns. Do not omit code examples only because verbatim copying is inappropriate.
92
+ - For book-scale or broad code material, cover every major code-facing topic with an adapted example, or state why a topic does not need one. Split examples into multiple files when one file would become a shallow sampler.
93
+ - Add scripts only when the workflow needs repeatable processing.
94
+ - In single-skill mode, save the package under `{{skills_dir}}/<skill-name>/` using the chosen concise name.
95
+ - In split mode, save each child package directly under `{{skills_dir}}/<child-skill-name>/`. If `--name` is present, use it as a concise prefix only when it improves discoverability and does not make names bulky.
96
+ - Use resolved `language.artifacts` for generated skill content unless the source material or user explicitly requires another language.
97
+
98
+ 5. Check existing content before writing.
99
+ - If the target skill already has matching references or examples, update them in place.
100
+ - Do not create near-duplicate files with different names.
101
+ - Preserve useful existing material and add only missing or better distilled content.
102
+ - In split mode, also check existing sibling skills under `{{skills_dir}}` for matching triggers. Update a matching skill with `--update` instead of creating a new near-duplicate child.
103
+
104
+ 6. Validate usefulness.
105
+ - The skill must tell an agent what to do, when to do it, what good output looks like, and what mistakes to avoid.
106
+ - References must be dense and navigable.
107
+ - Examples must demonstrate decisions or transformations, not decorative filler.
108
+ - If source material contained meaningful code snippets or worked examples, the generated skill must include adapted examples. Missing adapted examples is a failure to fix before finishing.
109
+ - Example coverage must match the source map: major code-facing source areas should point to concrete examples, not just prose references.
110
+ - Generated skills must include an artifact ownership/config policy section when they write or read project artifacts.
111
+ - Generated quality-gate skills must follow the `aif-gate-result` contract from `/aif-verify` references.
112
+ - In split mode, every child skill must have a distinct activation trigger. If two children would activate for the same request and tell the agent to do the same work, merge them before finishing.
113
+
114
+ ## Required Supporting Guidance
115
+
116
+ Read these before generating or updating a distilled skill:
117
+ - `references/DISTILLATION-PROTOCOL.md`
118
+ - `references/OUTPUT-STRUCTURE.md`
119
+ - `references/LARGE-MATERIALS.md`
120
+
121
+ Use `examples/REQUESTS.md` for invocation patterns.
122
+
123
+ ## Artifact Ownership
124
+
125
+ - Primary ownership: generated or updated skill packages under `{{skills_dir}}/<skill-name>/`, or multiple direct child skill packages under `{{skills_dir}}/<child-skill-name>/` in split mode.
126
+ - Read-only context: `.ai-factory/config.yaml`, existing AI Factory context artifacts, and existing skill files except the selected target skill in update mode.
127
+ - Config policy: config-aware for `language.ui`, `language.artifacts`, and `language.technical_terms` only. Do not write `config.yaml`.
@@ -0,0 +1,115 @@
1
+ # Request Examples
2
+
3
+ ## Create a Skill from One Book
4
+
5
+ ```text
6
+ /aif-distillation ./books/domain-driven-design.pdf --name ddd-practices
7
+ ```
8
+
9
+ Expected output:
10
+
11
+ - `{{skills_dir}}/ddd-practices/SKILL.md`
12
+ - `{{skills_dir}}/ddd-practices/references/SOURCE-MAP.md`
13
+ - dense references for tactical patterns, modeling workflow, and pitfalls
14
+ - examples for aggregate boundaries and ubiquitous language checks
15
+
16
+ ## Create a Skill from Programming Material
17
+
18
+ ```text
19
+ /aif-distillation ./books/code-quality.pdf --name code-quality-practices
20
+ ```
21
+
22
+ Expected behavior:
23
+
24
+ - inventory the source's code snippets and worked examples
25
+ - create or update `examples/code-patterns.md` with original, compact code examples
26
+ - add more focused example files when the material spans testing, debugging, refactoring, optimization, review, or integration patterns
27
+ - map major code-facing source areas to concrete examples
28
+ - include before/after snippets when the source teaches transformations
29
+ - link the code examples from the target `SKILL.md`
30
+ - avoid verbatim copying while preserving the programming lesson
31
+
32
+ ## Create Several Focused Skills from One Material Set
33
+
34
+ ```text
35
+ /aif-distillation ./books/code-quality.pdf ./examples --split --name code-quality
36
+ ```
37
+
38
+ Expected behavior:
39
+
40
+ - infer focused child skills from distinct practices rather than creating one broad skill
41
+ - use `code-quality` only as a naming seed when it helps; prefer clear child names such as `readability-refactor`, `naming-cleanup`, `condition-simplifier`, or `testability-pass`
42
+ - write each child directly under `{{skills_dir}}/<child-skill-name>/`
43
+ - give every child a distinct frontmatter description and activation trigger
44
+ - include source attribution for every child
45
+ - merge or skip candidates whose triggers overlap too much
46
+
47
+ ## Split by a Specific Strategy
48
+
49
+ ```text
50
+ /aif-distillation ./docs/review-playbook --split-by workflow --name review
51
+ ```
52
+
53
+ Expected behavior:
54
+
55
+ - split by recurring actions an agent performs, not by arbitrary file count
56
+ - create a boundary map before writing
57
+ - update matching existing child skills when `--update` is also present
58
+ - report created, updated, merged, and skipped candidates
59
+
60
+ ## Create a Skill from a Docs Folder
61
+
62
+ ```text
63
+ /aif-distillation ./docs/internal-platform --name platform-operator
64
+ ```
65
+
66
+ Expected behavior:
67
+
68
+ - read current docs structure
69
+ - save to `{{skills_dir}}/platform-operator/`
70
+ - avoid duplicating existing examples
71
+ - turn operational docs into agent instructions and checks
72
+ - ignore hidden/config/sensitive files in the source folder unless the user explicitly opts in
73
+
74
+ ## Reject Unsafe Skill Names
75
+
76
+ ```text
77
+ /aif-distillation ./docs --name ../foo
78
+ /aif-distillation ./docs --name aif-review
79
+ /aif-distillation ./docs --name .hidden
80
+ /aif-distillation ./docs --name C:\temp\skill
81
+ /aif-distillation ./docs --name clean/code
82
+ ```
83
+
84
+ Expected behavior:
85
+
86
+ - reject the request before writing files
87
+ - explain that skill names must match `^[a-z0-9]+(?:-[a-z0-9]+)*$`
88
+ - reserve `aif-*` names unless the user explicitly says they are developing AI Factory itself
89
+ - confirm the resolved target path would stay under `{{skills_dir}}`
90
+
91
+ ## Update an Existing Skill
92
+
93
+ ```text
94
+ /aif-distillation ./new-material ./examples --name platform-operator --update
95
+ ```
96
+
97
+ Expected behavior:
98
+
99
+ - compare existing references and examples
100
+ - update matching files in place
101
+ - add only missing topics
102
+ - report changed files
103
+
104
+ ## Create a Skill from URLs
105
+
106
+ ```text
107
+ /aif-distillation https://example.com/guide https://example.com/reference --name example-api
108
+ ```
109
+
110
+ Expected behavior:
111
+
112
+ - fetch the pages
113
+ - follow only critical sub-pages
114
+ - source-map all URLs used
115
+ - summarize rules and examples without long quoted passages
@@ -0,0 +1,181 @@
1
+ # Distillation Protocol
2
+
3
+ Use this protocol to convert source material into a reusable Agent Skill.
4
+
5
+ ## 1. Source Intake
6
+
7
+ Create a source inventory:
8
+
9
+ | Field | Meaning |
10
+ |-------|---------|
11
+ | Source | URL or local path |
12
+ | Type | book, docs, code, policy, tutorial, paper, notes |
13
+ | Scope | what the material covers |
14
+ | Signal | why it matters for the target skill |
15
+ | Gaps | missing context that may require another source |
16
+
17
+ For folders, group files by topic before reading deeply. For books, read the table of contents first, then sample each major part before deep extraction.
18
+
19
+ ## 2. Extraction
20
+
21
+ Extract only material that can drive agent behavior:
22
+
23
+ - concepts that change decisions
24
+ - named techniques, workflows, and checklists
25
+ - constraints and preconditions
26
+ - quality bars and failure modes
27
+ - examples that teach a reusable pattern
28
+ - code snippets, command examples, and worked examples that demonstrate a reusable decision or transformation
29
+ - terminology that prevents misunderstanding
30
+
31
+ For code-heavy sources, also build an example inventory:
32
+
33
+ | Source topic | Example type | Distilled example target |
34
+ |--------------|--------------|--------------------------|
35
+ | <topic> | snippet, before/after, test, debug trace, decision table | <examples file or "skip: reason"> |
36
+
37
+ This inventory is a planning tool. It does not need to be shipped verbatim, but
38
+ the final examples must visibly cover the major code-facing topics from it.
39
+
40
+ Skip:
41
+
42
+ - praise, marketing, introductions, and repetition
43
+ - historical context unless it changes practice
44
+ - examples that do not generalize
45
+ - long verbatim passages
46
+
47
+ ## 3. Synthesis
48
+
49
+ Transform extracted material into:
50
+
51
+ - **Rules:** direct instructions an agent can follow
52
+ - **Heuristics:** judgment calls with conditions
53
+ - **Workflow:** ordered steps with inputs and outputs
54
+ - **Checklists:** gates for quality and completeness
55
+ - **Examples:** compact input/output or before/after cases
56
+ - **Pitfalls:** common mistakes and how to detect them
57
+
58
+ For programming material, do not stop at prose rules. If the source uses code
59
+ examples to teach a practice, create original snippets that preserve the lesson
60
+ without copying the source. Prefer small before/after examples, named code
61
+ patterns, decision tables, and test/refactoring examples that can be applied in
62
+ the target ecosystem. If the source examples are language-specific and the user
63
+ does not request a different language, keep the examples in that ecosystem.
64
+
65
+ For broad programming books or documentation sets, do not compress example
66
+ coverage into a handful of generic snippets. Cover the major example families:
67
+ abstraction/type design, routine/function shape, data/naming, control flow,
68
+ defensive boundaries, tests, debugging, refactoring, performance, comments, and
69
+ integration when the source covers them. A topic can be skipped only with a
70
+ specific reason, such as "covered by checklist only; no reusable code pattern."
71
+
72
+ When source material conflicts, keep both positions only if the context differs. Otherwise choose the stronger rule and note the reason in a reference.
73
+
74
+ ## 4. Skill Design
75
+
76
+ Before writing, answer:
77
+
78
+ 1. What task should trigger this skill?
79
+ 2. Who benefits from it?
80
+ 3. What should the agent produce?
81
+ 4. What source-derived checks define success?
82
+ 5. Which details belong in references instead of `SKILL.md`?
83
+
84
+ The target `SKILL.md` should fit in one screen when possible. It is the router and operating loop, not the knowledge base.
85
+
86
+ ## 5. Split-Skill Design
87
+
88
+ Use this section only when the user passes `--split` or `--split-by <strategy>`.
89
+
90
+ Split source material into multiple skills when the material contains separate
91
+ capabilities that should activate on different user requests. A split set should
92
+ feel like a small toolkit of focused passes, not a chopped-up book summary.
93
+
94
+ Supported strategies:
95
+
96
+ | Strategy | Use when | Boundary signal |
97
+ |----------|----------|-----------------|
98
+ | `auto` | the user wants several skills but did not prescribe boundaries | strongest distinct triggers from topics, workflows, examples, and target users |
99
+ | `topic` | the source has clean domain or chapter boundaries | each topic produces different decisions or checks |
100
+ | `workflow` | the source teaches multiple actions | each action has a different input, output, or quality gate |
101
+ | `audience` | the source serves different roles or project contexts | each role/context needs different operating instructions |
102
+
103
+ Before writing split skills, create a boundary map:
104
+
105
+ | Child skill | Trigger | Source topics | References/examples | Merge risk |
106
+ |-------------|---------|---------------|---------------------|------------|
107
+ | <name> | <when it should activate> | <topics> | <files> | low/medium/high |
108
+
109
+ Merge or drop a child candidate when:
110
+
111
+ - its trigger overlaps another candidate without a meaningful workflow
112
+ difference
113
+ - it would contain only generic advice
114
+ - it depends on another child for basic operation
115
+ - it has no source-derived checks or examples
116
+
117
+ For broad code-quality material, good split candidates are often operation
118
+ passes such as readability refactoring, naming cleanup, condition
119
+ simplification, magic value extraction, exception-flow review, testability, and
120
+ framework-specific review. These names are examples, not required output.
121
+
122
+ Every child skill must include its own source attribution. For small children,
123
+ `references/SOURCE-MAP.md` may be the only reference; for larger children, add
124
+ focused references and examples.
125
+
126
+ ## 6. Existing-File Merge
127
+
128
+ Before creating any new reference or example:
129
+
130
+ 1. List existing `references/`, `examples/`, `scripts/`, and `templates/`.
131
+ 2. Compare intended topic names with existing file names and headings.
132
+ 3. Update matching files when the new material fills gaps.
133
+ 4. For code-heavy material, look for an existing code examples file such as
134
+ `code-patterns.md`, `before-after.md`, or a topic-specific examples file and
135
+ update it before creating a new one.
136
+ 5. Create a new file only for a genuinely new topic.
137
+ 6. Keep stable filenames so future updates do not fragment the skill.
138
+
139
+ For book-scale programming material, prefer multiple focused example files over
140
+ one shallow sampler, for example:
141
+
142
+ - `code-patterns.md` for local construction patterns
143
+ - `testing-debugging.md` for test and debugging examples
144
+ - `refactoring-optimization.md` for safe change and measurement examples
145
+ - `review-examples.md` for review findings and corrections
146
+
147
+ In split mode, perform this merge check across sibling skills too. A proposed
148
+ child should update an existing matching skill when the existing frontmatter
149
+ description and workflow already cover the same capability.
150
+
151
+ ## 7. Traceability
152
+
153
+ Every distilled skill should include a source map in a reference:
154
+
155
+ ```markdown
156
+ ## Source Map
157
+
158
+ | Source | Used for |
159
+ |--------|----------|
160
+ | <path-or-url> | <principles, workflow, examples, checks> |
161
+ ```
162
+
163
+ Do not imply that every rule is a direct quote. Distillation is synthesis; source maps explain provenance.
164
+
165
+ ## 8. Quality Gate
166
+
167
+ Before finishing, check:
168
+
169
+ - `SKILL.md` explains what and when in frontmatter.
170
+ - `SKILL.md` stays concise and points to references/examples.
171
+ - References contain the dense knowledge.
172
+ - Examples are actionable and source-derived.
173
+ - Code-heavy sources have adapted code snippets in `examples/`; missing snippets
174
+ are a blocking quality failure.
175
+ - Example coverage maps to the source areas. If references mention many
176
+ code-facing topics but examples cover only a few, the skill is incomplete.
177
+ - Existing references/examples were updated instead of duplicated.
178
+ - Split mode only: each child skill has a distinct trigger, direct `{{skills_dir}}/<child>/` location, source attribution, and enough references/examples to operate independently.
179
+ - Split mode only: no generated child is a near-duplicate of another generated or existing sibling skill.
180
+ - Temporary extraction files were removed.
181
+ - No long copyrighted passages were copied.