opencode-code-archaeology 2.0.0 → 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 (76) hide show
  1. package/.github/ISSUE_TEMPLATE/bug_report.yml +63 -0
  2. package/.github/ISSUE_TEMPLATE/feature_request.yml +48 -0
  3. package/.github/pull_request_template.md +27 -0
  4. package/.github/workflows/ci.yml +45 -0
  5. package/.github/workflows/release.yml +46 -0
  6. package/AGENTS.md +42 -10
  7. package/CHANGELOG.md +79 -0
  8. package/CONTRIBUTING.md +50 -0
  9. package/INSTALL.md +211 -0
  10. package/README.md +255 -71
  11. package/SECURITY.md +20 -0
  12. package/VERSION +1 -1
  13. package/assets/code-archaeology-banner.svg +195 -0
  14. package/commands/code-archaeology.md +7 -5
  15. package/dist/cli.d.ts +3 -0
  16. package/dist/cli.d.ts.map +1 -0
  17. package/dist/cli.js +137 -0
  18. package/dist/cli.js.map +1 -0
  19. package/dist/index.d.ts +1 -5
  20. package/dist/index.d.ts.map +1 -1
  21. package/dist/index.js +1 -17
  22. package/dist/index.js.map +1 -1
  23. package/dist/platform.d.ts +4 -0
  24. package/dist/platform.d.ts.map +1 -0
  25. package/dist/platform.js +11 -0
  26. package/dist/platform.js.map +1 -0
  27. package/dist/plugin.d.ts +3 -0
  28. package/dist/plugin.d.ts.map +1 -0
  29. package/dist/plugin.js +3 -0
  30. package/dist/plugin.js.map +1 -0
  31. package/dist/runtime.d.ts +18 -0
  32. package/dist/runtime.d.ts.map +1 -0
  33. package/dist/runtime.js +49 -0
  34. package/dist/runtime.js.map +1 -0
  35. package/dist/types.d.ts +1 -6
  36. package/dist/types.d.ts.map +1 -1
  37. package/dist/types.js.map +1 -1
  38. package/docs/ARCHITECTURE.md +123 -0
  39. package/docs/INSTALL.md +156 -0
  40. package/docs/README.md +72 -0
  41. package/docs/RELEASE.md +139 -0
  42. package/docs/SECURITY_AUDIT.md +38 -0
  43. package/docs/index.html +740 -0
  44. package/hooks/hermes/runner.ps1 +247 -0
  45. package/hooks/hermes/runner.sh +262 -0
  46. package/hooks/hermes/setup.ps1 +41 -0
  47. package/hooks/hermes/setup.sh +41 -0
  48. package/hooks/opencode/init.ps1 +83 -0
  49. package/hooks/opencode/revert-phase.ps1 +12 -0
  50. package/hooks/opencode/revert-phase.sh +3 -8
  51. package/hooks/opencode/update-expedition.ps1 +51 -0
  52. package/hooks/opencode/verify-package.sh +47 -0
  53. package/hooks/opencode/verify-phase.ps1 +35 -0
  54. package/hooks/opencode/verify-phase.sh +7 -7
  55. package/hooks/shared/command-utils.ps1 +100 -0
  56. package/package.json +41 -6
  57. package/prompts/dead_code.md +45 -0
  58. package/prompts/dependencies.md +49 -0
  59. package/prompts/discovery.md +47 -0
  60. package/prompts/dry.md +49 -0
  61. package/prompts/errors.md +52 -0
  62. package/prompts/final_verify.md +58 -0
  63. package/prompts/legacy.md +49 -0
  64. package/prompts/polish.md +48 -0
  65. package/prompts/types_consolidate.md +48 -0
  66. package/prompts/types_harden.md +51 -0
  67. package/skills/code-archaeology/SKILL.md +2 -2
  68. package/skills/hermes/INTEGRATION.md +120 -0
  69. package/skills/hermes/README.md +167 -0
  70. package/skills/hermes/code-archaeology-prompt.md +203 -0
  71. package/wiki/Expedition-Workflow.md +34 -0
  72. package/wiki/Home.md +27 -0
  73. package/wiki/Installation.md +44 -0
  74. package/wiki/Release-Process.md +31 -0
  75. package/wiki/Security-and-Safety.md +21 -0
  76. package/plugins/code-archaeology.ts +0 -8
@@ -0,0 +1,63 @@
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
@@ -0,0 +1,48 @@
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?
@@ -0,0 +1,27 @@
1
+ ## Summary
2
+
3
+ -
4
+
5
+ ## Verification
6
+
7
+ - [ ] Polish pass completed before commit, push, and PR.
8
+ - [ ] `npm run build`
9
+ - [ ] `npm run typecheck`
10
+ - [ ] `npm test`
11
+ - [ ] `npm audit --audit-level=moderate`
12
+ - [ ] `bash -n hooks/opencode/*.sh`
13
+ - [ ] `npm pack --json --dry-run`
14
+
15
+ ## Safety Checklist
16
+
17
+ - [ ] I did not commit `.archaeology/`, `.superpowers/`, secrets, logs, or local editor state.
18
+ - [ ] Restore-mode changes are backed by reviewed survey or excavate output.
19
+ - [ ] I did not remove try/catch around I/O or external input boundaries.
20
+ - [ ] I flagged uncertain type or behavior changes for review instead of guessing.
21
+
22
+ ## Docs And Release Checklist
23
+
24
+ - [ ] README, INSTALL, docs, and wiki source are updated if user behavior changed.
25
+ - [ ] CHANGELOG includes user-visible changes.
26
+ - [ ] Package metadata and npm package contents are correct for release-impacting changes.
27
+ - [ ] Version, tag, publish, and release steps are not included unless this PR is the release PR.
@@ -0,0 +1,45 @@
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
@@ -0,0 +1,46 @@
1
+ name: Release
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+
8
+ jobs:
9
+ release:
10
+ runs-on: ubuntu-latest
11
+ permissions:
12
+ contents: write
13
+ issues: write
14
+ pull-requests: write
15
+ id-token: write
16
+ steps:
17
+ - uses: actions/checkout@v4
18
+ with:
19
+ fetch-depth: 0
20
+ persist-credentials: false
21
+
22
+ - uses: actions/setup-node@v4
23
+ with:
24
+ node-version: '22'
25
+ registry-url: 'https://registry.npmjs.org'
26
+
27
+ - name: Install dependencies
28
+ run: npm ci
29
+
30
+ - name: Build
31
+ run: npm run build
32
+
33
+ - name: Type check
34
+ run: npm run typecheck
35
+
36
+ - name: Verify package
37
+ run: npm run verify:pack
38
+
39
+ - name: Test
40
+ run: npm test
41
+
42
+ - name: Release
43
+ env:
44
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
45
+ NPM_CONFIG_PROVENANCE: true
46
+ run: npx semantic-release
package/AGENTS.md CHANGED
@@ -1,27 +1,35 @@
1
1
  # Code Archaeology Agent Guide
2
2
 
3
- Code Archaeology is an OpenCode plugin for systematic codebase excavation, cataloging, and restoration.
3
+ Code Archaeology is a multi-runtime plugin for systematic codebase excavation, cataloging, and restoration. It supports both **OpenCode** and **Hermes Agent** runtimes.
4
4
 
5
5
  ## Runtime Policy
6
6
 
7
- - OpenCode is the only supported worker runtime.
7
+ - **OpenCode** is the primary interactive runtime (slash commands).
8
+ - **Hermes Agent** is the cron-based background runtime (one phase per 15-minute run).
8
9
  - The plugin operates entirely within the target repository.
9
10
  - All changes are isolated to a configurable branch (`refactor/archaeology` by default).
10
11
 
11
12
  ## Available Hooks
12
13
 
13
- Core hooks in `hooks/opencode/`:
14
- - `init.sh` — Initialize `.archaeology/` directory and session state
15
- - `verify-phase.sh` — Run tests and typecheck between phases
16
- - `revert-phase.sh` — Revert changes if a phase fails verification
17
- - `update-expedition.sh` — Update expedition status in session.json
14
+ ### OpenCode hooks (`hooks/opencode/`)
15
+ - `init.sh` / `init.ps1` — Initialize `.archaeology/` directory and session state
16
+ - `verify-phase.sh` / `verify-phase.ps1` — Run tests and typecheck between phases
17
+ - `revert-phase.sh` / `revert-phase.ps1` — Revert changes if a phase fails verification
18
+ - `update-expedition.sh` / `update-expedition.ps1` — Update expedition status in session.json
19
+
20
+ ### Hermes hooks (`hooks/hermes/`)
21
+ - `setup.sh` / `setup.ps1` — Detect Hermes capabilities and write `hermes-runtime.json`
22
+ - `runner.sh` / `runner.ps1` — Execute one expedition phase per cron run with test gates
23
+
24
+ **Platform support:** `.sh` scripts run on macOS/Linux; `.ps1` scripts run on Windows (PowerShell).
18
25
 
19
26
  ## Safety Hooks
20
27
 
21
- - `verify-phase.sh` — Mandatory test/typecheck gate between expeditions
22
- - `revert-phase.sh` — Automatic rollback on failure
28
+ - `verify-phase.sh` — Mandatory test/typecheck gate between expeditions (OpenCode)
29
+ - `revert-phase.sh` — Automatic rollback on failure (OpenCode)
30
+ - `runner.sh` — Built-in pre/post verification and auto-revert (Hermes)
23
31
 
24
- ## Workflow
32
+ ## OpenCode Workflow
25
33
 
26
34
  1. Run `hooks/opencode/init.sh` to initialize the session
27
35
  2. For each expedition:
@@ -31,6 +39,19 @@ Core hooks in `hooks/opencode/`:
31
39
  d. Run `hooks/opencode/update-expedition.sh <phase> <status> [findings]`
32
40
  3. Final verification runs all checks and generates `FINAL_CATALOG.md`
33
41
 
42
+ ## Hermes Workflow
43
+
44
+ 1. Run `hooks/hermes/setup.sh` to detect Hermes capabilities
45
+ 2. Create a Hermes cronjob (see `skills/hermes/INTEGRATION.md`)
46
+ 3. Each cron run executes **exactly ONE** phase:
47
+ a. Read `.archaeology/session.json` for current phase and mode
48
+ b. Run the phase (survey, excavate, or restore)
49
+ c. Run test/typecheck verification
50
+ d. Keep or revert changes automatically
51
+ e. Advance to next phase in `session.json`
52
+ f. **STOP** — next cron run continues
53
+ 4. After 10 phases, `FINAL_CATALOG.md` is generated
54
+
34
55
  ## Local State
35
56
 
36
57
  `.archaeology/` is runtime state and must not be committed.
@@ -42,6 +63,7 @@ Key files:
42
63
  - `FINAL_CATALOG.md` — Completed excavation summary
43
64
  - `excavation_log.txt` — `git diff --stat`
44
65
  - `patches/` — Mock patches (excavate mode)
66
+ - `hermes-runtime.json` — Hermes runtime configuration (Hermes only)
45
67
 
46
68
  ## Modes
47
69
 
@@ -63,6 +85,8 @@ Key files:
63
85
 
64
86
  ## Verification
65
87
 
88
+ ### OpenCode
89
+
66
90
  Before claiming work is complete:
67
91
 
68
92
  ```bash
@@ -70,6 +94,14 @@ bash hooks/opencode/verify-phase.sh final_verify
70
94
  bash -n hooks/opencode/*.sh
71
95
  ```
72
96
 
97
+ ### Hermes
98
+
99
+ Verification is built into `runner.sh`:
100
+
101
+ ```bash
102
+ bash hooks/hermes/runner.sh
103
+ ```
104
+
73
105
  ## Language Support
74
106
 
75
107
  | Language | Dead Code | Dependencies | Types | DRY |
package/CHANGELOG.md ADDED
@@ -0,0 +1,79 @@
1
+ # [2.2.0](https://github.com/Maleick/Code-Archaeology/compare/v2.1.0...v2.2.0) (2026-05-07)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * avoid session-sourced verification commands ([#10](https://github.com/Maleick/Code-Archaeology/issues/10)) ([9d3296d](https://github.com/Maleick/Code-Archaeology/commit/9d3296d1551ed7c97b90aca5c4be932bad5042e6))
7
+ * harden PowerShell verification hooks ([#6](https://github.com/Maleick/Code-Archaeology/issues/6)) ([ae1c1fa](https://github.com/Maleick/Code-Archaeology/commit/ae1c1fab3b1ce84872ad8217959d321e8e42266b))
8
+ * harden trusted publishing safety ([c78ee2e](https://github.com/Maleick/Code-Archaeology/commit/c78ee2e9bc75ff6554e75f848f64a3054a74344e))
9
+ * **hermes:** require operator approval for restore mode ([#8](https://github.com/Maleick/Code-Archaeology/issues/8)) ([772cd67](https://github.com/Maleick/Code-Archaeology/commit/772cd67df32f853c562fe8ed46f6d1528b477fda))
10
+ * only set completed_at when status is completed ([ebf1040](https://github.com/Maleick/Code-Archaeology/commit/ebf1040fb8a4a9ff23a40d6fa6042313e590b363))
11
+ * pass model router args safely ([#11](https://github.com/Maleick/Code-Archaeology/issues/11)) ([a7379fc](https://github.com/Maleick/Code-Archaeology/commit/a7379fcf425eab70f2906de75f0a158e7d418e85))
12
+ * secure Hermes session rewrites ([#7](https://github.com/Maleick/Code-Archaeology/issues/7)) ([55d5694](https://github.com/Maleick/Code-Archaeology/commit/55d5694684158d1ae471fed25b4f8de0706c7810))
13
+
14
+
15
+ ### Features
16
+
17
+ * Add Windows/PowerShell support ([a6b74ea](https://github.com/Maleick/Code-Archaeology/commit/a6b74ea75c1eb60263e939df3dc27fa4cc8b7a72)), closes [#4](https://github.com/Maleick/Code-Archaeology/issues/4)
18
+
19
+ # [2.1.0](https://github.com/Maleick/Code-Archaeology/compare/v2.0.2...v2.1.0) (2026-05-05)
20
+
21
+
22
+ ### Bug Fixes
23
+
24
+ * align analysis tool types ([65b19b2](https://github.com/Maleick/Code-Archaeology/commit/65b19b2b581c2e3f196f3d53886fd8dfdab23ea2))
25
+ * block invalid Hermes sessions ([aaafd4f](https://github.com/Maleick/Code-Archaeology/commit/aaafd4f0a0d6652ae92b5513caa13b2fabcab06e))
26
+ * harden Hermes install checks ([bc034cc](https://github.com/Maleick/Code-Archaeology/commit/bc034cca6cb8af88287cc3656cd72adf8a4246c1))
27
+ * remove embedded worktree and ignore .autoship/ ([400b554](https://github.com/Maleick/Code-Archaeology/commit/400b55452f96f604074d73f6eea79cf996a91aad))
28
+ * remove stale PluginServer stub ([#3](https://github.com/Maleick/Code-Archaeology/issues/3)) ([f8b15a3](https://github.com/Maleick/Code-Archaeology/commit/f8b15a306f55cfa6e036cc05e115357ec68df023)), closes [#2](https://github.com/Maleick/Code-Archaeology/issues/2)
29
+
30
+
31
+ ### Features
32
+
33
+ * **hermes:** add full Hermes Agent runtime support ([2f4ad41](https://github.com/Maleick/Code-Archaeology/commit/2f4ad41060994802c1fb3c5a480e88728838130b)), closes [#hermes-support](https://github.com/Maleick/Code-Archaeology/issues/hermes-support) [#multi-runtime](https://github.com/Maleick/Code-Archaeology/issues/multi-runtime)
34
+ * prepare v2.1.0 release ([54507d4](https://github.com/Maleick/Code-Archaeology/commit/54507d423b421535116363be86fbcba30b161d9e))
35
+ * **routing:** add intelligent model routing for free-tier priority ([a456556](https://github.com/Maleick/Code-Archaeology/commit/a45655602106933de64a0af5b63e18e6378847d7))
36
+
37
+ # Changelog
38
+
39
+ ## Unreleased
40
+
41
+ - Switched release publishing to npm trusted publishing with GitHub Actions OIDC.
42
+ - Hardened Hermes restore mode so it blocks explicitly until implemented instead of reporting a successful no-op restore.
43
+ - Changed OpenCode revert handling to preserve failed phase changes in a named git stash instead of dropping them.
44
+ - Exposed public type definitions through package exports and excluded the repo-local legacy plugin shim from npm package contents.
45
+
46
+ ## v2.1.0
47
+
48
+ - Changed `/code-archaeology` to run the full 10-phase survey chain by default without per-phase prompts.
49
+ - Kept the default OpenCode flow non-destructive: survey mode writes report artifacts under `.archaeology/` only.
50
+ - Clarified that `/code-archaeology-restore` remains the explicit command for applying source changes.
51
+ - Updated command, CLI, plugin, and release tests for the new default survey-chain behavior.
52
+
53
+ ## v2.0.3
54
+
55
+ - Hardened Hermes runner startup so clean repositories initialize `.archaeology/session.json` without requiring prior setup.
56
+ - Added clear blocked-state handling for malformed Hermes session phases instead of allowing low-level `jq` failures.
57
+ - Added invalid JSON protection for Hermes session files so corrupted state is reported without being overwritten.
58
+ - Expanded CLI `doctor` checks and tests to verify Hermes hooks and integration docs are packaged alongside OpenCode assets.
59
+ - Aligned the exported analysis-tool type contract with the documented TypeScript, JavaScript, Python, Go, and Rust tool matrix.
60
+ - Updated install documentation to cover Hermes verification and troubleshooting parity with OpenCode.
61
+
62
+ ## v2.0.2
63
+
64
+ - Added release-ready repository parity files: CI workflow, issue templates, PR template, security policy, contribution guide, and changelog.
65
+ - Added npm CLI and install documentation so users can install from npm, GitHub, or OpenCode plugin configuration paths.
66
+ - Added security audit and safety documentation covering local state, restore-mode review, dependency audit expectations, and secret-free examples.
67
+ - Prepared package metadata and package contents for npm release readiness, including docs, wiki source, assets, prompts, and release support files.
68
+
69
+ ## v2.0.1
70
+
71
+ - Committed built `dist/` artifacts so GitHub-based installs can load the plugin without requiring a local build step.
72
+ - Updated installation and auto-update documentation.
73
+ - Bumped package version to `2.0.1`.
74
+
75
+ ## v2.0.0
76
+
77
+ - Converted Code Archaeology into an OpenCode plugin.
78
+ - Added commands, hooks, policies, prompts, schema, and plugin packaging for survey, excavate, and restore workflows.
79
+ - Established the archaeology workflow for dead code, legacy cleanup, dependency mapping, type work, DRY review, error handling, and final catalog verification.
@@ -0,0 +1,50 @@
1
+ # Contributing
2
+
3
+ Thanks for improving Code Archaeology, an OpenCode plugin for systematic codebase excavation, cataloging, and restoration.
4
+
5
+ ## Local Setup
6
+
7
+ ```bash
8
+ npm install
9
+ npm run build
10
+ npm test
11
+ ```
12
+
13
+ Use Node 20 for CI parity. Node 18 or newer is supported by the package metadata.
14
+
15
+ ## Branch Policy
16
+
17
+ - Do not commit directly to `main` or `master`.
18
+ - Use a focused branch or worktree for each change.
19
+ - Keep `.archaeology/`, `.superpowers/`, `node_modules/`, logs, secrets, and editor state out of commits.
20
+ - Do not commit, tag, push, or publish release artifacts unless you are intentionally performing a reviewed release step.
21
+
22
+ ## Testing Commands
23
+
24
+ Run the most focused checks for your change, and run the release checks before release-impacting changes are merged:
25
+
26
+ ```bash
27
+ npm run build
28
+ npm run typecheck
29
+ npm test
30
+ npm audit --audit-level=moderate
31
+ bash -n hooks/opencode/*.sh
32
+ npm pack --json --dry-run
33
+ ```
34
+
35
+ If a restore-mode change modifies behavior, verify it against a disposable repository or fixture and document the result.
36
+
37
+ Before committing, pushing, or opening a PR, run a polish pass over the changed surface. Check wording, links, visuals, accessibility, package contents, and whether the repository presentation still looks complete.
38
+
39
+ ## Documentation Expectations
40
+
41
+ - Update `README.md`, `INSTALL.md`, `docs/`, or `wiki/` when installation, commands, workflow, safety, or release behavior changes.
42
+ - Keep documentation factual, concise, and ASCII.
43
+ - Do not include secrets, credentials, private repository contents, or full local runtime state.
44
+ - Preserve the safety model: survey first, excavate for mock patches, restore only after review.
45
+
46
+ ## Release Notes Expectations
47
+
48
+ - Add user-visible changes to `CHANGELOG.md`.
49
+ - Mention install or CLI changes, safety changes, package metadata changes, and migration steps when relevant.
50
+ - Do not claim a GitHub release, npm publish, tag, or Pages update happened until it has been verified.
package/INSTALL.md ADDED
@@ -0,0 +1,211 @@
1
+ # Install Code Archaeology
2
+
3
+ Code Archaeology is a multi-runtime plugin for systematic codebase excavation. It is non-destructive by default: `survey` mode writes reports only, while `restore` mode modifies code after review and verification.
4
+
5
+ ## Runtimes
6
+
7
+ - **OpenCode** — Interactive slash-command runtime (`/code-archaeology`)
8
+ - **Hermes Agent** — Cron-based background runtime (one phase per 15-minute run)
9
+
10
+ ## OpenCode Handoff
11
+
12
+ Paste this into OpenCode if you want the agent to install and verify the plugin for you:
13
+
14
+ ```text
15
+ Run `npm pack opencode-code-archaeology@2.2.0`, extract the resulting tarball, then open and follow `package/INSTALL.md` from that tarball. If you need a concrete command sequence: `npm pack opencode-code-archaeology@2.2.0 && tar -xof opencode-code-archaeology-2.2.0.tgz && cat package/INSTALL.md`.
16
+ ```
17
+
18
+ ## Prerequisites
19
+
20
+ - Node.js with npm, or Bun if your setup uses Bun package resolution.
21
+ - Git installed and available in your shell.
22
+ - A target repository with tests or type checks available before you run `restore` mode.
23
+ - For Hermes: Hermes Agent CLI or an active Hermes session.
24
+ - **Windows**: PowerShell 5.1 or later (hooks use `.ps1` scripts on Windows).
25
+
26
+ ## Recommended OpenCode Plugin Install
27
+
28
+ Add Code Archaeology to your `opencode.json` plugin array:
29
+
30
+ ```json
31
+ {
32
+ "plugin": [
33
+ "opencode-code-archaeology@2.2.0"
34
+ ]
35
+ }
36
+ ```
37
+
38
+ Restart OpenCode after editing the configuration. The command family should then be available inside your target repository:
39
+
40
+ ```text
41
+ /code-archaeology
42
+ /code-archaeology-survey
43
+ /code-archaeology-excavate
44
+ /code-archaeology-restore
45
+ ```
46
+
47
+ `/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.
48
+
49
+ ## Hermes Setup
50
+
51
+ ### 1. Install Code Archaeology CLI
52
+
53
+ ```bash
54
+ npm install -g opencode-code-archaeology@2.2.0
55
+ ```
56
+
57
+ ### 2. Setup Hermes Runtime
58
+
59
+ **macOS/Linux:**
60
+ ```bash
61
+ cd ~/projects/Code-Archaeology
62
+ bash hooks/hermes/setup.sh
63
+ ```
64
+
65
+ **Windows:**
66
+ ```powershell
67
+ cd ~/projects/Code-Archaeology
68
+ .\hooks\hermes\setup.ps1
69
+ ```
70
+
71
+ ### 3. Create Hermes Cronjob
72
+
73
+ ```bash
74
+ hermes cronjob create \
75
+ --name "code-archaeology-expedition" \
76
+ --schedule "every 15m" \
77
+ --workdir ~/projects/Code-Archaeology \
78
+ --prompt "Run one Code Archaeology expedition phase. Read .archaeology/session.json, execute current phase with verification, advance to next phase."
79
+ ```
80
+
81
+ See `skills/hermes/INTEGRATION.md` for full Hermes integration details.
82
+
83
+ ## npm Global Install
84
+
85
+ If you prefer a global package install:
86
+
87
+ ```bash
88
+ npm install -g opencode-code-archaeology@2.2.0
89
+ opencode-code-archaeology install
90
+ opencode-code-archaeology doctor
91
+ opencode-code-archaeology version
92
+ ```
93
+
94
+ Then restart OpenCode and run:
95
+
96
+ ```text
97
+ /code-archaeology
98
+ ```
99
+
100
+ ## One-Time Bun Path
101
+
102
+ If your environment supports one-time package execution through Bun:
103
+
104
+ ```bash
105
+ bunx opencode-code-archaeology@2.2.0 install
106
+ bunx opencode-code-archaeology@2.2.0 doctor
107
+ ```
108
+
109
+ Use the plugin-array install for normal OpenCode usage.
110
+
111
+ ## Verification
112
+
113
+ These checks do not require secrets:
114
+
115
+ ```bash
116
+ npm view opencode-code-archaeology version
117
+ npm view opencode-code-archaeology dist-tags
118
+ opencode-code-archaeology doctor
119
+ ```
120
+
121
+ For a local clone:
122
+
123
+ ```bash
124
+ npm install
125
+ npm run build
126
+ npm run typecheck
127
+ bash -n hooks/opencode/*.sh
128
+ bash -n hooks/hermes/*.sh
129
+ ```
130
+
131
+ **Windows:**
132
+ ```powershell
133
+ npm install
134
+ npm run build
135
+ npm run typecheck
136
+ Get-ChildItem hooks/opencode/*.ps1 | ForEach-Object { Get-Command $_.FullName }
137
+ Get-ChildItem hooks/hermes/*.ps1 | ForEach-Object { Get-Command $_.FullName }
138
+ ```
139
+
140
+ To verify command availability, restart OpenCode in a Git repository and run:
141
+
142
+ ```text
143
+ /code-archaeology
144
+ ```
145
+
146
+ The default survey chain should create `.archaeology/` reports without modifying source files or asking to proceed phase by phase.
147
+
148
+ ## Updating
149
+
150
+ For plugin-array installs, update by changing the package version to a reviewed npm release, then restart OpenCode. Do not point OpenCode at a mutable Git branch such as `main` for automatic updates.
151
+
152
+ For npm global installs:
153
+
154
+ ```bash
155
+ npm install -g opencode-code-archaeology@2.2.0
156
+ npm list -g opencode-code-archaeology --depth=0
157
+ ```
158
+
159
+ ## Troubleshooting
160
+
161
+ ### Plugin Not Loading (OpenCode)
162
+
163
+ - Confirm `opencode.json` is valid JSON.
164
+ - Confirm the plugin entry is in the top-level `plugin` array.
165
+ - Restart OpenCode after changing the config.
166
+ - Check that npm can resolve the pinned `opencode-code-archaeology` release.
167
+
168
+ ### Commands Not Found (OpenCode)
169
+
170
+ - Restart OpenCode so it reloads plugin commands.
171
+ - Confirm the package installed successfully with `npm list -g opencode-code-archaeology --depth=0` if using the global path.
172
+ - Run `/code-archaeology` from inside a Git repository, not from an empty directory.
173
+
174
+ ### Cron Not Running (Hermes)
175
+
176
+ ```bash
177
+ hermes cronjob list
178
+ hermes cronjob log code-archaeology-expedition
179
+ ```
180
+
181
+ ### Phase Blocked (Hermes)
182
+
183
+ ```bash
184
+ # Check blocker
185
+ cat .archaeology/session.json | jq '.flags.blocked_reason'
186
+
187
+ # Reset and retry
188
+ jq '.status = "running" | del(.flags.blocked_reason)' .archaeology/session.json > tmp.json && mv tmp.json .archaeology/session.json
189
+ ```
190
+
191
+ ### Stale Cache
192
+
193
+ - Remove the cached OpenCode package for `opencode-code-archaeology` if your runtime keeps one.
194
+ - Reinstall or rerun the OpenCode plugin resolution step.
195
+ - Restart OpenCode before testing again.
196
+
197
+ ### Restore Safety
198
+
199
+ - Start with `/code-archaeology` (OpenCode) or `mode = "survey"` (Hermes); it writes reports only.
200
+ - Review `.archaeology/site_survey.md` and expedition reports before restore.
201
+ - Use `/code-archaeology-excavate` (OpenCode) or `mode = "excavate"` (Hermes) for mock patches if you want another review gate.
202
+ - Run `/code-archaeology-restore` (OpenCode) or `mode = "restore"` (Hermes) only when the target repository has tests or type checks available.
203
+ - Do not commit `.archaeology/`; it is local runtime state.
204
+
205
+ ## Links
206
+
207
+ - Documentation: https://github.com/Maleick/Code-Archaeology/tree/main/docs
208
+ - Wiki: https://github.com/Maleick/Code-Archaeology/wiki
209
+ - Releases: https://github.com/Maleick/Code-Archaeology/releases
210
+ - Issues: https://github.com/Maleick/Code-Archaeology/issues
211
+ - Hermes docs: https://hermes-agent.nousresearch.com/docs