opencode-code-archaeology 2.0.2 → 2.2.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.
Files changed (60) hide show
  1. package/AGENTS.md +42 -10
  2. package/CHANGELOG.md +66 -0
  3. package/CONTRIBUTING.md +2 -0
  4. package/INSTALL.md +90 -20
  5. package/README.md +90 -29
  6. package/VERSION +1 -1
  7. package/assets/code-archaeology-banner.svg +173 -44
  8. package/commands/code-archaeology.md +7 -5
  9. package/dist/cli.js +28 -2
  10. package/dist/cli.js.map +1 -1
  11. package/dist/index.d.ts +1 -5
  12. package/dist/index.d.ts.map +1 -1
  13. package/dist/index.js +1 -17
  14. package/dist/index.js.map +1 -1
  15. package/dist/platform.d.ts +4 -0
  16. package/dist/platform.d.ts.map +1 -0
  17. package/dist/platform.js +11 -0
  18. package/dist/platform.js.map +1 -0
  19. package/dist/plugin.d.ts +2 -2
  20. package/dist/plugin.d.ts.map +1 -1
  21. package/dist/plugin.js +2 -1
  22. package/dist/plugin.js.map +1 -1
  23. package/dist/runtime.d.ts +18 -0
  24. package/dist/runtime.d.ts.map +1 -0
  25. package/dist/runtime.js +49 -0
  26. package/dist/runtime.js.map +1 -0
  27. package/dist/types.d.ts +1 -6
  28. package/dist/types.d.ts.map +1 -1
  29. package/dist/types.js.map +1 -1
  30. package/docs/ARCHITECTURE.md +41 -10
  31. package/docs/INSTALL.md +50 -11
  32. package/docs/README.md +37 -9
  33. package/docs/RELEASE.md +20 -16
  34. package/docs/index.html +740 -0
  35. package/hooks/hermes/runner.ps1 +247 -0
  36. package/hooks/hermes/runner.sh +262 -0
  37. package/hooks/hermes/setup.ps1 +41 -0
  38. package/hooks/hermes/setup.sh +41 -0
  39. package/hooks/opencode/init.ps1 +83 -0
  40. package/hooks/opencode/revert-phase.ps1 +12 -0
  41. package/hooks/opencode/revert-phase.sh +3 -8
  42. package/hooks/opencode/update-expedition.ps1 +51 -0
  43. package/hooks/opencode/verify-package.sh +1 -0
  44. package/hooks/opencode/verify-phase.ps1 +35 -0
  45. package/hooks/opencode/verify-phase.sh +7 -7
  46. package/hooks/shared/command-utils.ps1 +100 -0
  47. package/package.json +16 -3
  48. package/skills/code-archaeology/SKILL.md +2 -2
  49. package/skills/hermes/INTEGRATION.md +120 -0
  50. package/skills/hermes/README.md +167 -0
  51. package/skills/hermes/code-archaeology-prompt.md +203 -0
  52. package/wiki/Expedition-Workflow.md +3 -1
  53. package/wiki/Home.md +2 -2
  54. package/wiki/Installation.md +2 -0
  55. package/wiki/Release-Process.md +6 -6
  56. package/.github/ISSUE_TEMPLATE/bug_report.yml +0 -63
  57. package/.github/ISSUE_TEMPLATE/feature_request.yml +0 -48
  58. package/.github/pull_request_template.md +0 -26
  59. package/.github/workflows/ci.yml +0 -45
  60. 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.2.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.2.0 --no-git-tag-version`.
11
+ 3. Update `VERSION` to `2.2.0`.
12
12
  4. Update `CHANGELOG.md` with release notes.
13
13
  5. Run verification:
14
14
 
@@ -22,10 +22,10 @@ bash -n hooks/opencode/*.sh
22
22
  npm pack --json --dry-run
23
23
  ```
24
24
 
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.
25
+ 6. Confirm the package dry run includes `dist`, `assets`, `hooks`, `commands`, `skills`, `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.2.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.2.0` show the expected release.
30
30
 
31
31
  Do not claim GitHub Pages is enabled unless repository settings confirm it.
@@ -1,63 +0,0 @@
1
- name: Bug report
2
- description: Report a problem with the Code Archaeology OpenCode plugin.
3
- title: "bug: "
4
- labels:
5
- - bug
6
- body:
7
- - type: markdown
8
- attributes:
9
- value: Thanks for helping improve Code Archaeology. Do not include secrets, private code, or full `.archaeology/` state.
10
- - type: textarea
11
- id: summary
12
- attributes:
13
- label: Summary
14
- description: What went wrong?
15
- validations:
16
- required: true
17
- - type: dropdown
18
- id: mode
19
- attributes:
20
- label: Mode
21
- options:
22
- - survey
23
- - excavate
24
- - restore
25
- - install or CLI
26
- - documentation
27
- - other
28
- validations:
29
- required: true
30
- - type: input
31
- id: version
32
- attributes:
33
- label: Version
34
- description: Package version, commit SHA, or install source.
35
- placeholder: v2.0.2
36
- - type: textarea
37
- id: steps
38
- attributes:
39
- label: Steps to reproduce
40
- placeholder: |
41
- 1. Run ...
42
- 2. See ...
43
- validations:
44
- required: true
45
- - type: textarea
46
- id: expected
47
- attributes:
48
- label: Expected behavior
49
- validations:
50
- required: true
51
- - type: textarea
52
- id: actual
53
- attributes:
54
- label: Actual behavior
55
- description: Include sanitized logs or error output when useful.
56
- validations:
57
- required: true
58
- - type: textarea
59
- id: environment
60
- attributes:
61
- label: Environment
62
- description: OS, Node version, OpenCode version, package manager, and target language.
63
- placeholder: macOS 14, Node 20, OpenCode ..., npm ..., TypeScript
@@ -1,48 +0,0 @@
1
- name: Feature request
2
- description: Suggest an improvement for the Code Archaeology OpenCode plugin.
3
- title: "feat: "
4
- labels:
5
- - enhancement
6
- body:
7
- - type: markdown
8
- attributes:
9
- value: Please focus on the user workflow and safety impact. Do not include private repository contents.
10
- - type: textarea
11
- id: problem
12
- attributes:
13
- label: Problem
14
- description: What workflow or limitation should this improve?
15
- validations:
16
- required: true
17
- - type: textarea
18
- id: proposal
19
- attributes:
20
- label: Proposed solution
21
- description: What should Code Archaeology do differently?
22
- validations:
23
- required: true
24
- - type: dropdown
25
- id: area
26
- attributes:
27
- label: Area
28
- options:
29
- - survey reporting
30
- - excavate mock patches
31
- - restore safety
32
- - language support
33
- - CLI or install
34
- - documentation
35
- - CI or release
36
- - other
37
- validations:
38
- required: true
39
- - type: textarea
40
- id: alternatives
41
- attributes:
42
- label: Alternatives considered
43
- description: Any workaround or simpler approach?
44
- - type: textarea
45
- id: safety
46
- attributes:
47
- label: Safety considerations
48
- description: Could this modify user code, expose local state, or affect restore behavior?
@@ -1,26 +0,0 @@
1
- ## Summary
2
-
3
- -
4
-
5
- ## Verification
6
-
7
- - [ ] `npm run build`
8
- - [ ] `npm run typecheck`
9
- - [ ] `npm test`
10
- - [ ] `npm audit --audit-level=moderate`
11
- - [ ] `bash -n hooks/opencode/*.sh`
12
- - [ ] `npm pack --json --dry-run`
13
-
14
- ## Safety Checklist
15
-
16
- - [ ] I did not commit `.archaeology/`, `.superpowers/`, secrets, logs, or local editor state.
17
- - [ ] Restore-mode changes are backed by reviewed survey or excavate output.
18
- - [ ] I did not remove try/catch around I/O or external input boundaries.
19
- - [ ] I flagged uncertain type or behavior changes for review instead of guessing.
20
-
21
- ## Docs And Release Checklist
22
-
23
- - [ ] README, INSTALL, docs, and wiki source are updated if user behavior changed.
24
- - [ ] CHANGELOG includes user-visible changes.
25
- - [ ] Package metadata and npm package contents are correct for release-impacting changes.
26
- - [ ] Version, tag, publish, and release steps are not included unless this PR is the release PR.
@@ -1,45 +0,0 @@
1
- name: CI
2
-
3
- on:
4
- push:
5
- branches:
6
- - main
7
- pull_request:
8
- branches:
9
- - main
10
-
11
- jobs:
12
- verify:
13
- name: Verify
14
- runs-on: ubuntu-latest
15
-
16
- steps:
17
- - name: Checkout
18
- uses: actions/checkout@v4
19
-
20
- - name: Setup Node.js
21
- uses: actions/setup-node@v4
22
- with:
23
- node-version: 20
24
- cache: npm
25
-
26
- - name: Install dependencies
27
- run: npm ci
28
-
29
- - name: Build
30
- run: npm run build
31
-
32
- - name: Typecheck
33
- run: npm run typecheck
34
-
35
- - name: Test
36
- run: npm test
37
-
38
- - name: Audit dependencies
39
- run: npm audit --audit-level=moderate
40
-
41
- - name: Check shell hook syntax
42
- run: bash -n hooks/opencode/*.sh
43
-
44
- - name: Validate npm package contents
45
- run: npm pack --json --dry-run
@@ -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";