lisa-learn
npx skills add https://github.com/codyswanngt/lisa --skill lisa-learn
Agent 安装分布
Skill 文档
Lisa Learn
Analyze the git diff in a downstream project after Lisa was applied. Identify improvements the project had that Lisa overwrote, potential breakage, safe overrides, and neutral changes. Offer to upstream improvements back to Lisa templates.
This completes a feedback loop: /lisa-integration-test applies and verifies, /lisa-learn analyzes the transition for upstream opportunities, and /lisa-review-project compares static drift.
Prerequisites
This skill must be run FROM the Lisa repository directory. The target project must have Lisa applied and have uncommitted changes from a recent Lisa run.
Instructions
Step 1: Validate Environment
-
Confirm running from Lisa by checking for
src/core/lisa.ts.- If not in Lisa, error with:
This command must be run FROM the Lisa repository. Current directory does not contain src/core/lisa.ts. Usage: /lisa-learn /path/to/target-project
- If not in Lisa, error with:
-
Extract project path from
$ARGUMENTS. If not provided, ask the user:Which project would you like to analyze? Path: [user provides path] -
Validate the project path:
- Check the path exists and is a directory
- Check
.lisa-manifestexists in the project root - If missing, error with:
Project does not have Lisa applied. Expected to find: {project-path}/.lisa-manifest Did you apply Lisa to this project? Run: bun run dev {project-path}
-
Check the project has uncommitted changes:
git -C <project-path> status --porcelain- If clean (no output), stop with:
No uncommitted changes found in the project. Run `bun run dev <project-path>` first, then re-run /lisa-learn to analyze what changed.
- If clean (no output), stop with:
Step 2: Read Manifest and Detect Types
-
Read
<project-path>/.lisa-manifestline by line.- Skip lines starting with
#(comments) and empty lines - Parse format:
strategy|relative/path/to/file - Extract
strategyandrelativePathfor each entry - Store as a lookup:
{ [relativePath]: strategy }
- Skip lines starting with
-
Detect project types by checking the project filesystem:
- cdk:
cdk.jsonexists ORaws-cdkin package.json dependencies - nestjs:
nest-cli.jsonexists OR@nestjsin package.json dependencies - expo:
app.jsonexists OReas.jsonexists ORexpoin package.json dependencies - typescript:
tsconfig.jsonexists ORtypescriptin package.json dependencies - npm-package:
package.jsonwithout"private": trueAND hasmain,bin,exports, orfiles
- cdk:
-
Build the type hierarchy. Example: if
expodetected, types =[all, typescript, expo]- If no types detected, use
[all]
- If no types detected, use
Step 3: Capture Git Diff
Run these commands against the project:
git -C <project-path> diffâ full diff for modified tracked filesgit -C <project-path> diff --statâ summary of changesgit -C <project-path> status --porcelainâ identify new/untracked files (??prefix) and modified files (Mprefix)
Store the full diff output and the list of changed files for analysis.
Step 4: Correlate Diff with Manifest
For each file that appears in the git diff or status output:
- Look up the file’s strategy in the manifest (from Step 2)
- Find the Lisa source template by checking type directories in reverse hierarchy order (most specific first):
{type}/copy-overwrite/{relativePath}{type}/copy-contents/{relativePath}{type}/create-only/{relativePath}- Fall back through parent types until found
- Example for an Expo project: check
expo/âtypescript/âall/
- Record the mapping:
{ file, strategy, sourceTemplate, diff } - Flag files NOT in the manifest as “collateral changes” â these are files that Lisa didn’t directly manage but were affected (e.g., lockfiles, generated files)
Step 5: Analyze Each Changed File
Categorize each changed file based on its strategy and the nature of the diff:
| Category | Meaning | Action |
|---|---|---|
| Upstream Candidate | Project had something better that Lisa overwrote | Offer to upstream |
| Potential Breakage | Lisa’s change might break the project | Warn user |
| Safe Override | Lisa’s update is correct, project was outdated | No action needed |
| Neutral Change | Cosmetic/formatting differences | Skip |
Analysis rules by strategy:
-
copy-overwritefiles (primary targets for learning):- In the diff,
-lines = project’s old version (what was there before Lisa),+lines = Lisa’s replacement - Analyze if removed content (
-lines) represents an improvement over Lisa’s version:- Better error handling, bug fixes, additional config options, better docs â Upstream Candidate
- Project-specific config (env vars, custom paths, API keys) â Safe Override (Lisa correctly replaced)
- Formatting differences only â Neutral Change
- Check if added content (
+lines) might break the project:- Removes project-required config â Potential Breakage
- Adds conflicting settings â Potential Breakage
- In the diff,
-
copy-contentsfiles:- Only
+lines (additions are safe, they’re new content Lisa added) - Note additions but they’re typically Safe Override
- Only
-
merge/package-lisafiles (e.g.,package.json):- Check if Lisa removed or overwrote project-specific values
- Removed dependencies the project needs â Potential Breakage
- Updated versions â Safe Override
- Added governance dependencies â Safe Override
-
create-onlyfiles:- These should NOT be modified by Lisa after initial creation
- If they appear in the diff, flag as unexpected â Potential Breakage
-
Collateral changes (not in manifest):
- Lockfile changes â Neutral Change
- Other changes â investigate and categorize
Step 6: Breakage Detection (Optional)
Ask the user if they want to run verification checks:
Would you like to run typecheck/lint/test on the project to detect breakage?
1. Yes â run all checks
2. No â skip verification
If yes:
- Detect package manager from lockfile:
bun.lockbâ bunpnpm-lock.yamlâ pnpmyarn.lockâ yarnpackage-lock.jsonâ npm
- Run in order (stop at first failure):
cd <project-path> && <pm> run typecheckcd <project-path> && <pm> run lintcd <project-path> && <pm> run test
- Report results and add any failures to the Potential Breakage category
Step 7: Generate Report
Create a markdown report:
# Lisa Learn Report
**Lisa Directory:** {lisa-path}
**Target Project:** {project-path}
**Project Types:** {types}
**Project Name:** {from package.json name or directory basename}
**Generated:** {current date/time ISO}
## Summary
- **Total files changed:** X
- **Upstream Candidates:** X
- **Potential Breakage:** X
- **Safe Overrides:** X
- **Neutral Changes:** X
- **Collateral Changes:** X
## Upstream Candidates
These files had improvements that Lisa overwrote. Consider adopting them back into Lisa templates.
### {relative/path/to/file}
**Source Template:** {type}/copy-overwrite/{path}
**Strategy:** copy-overwrite
<details>
<summary>View diff (- = project's version, + = Lisa's version)</summary>
\`\`\`diff
{diff output}
\`\`\`
</details>
**Analysis:** {Why the project's version was better and what should be upstreamed}
---
[Repeat for each upstream candidate]
## Potential Breakage
These changes might break the project. Review carefully.
### {relative/path/to/file}
**Source Template:** {type}/copy-overwrite/{path}
**Strategy:** copy-overwrite
<details>
<summary>View diff</summary>
\`\`\`diff
{diff output}
\`\`\`
</details>
**Risk:** {What might break and why}
---
[Repeat for each potential breakage]
## Safe Overrides
These are correct template updates where Lisa's version is an improvement over the project's outdated version.
<details>
<summary>X files safely updated</summary>
- {file1} â {brief reason}
- {file2} â {brief reason}
</details>
## Neutral Changes
<details>
<summary>X files with cosmetic/formatting differences</summary>
- {file1}
- {file2}
</details>
## Collateral Changes
Files not in the manifest that were affected:
- {file1} â {brief description}
Step 8: Offer to Upstream
For each Upstream Candidate, offer to copy the project’s pre-Lisa version back into the corresponding Lisa template:
I found X upstream candidates. Would you like to upstream any improvements back to Lisa?
[List files with brief descriptions]
Options:
1. Upstream all candidates
2. Select specific files to upstream
3. Review candidates in detail first
4. Skip â no changes to Lisa
If the user wants to upstream:
- For each selected file, get the project’s pre-Lisa version:
git -C <project-path> show HEAD:<relativePath> - Determine the target Lisa template path from the Step 4 mapping
- Confirm with user: “Copy project’s version of
{relativePath}to{sourceTemplate}?” - If confirmed, write the pre-Lisa content to the Lisa template file using the Write tool
- Report success for each file
Step 9: Handle Breakage
If any Potential Breakage items were identified, offer options:
I found X potential breakage items. How would you like to handle them?
Options:
1. Fix in Lisa templates (upstream the fix)
2. Fix in project local overrides (*.local.* files)
3. Review each breakage item
4. Skip â handle manually later
For option 1 (fix upstream): Analyze the breakage, determine the fix, apply it to the Lisa template, and report.
For option 2 (fix in project): Identify the appropriate local override file (e.g., tsconfig.local.json, eslint.config.local.ts, jest.config.local.ts) and apply the fix there.
Important Notes
- Never auto-upstream without confirmation â always ask the user before modifying Lisa templates
- Pre-Lisa content comes from git â use
git -C <project-path> show HEAD:<path>to get the committed version before Lisa’s uncommitted changes - Preserve the most specific type directory â if a template exists in
expo/copy-overwrite/, upstream there, not toall/copy-overwrite/ - Handle missing files gracefully â if a file appears in the diff but not in the manifest, it’s a collateral change
- Compare carefully â some differences may be platform-specific (line endings, env vars) and should NOT be upstreamed
- Retry loop is bounded â if fixing breakage requires more than 3 iterations, stop and report the situation to the user
- This skill is Lisa-only â it is NOT distributed to downstream projects via
all/copy-overwrite/