opencode-code-archaeology 2.0.2 → 2.2.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 (58) hide show
  1. package/.github/pull_request_template.md +1 -0
  2. package/.github/workflows/release.yml +46 -0
  3. package/AGENTS.md +42 -10
  4. package/CHANGELOG.md +59 -0
  5. package/CONTRIBUTING.md +2 -0
  6. package/INSTALL.md +90 -20
  7. package/README.md +90 -29
  8. package/VERSION +1 -1
  9. package/assets/code-archaeology-banner.svg +173 -44
  10. package/commands/code-archaeology.md +7 -5
  11. package/dist/cli.js +28 -2
  12. package/dist/cli.js.map +1 -1
  13. package/dist/index.d.ts +1 -5
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.js +1 -17
  16. package/dist/index.js.map +1 -1
  17. package/dist/platform.d.ts +4 -0
  18. package/dist/platform.d.ts.map +1 -0
  19. package/dist/platform.js +11 -0
  20. package/dist/platform.js.map +1 -0
  21. package/dist/plugin.d.ts +2 -2
  22. package/dist/plugin.d.ts.map +1 -1
  23. package/dist/plugin.js +2 -1
  24. package/dist/plugin.js.map +1 -1
  25. package/dist/runtime.d.ts +18 -0
  26. package/dist/runtime.d.ts.map +1 -0
  27. package/dist/runtime.js +49 -0
  28. package/dist/runtime.js.map +1 -0
  29. package/dist/types.d.ts +1 -6
  30. package/dist/types.d.ts.map +1 -1
  31. package/dist/types.js.map +1 -1
  32. package/docs/ARCHITECTURE.md +41 -10
  33. package/docs/INSTALL.md +50 -11
  34. package/docs/README.md +37 -9
  35. package/docs/RELEASE.md +20 -16
  36. package/docs/index.html +740 -0
  37. package/hooks/hermes/runner.ps1 +247 -0
  38. package/hooks/hermes/runner.sh +262 -0
  39. package/hooks/hermes/setup.ps1 +41 -0
  40. package/hooks/hermes/setup.sh +41 -0
  41. package/hooks/opencode/init.ps1 +83 -0
  42. package/hooks/opencode/revert-phase.ps1 +12 -0
  43. package/hooks/opencode/revert-phase.sh +3 -8
  44. package/hooks/opencode/update-expedition.ps1 +51 -0
  45. package/hooks/opencode/verify-package.sh +1 -0
  46. package/hooks/opencode/verify-phase.ps1 +35 -0
  47. package/hooks/opencode/verify-phase.sh +7 -7
  48. package/hooks/shared/command-utils.ps1 +100 -0
  49. package/package.json +16 -2
  50. package/skills/code-archaeology/SKILL.md +2 -2
  51. package/skills/hermes/INTEGRATION.md +120 -0
  52. package/skills/hermes/README.md +167 -0
  53. package/skills/hermes/code-archaeology-prompt.md +203 -0
  54. package/wiki/Expedition-Workflow.md +3 -1
  55. package/wiki/Home.md +2 -2
  56. package/wiki/Installation.md +2 -0
  57. package/wiki/Release-Process.md +5 -5
  58. package/plugins/code-archaeology.ts +0 -8
@@ -0,0 +1,203 @@
1
+ ---
2
+ name: code-archaeology-hermes
3
+ description: Code Archaeology expedition runner for Hermes Agent — systematic codebase excavation with test-gated phases.
4
+ trigger: When running Code Archaeology on Hermes Agent via cronjob.
5
+ ---
6
+
7
+ # Code Archaeology Hermes Skill
8
+
9
+ ## One Phase Per Cron Run
10
+
11
+ Each cron run executes exactly ONE expedition phase. Do not combine phases.
12
+
13
+ ## Phase Detection (run FIRST)
14
+
15
+ ```bash
16
+ cd {{workdir}}
17
+ if [ -f .archaeology/session.json ]; then
18
+ phase=$(jq -r '.current_phase' .archaeology/session.json)
19
+ mode=$(jq -r '.mode' .archaeology/session.json)
20
+ status=$(jq -r '.status' .archaeology/session.json)
21
+ else
22
+ phase="site-survey"
23
+ mode="survey"
24
+ status="running"
25
+ fi
26
+ ```
27
+
28
+ **Decision tree:**
29
+ - `status` = "complete" → **STOP** (all phases done)
30
+ - `status` = "blocked" → **STOP** (report blocker)
31
+ - `phase` = "site-survey" → **Phase 1**
32
+ - `phase` = "dead-code" → **Phase 2**
33
+ - `phase` = "legacy-removal" → **Phase 3**
34
+ - `phase` = "dependency-mapping" → **Phase 4**
35
+ - `phase` = "type-consolidation" → **Phase 5**
36
+ - `phase` = "type-hardening" → **Phase 6**
37
+ - `phase` = "dry-stratification" → **Phase 7**
38
+ - `phase` = "error-handling" → **Phase 8**
39
+ - `phase` = "artifact-cleaning" → **Phase 9**
40
+ - `phase` = "final-catalog" → **Phase 10**
41
+
42
+ ## Expedition Phases
43
+
44
+ ### Phase 1: Site Survey & Baseline
45
+
46
+ 1. Create `.archaeology/` directory if missing
47
+ 2. Generate `site_survey.md` — baseline inventory of codebase
48
+ 3. Record: file count, language distribution, test coverage, dependencies
49
+ 4. **No code changes**
50
+
51
+ **STOP after survey.** Next run: Phase 2.
52
+
53
+ ### Phase 2: Dead Code Excavation
54
+
55
+ 1. Catalog dead code, unused exports, unreachable functions
56
+ 2. Generate `expedition2-report.md` with findings
57
+ 3. **Mode = survey**: reports only
58
+ 4. **Mode = restore**: remove dead code (test-gated)
59
+
60
+ **STOP after catalog.** Next run: Phase 3.
61
+
62
+ ### Phase 3: Legacy Stratum Removal
63
+
64
+ 1. Identify legacy fallbacks, deprecated shims, compatibility layers
65
+ 2. Generate `expedition3-report.md`
66
+ 3. **Never remove try/catch from I/O boundaries**
67
+ 4. **Mode = restore**: remove approved legacy code (test-gated)
68
+
69
+ **STOP after identification.** Next run: Phase 4.
70
+
71
+ ### Phase 4: Circular Dependency Cartography
72
+
73
+ 1. Map circular dependencies using language-specific tools
74
+ 2. Generate `expedition4-report.md` with dependency graph
75
+ 3. **No code changes** (mapping only)
76
+
77
+ **STOP after mapping.** Next run: Phase 5.
78
+
79
+ ### Phase 5: Type Catalog Consolidation
80
+
81
+ 1. Find duplicate type definitions
82
+ 2. Generate `expedition5-report.md`
83
+ 3. **Only run AFTER dead code and legacy removal**
84
+ 4. **Mode = restore**: consolidate types (test-gated)
85
+
86
+ **STOP after catalog.** Next run: Phase 6.
87
+
88
+ ### Phase 6: Type Restoration & Hardening
89
+
90
+ 1. Identify weak types without guessing replacements
91
+ 2. Generate `expedition6-report.md`
92
+ 3. Flag uncertain replacements for human review
93
+ 4. **Mode = restore**: harden approved types (test-gated)
94
+
95
+ **STOP after identification.** Next run: Phase 7.
96
+
97
+ ### Phase 7: DRY Stratification
98
+
99
+ 1. Find semantic duplication and error-handling slop
100
+ 2. Generate `expedition7-report.md`
101
+ 3. **Preserve I/O boundaries**
102
+ 4. **Mode = restore**: DRY approved code (test-gated)
103
+
104
+ **STOP after analysis.** Next run: Phase 8.
105
+
106
+ ### Phase 8: Error Handling Stratigraphy
107
+
108
+ 1. Review error-handling patterns
109
+ 2. Generate `expedition8-report.md`
110
+ 3. **Never remove try/catch from I/O or external input boundaries**
111
+ 4. **Mode = restore**: improve approved error handling (test-gated)
112
+
113
+ **STOP after review.** Next run: Phase 9.
114
+
115
+ ### Phase 9: Artifact Cleaning & Documentation
116
+
117
+ 1. Identify stale artifacts and documentation gaps
118
+ 2. Generate `expedition9-report.md`
119
+ 3. Clean approved artifacts (test-gated)
120
+
121
+ **STOP after cleaning.** Next run: Phase 10.
122
+
123
+ ### Phase 10: Site Preservation & Final Catalog
124
+
125
+ 1. Generate `FINAL_CATALOG.md` — complete excavation summary
126
+ 2. Run final verification (all tests + typecheck)
127
+ 3. Update session.json: `status = "complete"`
128
+
129
+ **STOP. Expedition complete.**
130
+
131
+ ## Verification (between phases)
132
+
133
+ ```bash
134
+ # Pre-phase: ensure clean state
135
+ {{test_command}}
136
+ {{typecheck_command}}
137
+
138
+ # Post-phase (restore mode only): verify changes
139
+ {{test_command}}
140
+ {{typecheck_command}}
141
+ ```
142
+
143
+ **If verification fails:**
144
+ 1. Revert changes: `git reset --hard HEAD`
145
+ 2. Update session: `status = "blocked"`, `blocked_reason = "..."`
146
+ 3. Report blocker and STOP
147
+
148
+ ## Mode Behavior
149
+
150
+ | Mode | Action | File Changes? |
151
+ |------|--------|---------------|
152
+ | **survey** | Generate reports only | None outside `.archaeology/` |
153
+ | **excavate** | Reports + mock patches | None outside `.archaeology/patches/` |
154
+ | **restore** | Apply approved changes | Yes, test-gated |
155
+
156
+ ## Rules
157
+
158
+ - **One phase per cron run** — never combine
159
+ - **Fixed order** — never skip phases
160
+ - **Survey first** — always generate reports before changes
161
+ - **Test gates** — run tests between every phase
162
+ - **Auto-revert** — revert on any verification failure
163
+ - **Preserve I/O** — never remove try/catch from boundaries
164
+ - **No guessing** — flag uncertain types for human review
165
+ - **Use [SILENT]** for no-op phases
166
+
167
+ ## Context Variables
168
+
169
+ | Variable | Source |
170
+ |----------|--------|
171
+ | `{{workdir}}` | Cronjob `workdir` setting |
172
+ | `{{mode}}` | session.json (survey/excavate/restore) |
173
+ | `{{test_command}}` | session.json |
174
+ | `{{typecheck_command}}` | session.json |
175
+ | `{{branch_name}}` | session.json (default: refactor/archaeology) |
176
+ | `{{language}}` | session.json (default: typescript) |
177
+
178
+ ## Language Tool Mapping
179
+
180
+ | Language | Dead Code | Dependencies | Types | DRY |
181
+ |----------|-----------|--------------|-------|-----|
182
+ | TypeScript | `knip` | `madge` | `tsc` | `jscpd` |
183
+ | JavaScript | `knip` | `madge` | N/A | `jscpd` |
184
+ | Python | `vulture` | `pydeps` | `mypy` | `pylint` |
185
+ | Go | `deadcode` | `godepgraph` | `go vet` | `golangci-lint` |
186
+ | Rust | `cargo-udeps` | `cargo-deps` | `rustc` | `clippy` |
187
+
188
+ ## STOP Conditions
189
+
190
+ - All 10 phases complete
191
+ - Verification fails (blocked)
192
+ - `stop_requested` flag set
193
+ - Human review required (strict mode findings)
194
+
195
+ ## Next Steps After Complete
196
+
197
+ 1. Review `.archaeology/FINAL_CATALOG.md`
198
+ 2. Review all `expedition*-report.md` files
199
+ 3. Apply mock patches from `.archaeology/patches/` if in excavate mode
200
+ 4. Merge `refactor/archaeology` branch if in restore mode
201
+ 5. Archive `.archaeology/` directory
202
+
203
+ **Start by detecting phase from session.json. Execute exactly ONE phase with verification. STOP.**
@@ -2,7 +2,7 @@
2
2
 
3
3
  [Home](Home) | [Installation](Installation) | [Security](Security-and-Safety) | [Release](Release-Process)
4
4
 
5
- Code Archaeology runs phases in a fixed order so later changes are based on earlier evidence.
5
+ Code Archaeology runs phases in a fixed order so later changes are based on earlier evidence. In OpenCode, `/code-archaeology` runs the full 10-phase survey chain by default without per-phase prompts.
6
6
 
7
7
  1. Site Survey & Baseline
8
8
  2. Dead Code Excavation
@@ -23,6 +23,8 @@ Code Archaeology runs phases in a fixed order so later changes are based on earl
23
23
  | `excavate` | Reports plus mock patches in `.archaeology/patches/`. |
24
24
  | `restore` | Applies approved changes with verification gates. |
25
25
 
26
+ Use `/code-archaeology-restore` explicitly when you are ready to apply changes. The default `/code-archaeology` command remains survey-only and writes reports under `.archaeology/`.
27
+
26
28
  ## Local Artifacts
27
29
 
28
30
  `.archaeology/` contains `session.json`, `site_survey.md`, expedition reports, `FINAL_CATALOG.md`, `excavation_log.txt`, and optional mock patches. It is local runtime state and should not be committed.
package/wiki/Home.md CHANGED
@@ -21,7 +21,7 @@ opencode-code-archaeology version
21
21
  Restart OpenCode inside a Git repository and run:
22
22
 
23
23
  ```text
24
- /code-archaeology-survey
24
+ /code-archaeology
25
25
  ```
26
26
 
27
- Start with `survey`, review reports, then choose `excavate` for mock patches or `restore` for approved, test-gated changes.
27
+ `/code-archaeology` runs the full 10-phase survey chain without per-phase prompts, writes `.archaeology/` reports only, and makes no source-code changes. Review reports, then choose `excavate` for mock patches or `restore` for approved, test-gated changes.
@@ -23,6 +23,8 @@ Restart OpenCode. Commands should be available inside a Git repository:
23
23
  /code-archaeology-restore
24
24
  ```
25
25
 
26
+ `/code-archaeology` runs the full 10-phase survey chain by default without per-phase prompts. It writes reports under `.archaeology/` and makes no source-code changes. Use `/code-archaeology-restore` only after reviewing the reports and deciding to apply changes.
27
+
26
28
  ## npm CLI Path
27
29
 
28
30
  ```bash
@@ -2,13 +2,13 @@
2
2
 
3
3
  [Home](Home) | [Installation](Installation) | [Workflow](Expedition-Workflow) | [Security](Security-and-Safety)
4
4
 
5
- Use this checklist for future `opencode-code-archaeology` releases. `v2.0.2` is the current example version; replace it with the target version.
5
+ Use this checklist for future `opencode-code-archaeology` releases. `v2.1.0` is the current example version; replace it with the target version.
6
6
 
7
7
  ## Checklist
8
8
 
9
9
  1. Review the worktree for unrelated changes and local state.
10
- 2. Bump package files with `npm version 2.0.2 --no-git-tag-version`.
11
- 3. Update `VERSION` to `2.0.2`.
10
+ 2. Bump package files with `npm version 2.1.0 --no-git-tag-version`.
11
+ 3. Update `VERSION` to `2.1.0`.
12
12
  4. Update `CHANGELOG.md` with release notes.
13
13
  5. Run verification:
14
14
 
@@ -23,9 +23,9 @@ npm pack --json --dry-run
23
23
  ```
24
24
 
25
25
  6. Confirm the package dry run includes `dist`, `assets`, `hooks`, `commands`, `skills`, `plugins`, `schema`, `prompts`, `docs`, `wiki`, `README.md`, `INSTALL.md`, `CHANGELOG.md`, `SECURITY.md`, `CONTRIBUTING.md`, `VERSION`, `AGENTS.md`, and `LICENSE`.
26
- 7. Commit release files, tag `v2.0.2`, push the branch, and push the tag.
26
+ 7. Commit release files, tag `v2.1.0`, push the branch, and push the tag.
27
27
  8. Create the GitHub release from the tag.
28
28
  9. Publish npm with `npm publish --access public`.
29
- 10. Confirm `npm view opencode-code-archaeology version` and `gh release view v2.0.2` show the expected release.
29
+ 10. Confirm `npm view opencode-code-archaeology version` and `gh release view v2.1.0` show the expected release.
30
30
 
31
31
  Do not claim GitHub Pages is enabled unless repository settings confirm it.
@@ -1,8 +0,0 @@
1
- export {
2
- id,
3
- repoRoot,
4
- version,
5
- server,
6
- } from "../src/index.ts";
7
-
8
- export type * from "../src/types";