@zalom/plastic 1.0.0-alpha.1 → 1.0.0-alpha.10

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.
@@ -0,0 +1,112 @@
1
+ ---
2
+ name: doctor
3
+ description: Use when diagnosing Plastic installation health, after updates, or when something seems broken. Runs checks and reports findings with fix options.
4
+ ---
5
+
6
+ # Doctor — Plastic Health Check
7
+
8
+ ## When to Use
9
+
10
+ - User invokes `/plastic:doctor`
11
+ - After `plastic:update` completes (automatically)
12
+ - When hooks aren't firing, skills aren't loading, or something seems broken
13
+ - When the user says "check plastic", "diagnose", "what's wrong with plastic"
14
+
15
+ ## Procedure
16
+
17
+ ### Step 1: Run the diagnostic script
18
+
19
+ ```bash
20
+ ruby ~/.plastic/scripts/doctor.rb --agent claude
21
+ ```
22
+
23
+ Replace `claude` with the current agent type if known (`codex`, `hermes`).
24
+
25
+ Parse the JSON output from stdout. The script is read-only and never modifies
26
+ files. Errors go to stderr.
27
+
28
+ Exit codes indicate check results, not script failure:
29
+ - `0` — all checks passed
30
+ - `1` — warnings found
31
+ - `2` — failures found
32
+
33
+ All three exit codes mean the script ran successfully. Do not treat non-zero
34
+ as an error.
35
+
36
+ ### Step 2: Determine overall status
37
+
38
+ Read the `status` field from the JSON root:
39
+
40
+ | Status | Meaning |
41
+ |--------|---------|
42
+ | `pass` | Everything is healthy |
43
+ | `warn` | Warnings found but Plastic works normally |
44
+ | `fail` | Blocking issues that prevent Plastic from operating |
45
+
46
+ ### Step 3: Fill the report template
47
+
48
+ Read `report.md` from the same directory as this SKILL.md
49
+ (`~/.plastic/skills/doctor/report.md` at runtime, or the plugin source
50
+ `skills/doctor/report.md` during development).
51
+
52
+ Group checks by category. For each category, list the checks with their
53
+ status icon and message. If a check has `details`, list them as sub-items.
54
+
55
+ Present the filled template to the user.
56
+
57
+ ### Step 4: Offer fixes (if applicable)
58
+
59
+ If any checks have `fixable: true` AND status is not `pass`:
60
+
61
+ 1. Group fixable items by category
62
+ 2. Show what each fix would do (from `fix_hint`)
63
+ 3. Ask the user: **"Fix all / Select individually / Skip"**
64
+
65
+ If no fixable issues exist, skip this step.
66
+
67
+ ### Step 5: Apply fixes
68
+
69
+ Use the `fix_hint` value to determine the correct action:
70
+
71
+ | Fix hint pattern | Agent action |
72
+ |---|---|
73
+ | "chmod +x on the listed files" | Run `chmod +x` on each file listed in `details` |
74
+ | "Create missing directory" | Run `mkdir -p` on the path |
75
+ | "Create INDEX.md with required sections" | Write INDEX.md with the 5 sections: Active, Future, Clusters, Abandoned, Completed |
76
+ | "Add missing entries to INDEX.md" | Add orphaned intents to the appropriate INDEX.md section |
77
+ | "Remove stale references from INDEX.md" | Edit INDEX.md to remove ghost references |
78
+ | "Re-run installer" | Run `npx @zalom/plastic@latest --agent` |
79
+
80
+ For fixes the agent cannot handle automatically, explain what the user needs
81
+ to do manually.
82
+
83
+ ### Step 6: Verify
84
+
85
+ After applying fixes, re-run the diagnostic script:
86
+
87
+ ```bash
88
+ ruby ~/.plastic/scripts/doctor.rb --agent claude
89
+ ```
90
+
91
+ Show the updated results.
92
+
93
+ - If all checks pass: announce success.
94
+ - If issues remain: explain what is still wrong and what the user can do.
95
+
96
+ ## Post-Update Mode
97
+
98
+ When invoked from `plastic:update` (not directly by the user):
99
+
100
+ 1. Run the diagnostic script as in Step 1.
101
+ 2. If all checks pass: show a single line — **"Health check: all clear."**
102
+ 3. If issues are found: show the full report (Steps 3-6).
103
+
104
+ This keeps the update flow clean when nothing is wrong.
105
+
106
+ ## Important Notes
107
+
108
+ - The script is **read-only**. It inspects but never modifies files.
109
+ All fixes are performed by the agent using standard tools.
110
+ - The script outputs JSON to stdout. Any diagnostic errors go to stderr.
111
+ - Non-zero exit codes mean "issues found", not "script crashed".
112
+ Always parse stdout regardless of exit code.
@@ -0,0 +1,96 @@
1
+ # Plastic Doctor Report
2
+
3
+ <!-- =======================================================================
4
+ AGENT INSTRUCTIONS -- How to fill this template
5
+ =========================================================================
6
+ 1. Run the doctor script. It outputs JSON with check results.
7
+ 2. Replace every {{placeholder}} below with the corresponding JSON value.
8
+ 3. For the category sections: the template shows ONE example section.
9
+ Repeat that pattern for each unique category in the checks array.
10
+ The six known categories and their display names are:
11
+ global_store -> "Global Store"
12
+ conventions -> "Conventions"
13
+ agent_registration -> "Agent Registration"
14
+ core_files -> "Core Files"
15
+ project_stores -> "Project Stores"
16
+ deprecations -> "Deprecations"
17
+ 4. For each check within a category, emit one line with the status icon
18
+ and the check message. If the check has non-empty details, list them
19
+ as indented sub-items.
20
+ 5. The "Fixable Issues" section should ONLY appear if at least one check
21
+ has fixable=true AND status is not "pass". Omit the entire section
22
+ otherwise.
23
+ 6. Status icons (plain text, no emoji):
24
+ pass -> [PASS]
25
+ warn -> [WARN]
26
+ fail -> [FAIL]
27
+ 7. The overall status icon in the header uses the same mapping.
28
+ 8. After filling, remove all HTML comments -- they are instructions only.
29
+ ======================================================================= -->
30
+
31
+ ## {{overall_status_icon}} Overall: {{status}} -- Plastic v{{version}}
32
+
33
+ Checked at: {{timestamp}}
34
+
35
+ ### Summary
36
+
37
+ {{pass}} passed, {{warn}} warnings, {{fail}} failed -- {{total}} checks total
38
+
39
+ ---
40
+
41
+ <!-- =====================================================================
42
+ CATEGORY SECTIONS
43
+ ======================================================================
44
+ Repeat the block below ONCE PER CATEGORY present in the checks array.
45
+ Group checks by their "category" field. Use the display name mapping
46
+ above for the heading. Within each category, list every check as a
47
+ single line: status icon + message. If a check has non-empty "details",
48
+ list each detail as an indented bullet beneath.
49
+
50
+ Example category section (for agent_registration with two checks):
51
+ ===================================================================== -->
52
+
53
+ ### Agent Registration
54
+
55
+ - [PASS] Claude Code adapter registered
56
+ - [FAIL] 2 hook scripts not executable
57
+ - ~/.claude/hooks/plastic-session-start
58
+ - ~/.claude/hooks/plastic-gate-check
59
+
60
+ <!-- =====================================================================
61
+ Repeat the above pattern for each category found in the checks array.
62
+ Only include categories that have at least one check.
63
+ Order categories as they appear in the checks array.
64
+ ===================================================================== -->
65
+
66
+ ---
67
+
68
+ <!-- =====================================================================
69
+ FIXABLE ISSUES SECTION
70
+ ======================================================================
71
+ Include this section ONLY if one or more checks have fixable=true AND
72
+ status is "warn" or "fail". If no fixable issues exist, omit everything
73
+ from the "Fixable Issues" heading through the end of the horizontal
74
+ rule that follows the table.
75
+
76
+ For each fixable check that is not "pass", emit one table row:
77
+ | status_icon | check_message | fix_hint |
78
+ ===================================================================== -->
79
+
80
+ ### Fixable Issues
81
+
82
+ | Status | Issue | Fix |
83
+ |--------|-------|-----|
84
+ | [FAIL] | 2 hook scripts not executable | chmod +x on the listed files |
85
+
86
+ <!-- =====================================================================
87
+ Repeat one row per fixable non-pass check.
88
+ ===================================================================== -->
89
+
90
+ ---
91
+
92
+ <!-- =====================================================================
93
+ FOOTER -- always include this line exactly as written.
94
+ ===================================================================== -->
95
+
96
+ Run `plastic doctor --fix` to auto-fix all fixable issues, or ask me to fix them now.
@@ -6,25 +6,62 @@ description: Use when merging a feature branch to main and tagging a release, bu
6
6
  # Releasing
7
7
 
8
8
  Merge, bump, tag, push. Annotated tags with changelogs. Semantic versioning.
9
+ Project configuration drives the workflow — no hardcoded assumptions.
9
10
 
10
11
  ## Checklist
11
12
 
12
- - [ ] All tests pass
13
+ - [ ] Read project config
14
+ - [ ] All tests pass (or verification skipped per config)
13
15
  - [ ] Merge feature branch to main
14
- - [ ] Bump version in plugin.json and marketplace.json
16
+ - [ ] Bump version in configured version files
15
17
  - [ ] Commit version bump
16
18
  - [ ] Create annotated tag
17
19
  - [ ] Push to remote with tags
20
+ - [ ] Run post-push actions (GitHub release, npm publish, etc.)
21
+ - [ ] Complete active intent
18
22
 
19
23
  ## Workflow
20
24
 
25
+ ### 0. Read Project Config
26
+
27
+ Before anything else, determine which project we are releasing and load its config.
28
+
29
+ 1. Read `~/.plastic/projects.yml` — find the project whose `path` matches the current working directory.
30
+ 2. Extract the project slug (the key under `projects:`).
31
+ 3. Read `~/.plastic/projects/{slug}/project.yml` — this contains the `release:` section.
32
+
33
+ Expected `release:` keys in project.yml:
34
+
35
+ ```yaml
36
+ release:
37
+ verify: "bin/rails test" # command to run before release
38
+ version_file: package.json # single file containing the version
39
+ version_files: # multiple files (overrides version_file)
40
+ - package.json
41
+ - .claude-plugin/plugin.json
42
+ tag_format: "v{{version}}" # tag naming pattern ({{version}} is replaced)
43
+ on_green: # actions to run after push succeeds
44
+ - github_release
45
+ - npm_publish
46
+ on_complete: commit_and_push # what to do with the version bump commit
47
+ on_red: stop # what to do if verification fails
48
+ ```
49
+
50
+ **Fallback:** If no project.yml exists or it has no `release:` section, fall back to asking the user for each step — verify command, version files, tag format, and post-push actions.
51
+
21
52
  ### 1. Verify Tests Pass
22
53
 
54
+ Run the verification command from `release.verify` in project.yml:
55
+
23
56
  ```bash
24
- ruby test/read_config_test.rb && ruby test/config_template_test.rb
57
+ # Example: release.verify = "ruby -Itest test/*_test.rb"
58
+ <verify-command-from-config>
25
59
  ```
26
60
 
27
- All tests must pass before release. Do not proceed if any fail.
61
+ - If `release.verify` is present: run it. All checks must pass before proceeding.
62
+ - If `release.verify` is absent or empty: skip verification. Log that no verify command is configured.
63
+ - If `release.on_red` is `stop`: abort the release on failure.
64
+ - If `release.on_red` is `fix_and_retry`: ask the user to fix and re-run.
28
65
 
29
66
  ### 2. Determine Version Bump
30
67
 
@@ -47,18 +84,26 @@ Always `--no-ff` to preserve branch history in the merge commit.
47
84
 
48
85
  ### 4. Bump Version
49
86
 
50
- Update ALL THREE files — they must stay in sync:
51
- - `package.json` → `"version": "X.Y.Z"`
52
- - `.claude-plugin/plugin.json` → `"version": "X.Y.Z"`
53
- - `.claude-plugin/marketplace.json` → `"version": "X.Y.Z"`
87
+ Determine which files to update from project.yml:
88
+
89
+ - If `release.version_files` is set: update ALL listed files (they must stay in sync).
90
+ - Else if `release.version_file` is set: update that single file.
91
+ - Else: ask the user which files contain the version.
92
+
93
+ Update the version string in each file, then commit:
54
94
 
55
95
  ```bash
56
- git add package.json .claude-plugin/plugin.json .claude-plugin/marketplace.json
96
+ git add <version-files>
57
97
  git commit -m "chore: bump version to X.Y.Z — [one-line summary]"
58
98
  ```
59
99
 
60
100
  ### 5. Create Annotated Tag
61
101
 
102
+ Read `release.tag_format` from project.yml to determine the tag name:
103
+
104
+ - If set (e.g. `"v{{version}}"`): replace `{{version}}` with the new version string.
105
+ - If not set: default to `vX.Y.Z`.
106
+
62
107
  Generate the changelog from commits since the last tag:
63
108
 
64
109
  ```bash
@@ -68,7 +113,7 @@ git log $(git describe --tags --abbrev=0)..HEAD --oneline --no-merges | grep -E
68
113
  Create the tag with a multi-line message:
69
114
 
70
115
  ```bash
71
- git tag -a vX.Y.Z -m "vX.Y.Z — [release name]
116
+ git tag -a <tag-name> -m "<tag-name> — [release name]
72
117
 
73
118
  - [changelog bullet points from feat/fix/refactor commits]"
74
119
  ```
@@ -79,16 +124,42 @@ git tag -a vX.Y.Z -m "vX.Y.Z — [release name]
79
124
  git push origin main --tags
80
125
  ```
81
126
 
82
- ### 7. GitHub Release
127
+ ### 7. Post-Push Actions
128
+
129
+ Read `release.on_green` from project.yml. This is a list of actions to run after a successful push. Execute each in order:
83
130
 
84
- Create a GitHub release from the tag. Use `--generate-notes` to auto-generate changelog from commits since the previous tag:
131
+ #### `github_release`
132
+
133
+ Create a GitHub release from the tag:
85
134
 
86
135
  ```bash
87
- gh release create vX.Y.Z --title "vX.Y.Z — [release name]" --generate-notes --notes-start-tag <previous-tag>
136
+ gh release create <tag-name> --title "<tag-name> — [release name]" --generate-notes --notes-start-tag <previous-tag>
88
137
  ```
89
138
 
90
139
  For the first release (no previous tag), write notes manually with `--notes "..."` instead.
91
140
 
141
+ #### `npm_publish`
142
+
143
+ Publish the package to npm:
144
+
145
+ ```bash
146
+ # For pre-release versions (0.x.y, or version contains -alpha/-beta/-rc):
147
+ npm publish --access public --tag alpha
148
+
149
+ # For stable versions (>= 1.0.0, no pre-release suffix):
150
+ npm publish --access public
151
+ ```
152
+
153
+ #### Other values
154
+
155
+ If `on_green` contains an action not listed above, log it:
156
+
157
+ ```
158
+ [releasing] Action "<action>" is configured but not yet implemented. Skipping.
159
+ ```
160
+
161
+ If `on_green` is empty or absent: skip post-push actions entirely.
162
+
92
163
  ### 8. Complete Active Intent
93
164
 
94
165
  A release IS a delivery. The active intent that drove this work must be completed as part of the release process. This is NOT optional.
@@ -100,17 +171,17 @@ A release IS a delivery. The active intent that drove this work must be complete
100
171
  c. Update `## Insights` with final observations
101
172
  d. Move from `## Active` to `## Completed` in INDEX.md (with today's date)
102
173
  e. Update clusters to show `_(completed)_`
103
- 3. Auto-commit: `cd ~/.plastic && git add . && git commit -m "feat: complete intent <ID> — delivered in v<X.Y.Z>"`
174
+ 3. Auto-commit: `cd ~/.plastic && git add . && git commit -m "feat: complete intent <ID> — delivered in <tag-name>"`
104
175
 
105
176
  **If no active intent exists for this release**, that itself is a problem — work happened outside the intent system. Log it and move on, but flag it.
106
177
 
107
178
  ## Conventions
108
179
 
109
180
  - **Annotated tags only** — `git tag -a`, never lightweight tags
110
- - **Tag format** — `vX.Y.Z` (lowercase v prefix)
111
- - **Tag message** — first line: `vX.Y.Z — [short name]`, then blank line, then bullet changelog
181
+ - **Tag format** — driven by `release.tag_format` in project.yml (default: `vX.Y.Z`)
182
+ - **Tag message** — first line: `<tag> — [short name]`, then blank line, then bullet changelog
112
183
  - **Commit prefixes** — `feat:`, `fix:`, `refactor:`, `chore:`, `docs:` (conventional commits)
113
- - **Version files** — package.json, plugin.json, and marketplace.json always match
184
+ - **Version files** — driven by project.yml; all listed files must always match
114
185
  - **Branch cleanup** — delete merged feature branches: `git branch -d <branch>`
115
186
 
116
187
  ## Retroactive Tagging
@@ -0,0 +1,114 @@
1
+ ---
2
+ name: plastic:research
3
+ description: "Research a topic for the active intent. Agent decides shallow vs deep based on scope. Produces reports in the intent's resources/ directory."
4
+ ---
5
+
6
+ # Research
7
+
8
+ Investigate a topic related to the active intent. Choose the right depth, produce a cited report.
9
+
10
+ **Announce at start:** "I'm researching [topic] for intent {id} — {name}."
11
+
12
+ ## Active Intent Gate
13
+
14
+ Before proceeding, resolve the active intent:
15
+
16
+ 1. **Detect store:** Read `~/.plastic/projects.yml`, match CWD against registered project paths. If match → project store at `~/.plastic/projects/{slug}/store/`. If no match → global store at `~/.plastic/store/`.
17
+ 2. **Find active intent:** Read `INDEX.md` from the detected store. Look under `## Active`. If exactly one → use it. If multiple → ask which. If none → refuse: "No active intent. Create one first with /plastic:creating-intent"
18
+ 3. **Resolve intent directory:** `{store}/store/{id}--{slug}/`
19
+
20
+ ## Depth Decision
21
+
22
+ Before starting research, assess the question against these criteria:
23
+
24
+ ### Shallow Research
25
+ Use when:
26
+ - The question is narrow and factual (e.g., "what's the API for X?", "does library Y support Z?")
27
+ - A single source or quick search is sufficient
28
+ - The answer is likely well-documented
29
+ - Time budget: minutes, not hours
30
+
31
+ **Method:** Direct web search + codebase exploration + single-pass synthesis.
32
+
33
+ ### Deep Research
34
+ Use when:
35
+ - The question needs multiple sources and cross-verification
36
+ - It's a landscape survey, competitive analysis, or architectural decision
37
+ - The user explicitly asks for thorough/exhaustive/comprehensive research
38
+ - Conflicting information exists and needs adversarial verification
39
+ - Time budget: significant, user expects depth
40
+
41
+ **Method:** Delegate to the native agent's deep research capability.
42
+ - On Claude Code: invoke the `deep-research` skill via `Skill` tool
43
+ - On other agents: use the agent's equivalent (see intent 7 for cross-agent mapping)
44
+ - If no native deep research exists: fan out multiple web searches manually, cross-reference, synthesize
45
+
46
+ ### Decision Heuristic
47
+
48
+ Ask yourself:
49
+ 1. Can I answer this with 1-2 searches? → **Shallow**
50
+ 2. Do I need to compare 3+ sources? → **Deep**
51
+ 3. Is the user asking for a survey or landscape view? → **Deep**
52
+ 4. Am I fact-checking a specific claim? → **Shallow**
53
+ 5. Could wrong information here cause architectural mistakes? → **Deep**
54
+
55
+ Announce your choice: "This needs [shallow/deep] research because [reason]."
56
+
57
+ ## Output
58
+
59
+ ### File Location
60
+ `{intent_dir}/resources/{type}--{topic}.md`
61
+
62
+ Create the resources/ directory if it doesn't exist.
63
+
64
+ ### Naming Convention
65
+ - `{type}` — one of: `deep-research`, `competitive-analysis`, `technical-spike`, `reference`, `landscape-survey`
66
+ - `{topic}` — kebab-case description of the research subject
67
+
68
+ Examples:
69
+ - `deep-research--installer-patterns.md`
70
+ - `technical-spike--sqlite-vec-performance.md`
71
+ - `reference--claude-code-hooks-api.md`
72
+ - `landscape-survey--ai-agent-ecosystem.md`
73
+
74
+ ### Report Structure
75
+
76
+ ```markdown
77
+ # {Type}: {Topic}
78
+
79
+ **Intent:** {id} — {name}
80
+ **Depth:** shallow | deep
81
+ **Date:** YYYY-MM-DD
82
+
83
+ ## Summary
84
+ [2-3 sentence executive summary]
85
+
86
+ ## Findings
87
+
88
+ ### [Finding 1 title]
89
+ [Details with inline citations where applicable]
90
+
91
+ ### [Finding 2 title]
92
+ ...
93
+
94
+ ## Sources
95
+ - [Source 1 title](url) — what was learned from this source
96
+ - [Source 2 title](url) — ...
97
+
98
+ ## Relevance to Intent
99
+ [How these findings affect the active intent's decisions or design]
100
+ ```
101
+
102
+ ## After Research
103
+
104
+ 1. Commit to store repo:
105
+ ```
106
+ cd {store_root} && git add . && git commit -m "research: {type} — {topic} (intent {id})"
107
+ ```
108
+
109
+ 2. Log in intent's `## Insights`:
110
+ ```
111
+ - Research: {type} — {topic}. Key finding: [one sentence]. See resources/{filename}.
112
+ ```
113
+
114
+ 3. Research does NOT chain to any other skill. It's a side quest — the user decides what to do with the findings.
@@ -54,13 +54,21 @@ Key changes in this version:
54
54
  Recommendation: run /clear for a clean session with all new conventions loaded.
55
55
  ```
56
56
 
57
- ### Step 4: Commit
57
+ ### Step 4: Run health check
58
+
59
+ Invoke `plastic:doctor` to verify the installation is healthy after the update.
60
+
61
+ If all checks pass, show: **"Health check: all clear."**
62
+
63
+ If issues are found, show the full doctor report and offer to fix any fixable items.
64
+
65
+ ### Step 5: Commit
58
66
 
59
67
  ```bash
60
68
  cd ~/.plastic && git add PLASTIC.md scripts/ AGENTS.md VERSION 2>/dev/null && git commit -m "chore: update Plastic core files" --allow-empty
61
69
  ```
62
70
 
63
- ### Step 5: Clear update cache
71
+ ### Step 6: Clear update cache
64
72
 
65
73
  ```bash
66
74
  rm -f ~/.plastic/.cache/update-check.json