@h1v35/hivex 0.2.0 → 0.2.2

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 (39) hide show
  1. package/README.md +55 -163
  2. package/docs/CONTEXT.md +20 -36
  3. package/docs/README.md +6 -12
  4. package/docs/adr/0003-independent-bun-installation.md +5 -19
  5. package/docs/adr/0010-practical-knowledge-assistance.md +28 -81
  6. package/docs/adr/0011-shared-knowledge-and-selective-history.md +16 -43
  7. package/docs/guidelines/engineering.md +74 -0
  8. package/docs/procedures/self-hosted-runner.md +7 -0
  9. package/package.json +32 -11
  10. package/skills/hivex/SKILL.md +28 -92
  11. package/skills/hivex/references/markdown.md +12 -42
  12. package/src/cli/diagnostic.ts +21 -11
  13. package/src/cli.ts +46 -36
  14. package/src/documents.ts +502 -320
  15. package/src/errors.ts +8 -6
  16. package/src/implementation.ts +185 -87
  17. package/src/ingestion-units.ts +107 -64
  18. package/src/knowledge-maintenance.ts +35 -22
  19. package/src/knowledge-model.ts +386 -268
  20. package/src/knowledge-serialization.ts +239 -0
  21. package/src/knowledge-snapshot.ts +100 -77
  22. package/src/knowledge-store.ts +634 -453
  23. package/src/knowledge.ts +1001 -758
  24. package/src/markdown.ts +107 -45
  25. package/src/model/connection.ts +134 -76
  26. package/src/model/failure.ts +46 -23
  27. package/src/model/invoke.ts +346 -166
  28. package/src/model/profile.ts +201 -103
  29. package/src/model/rpc-error.ts +21 -0
  30. package/src/model/server.ts +151 -82
  31. package/src/model/thread.ts +24 -14
  32. package/src/model/transcript.ts +87 -46
  33. package/src/ordering.ts +9 -0
  34. package/src/retrieval/lexical.ts +64 -41
  35. package/src/review.ts +83 -55
  36. package/src/runtime.d.ts +4 -0
  37. package/src/snapshot-command.ts +82 -43
  38. package/src/source-relocation.ts +222 -0
  39. package/docs/engineering.md +0 -174
@@ -6,53 +6,26 @@ date: 2026-09-11
6
6
 
7
7
  # Shared knowledge snapshots and selective documentary history
8
8
 
9
- The owner accepted two changes while reviewing Compi's adoption under Hivex #17. Long ADRs mix
10
- current rules with replaced text, increasing ingestion cost and ambiguity. Keeping the derived graph
11
- only in a local store also makes each clone pay to rebuild knowledge and leaves no shared history of
12
- the interpretations used. Markdown remains authoritative; versioning a graph does not make its
13
- interpretations correct or its sources current.
9
+ The owner accepted two changes while reviewing the project under [Hivex #17](https://github.com/H1V35/hivex/issues/17). Long ADRs mix current rules with replaced text, increasing ingestion cost and ambiguity. Keeping the derived graph only in a local store also makes each clone pay to rebuild knowledge and leaves no shared history of the interpretations used. Markdown remains authoritative; versioning a graph does not make its interpretations correct or its sources current.
14
10
 
15
11
  ## Compact current decisions, preserve accessible history
16
12
 
17
- An author may move replaced decision text into a clearly historical Markdown archive, preserving the
18
- original text, dates and provenance. The current ADR retains the applicable decision, reasons,
19
- dependencies and exceptions, with links to its history and replacements. A completely superseded ADR
20
- may become a short pointer at its original path. Preserve referenced anchors or update their callers;
21
- age alone never makes a still-applicable condition obsolete.
13
+ An author may move replaced decision text into a clearly historical Markdown archive, preserving the original text, dates and provenance. The current ADR retains the applicable decision, reasons, dependencies and exceptions, with links to its history and replacements. A completely superseded ADR may become a short pointer at its original path. Preserve referenced anchors or update their callers; age alone never makes a still-applicable condition obsolete.
22
14
 
23
- `docs/archive/adr/` is Compi's chosen convention, not a required layout for every adopter. Historical
24
- sources remain explicitly available for bounded retrieval when needed. They do not become the normal
25
- ingestion backlog or enter every consultation simply because they are accessible. Hivex must respect
26
- the project's declared source scope and report unavailable necessary evidence rather than silently
27
- omitting a dependency or treating an old rule as current. The author performs documentary compaction;
28
- Hivex does not rewrite project decisions automatically.
15
+ `docs/archive/adr/` is one valid convention, not a required layout for every project. Historical sources remain explicitly available for bounded retrieval when needed. They do not become the normal ingestion backlog or enter every consultation simply because they are accessible. Hivex must respect the project's declared source scope and report unavailable necessary evidence rather than silently omitting a dependency or treating an old rule as current. The author performs documentary compaction; Hivex does not rewrite project decisions automatically.
29
16
 
30
17
  ## Share derived knowledge, keep execution state local
31
18
 
32
- The shared artifact is `.hivex/graph.json`: a portable knowledge snapshot suitable for Git, containing
33
- the reusable graph, source versions, evidence, provenance and coverage/uncertainty information. It
34
- allows inspection of what changed and reuse in another clone without regenerating an identical
35
- model output. Preserve known provenance and identify unavailable legacy metadata; do not invent it.
36
-
37
- `.hivex/knowledge.sqlite` remains the local working store for queries, incremental work, attempts,
38
- budgets and caches. `.hivex/knowledge.lock` remains local. The shared artifact does not carry process
39
- identities, locks, pending invocations or the model-response cache. Loading it must not overwrite
40
- unfinished work, erase failed attempts or reset an existing work budget.
41
-
42
- Use deterministic structural and source-version checks to distinguish reusable knowledge from stale
43
- or unavailable parts. A fresh clone should reuse matching knowledge; changed sources require only
44
- the necessary update. A snapshot may retain explicit partial or uncertain coverage. Serializing the
45
- same graph should produce a stable diff; normal read-only queries should not dirty the shared file.
46
- Snapshot operations must not trigger hidden model calls or source edits.
47
-
48
- This extends ADR 0010's portable second-brain contract and supersedes a blanket recommendation to
49
- ignore every artifact under `.hivex/`. The CLI supports explicit snapshot export/import and reuses
50
- the snapshot in a fresh clone. Configurable `history` globs keep historical sources available for
51
- focused retrieval while excluding them from ordinary ingestion.
52
- A saved snapshot alone does not complete Compi adoption; publication and process retirement follow
53
- the project's normal workflow.
54
-
55
- Delivery is tracked by [#53](https://github.com/H1V35/hivex/issues/53) (shared graph snapshot) and
56
- [#54](https://github.com/H1V35/hivex/issues/54) (selective historical sources), under
57
- [the approved extension to #17](https://github.com/H1V35/hivex/issues/17#issuecomment-5631587186).
58
- The CLI remains the existing behavioral test boundary for both independent deliveries.
19
+ The shared artifact is `.hivex/graph.json`: a portable knowledge snapshot suitable for Git, containing the reusable graph, source versions, evidence, provenance and coverage/uncertainty information. It allows inspection of what changed and reuse in another clone without regenerating an identical model output. Preserve known provenance and identify unavailable legacy metadata; do not invent it.
20
+
21
+ `.hivex/knowledge.sqlite` remains the local working store for queries, incremental work, attempts, budgets and caches. `.hivex/knowledge.lock` remains local. The shared artifact does not carry process identities, locks, pending invocations or the model-response cache. Loading it must not overwrite unfinished work, erase failed attempts or reset an existing work budget.
22
+
23
+ Use deterministic structural and source-version checks to distinguish reusable knowledge from stale or unavailable parts. A fresh clone should reuse matching knowledge; changed sources require only the necessary update. A snapshot may retain explicit partial or uncertain coverage. Serializing the same graph should produce a stable diff; normal read-only queries should not dirty the shared file. Snapshot operations must not trigger hidden model calls or source edits.
24
+
25
+ This extends ADR 0010's portable second-brain contract and supersedes a blanket recommendation to ignore every artifact under `.hivex/`. The CLI supports explicit snapshot export/import and reuses the snapshot in a fresh clone. Configurable `history` globs keep historical sources available for focused retrieval while excluding them from ordinary ingestion. A saved snapshot alone does not complete a project's rollout; publication and process retirement follow the project's normal workflow.
26
+
27
+ Delivery is tracked by [#53](https://github.com/H1V35/hivex/issues/53) (shared graph snapshot) and [#54](https://github.com/H1V35/hivex/issues/54) (selective historical sources), under [the approved extension to #17](https://github.com/H1V35/hivex/issues/17#issuecomment-5631587186). The CLI remains the existing behavioral test boundary for both independent deliveries.
28
+
29
+ ## Source relocation 2026-09-13 (#64)
30
+
31
+ An explicit source relocation keeps knowledge usable when documentation changes location. It preserves decision and relationship identities, source versions, uncertainty and existing work history. An identical move can reuse ingestion coverage without a model call. Changed content or consolidation requires the normal update/check at the destination; relocation does not approve that interpretation or make mismatched evidence current. Refuse relocation while local work is unfinished, preserve original work and model answers, and record the source/destination and versions in the operation report. Commit the exported graph with the corresponding source changes so their history remains auditable.
@@ -0,0 +1,74 @@
1
+ ---
2
+ title: Engineering workflow
3
+ status: accepted
4
+ ---
5
+
6
+ # Engineering workflow
7
+
8
+ Hivex is a TypeScript/Bun product. Modules group behavior by domain responsibility and hide internal details behind small interfaces. Do not add a second development-session orchestrator or require an adopting project's layout, tracker or product packages. Codex, Git/GitHub and CI coordinate work.
9
+
10
+ ## Development and verification
11
+
12
+ Work is issue-first in `H1V35/hivex`. New vertical work follows discovery where decisions remain open, then an agreed spec, verifiable execution tickets, implementation and code review. Reuse settled scope instead of reopening an interview. The owning repository carries the execution ticket; a cross-repository parent supplies context and coordination, not a substitute for native tracking.
13
+
14
+ Resolve the existing spec/ticket before changing code and link the PR and verification to it. Absorb review findings into the appropriate existing ticket whenever its scope permits. Open a separate issue only when strictly necessary to preserve independently actionable work, and record why it cannot be absorbed. Read-only retrieval does not need a new ticket. Specs and tickets track work and acceptance; resulting durable decisions also enter their repository authority.
15
+
16
+ Use an existing issue for an already tracked requirement. Create a branch from the current remote main, keep each PR to one coherent change and preserve commit history when merging. Never push directly to main or force-push a shared branch. Apply review findings before acceptance; an invalid review can be rerun, while an adverse finding must be resolved on its merits. Current explicit owner authorization governs whether the agent may merge.
17
+
18
+ Independent code reviewers use the coordinating agent's current model and reasoning effort. Pass that profile explicitly when the subagent default differs, and verify the effective configuration after dispatch. Do not substitute the cheaper knowledge model for code review. Routine implementation subtasks may use an explicitly authorized cheaper model; Hivex's internal knowledge extraction/checking uses the user's knowledge-model configuration independently of the development and code-review model.
19
+
20
+ Choose verification for the affected surfaces. Code changes require typechecking, lint, formatting and relevant behavior tests; documentation-only changes need formatting and checks of affected references or declared sources. Record the exact revision and the checks actually completed. A later change invalidates the affected results. Do not claim an omitted, interrupted or truncated check passed.
21
+
22
+ GitHub Actions runs the quality workflow on the owner's Mac through an official self-hosted runner, using `[self-hosted, macOS, ARM64, hivex]`. GitHub retains secrets, logs and PR checks; no hosted runner fallback is configured. No speed benchmark is required. A queued, skipped or interrupted run is not a pass. Local verification remains required when the runner is unavailable. Installation and host migration follow the [runner procedure](../procedures/self-hosted-runner.md).
23
+
24
+ Use `bun install` for development and `bun ci` for frozen installation. Bun owns dependency installation through its native configuration and lockfile; Hivex has no custom installer or registry verifier. See the [installation decision](../adr/0003-independent-bun-installation.md).
25
+
26
+ Lint uses the published Ultracite ESLint/Prettier core presets with the owner's selected preferences: maximum cyclomatic complexity 20, cognitive complexity 15, nesting depth 3 and four parameters per function; print width 100 and single quotes; unused variables, arguments and caught errors may have a leading `_`, and loose equality is allowed when comparing with `null`. Keep the rest of the presets unchanged. Naming and unused-variable checks allow the leading `_` for unused bindings. The overlapping SonarJS unused-variable rule, `no-eq-null` and optional-catch-binding preference are disabled because they cannot express those exceptions; the configured unused-variable and equality rules still check ordinary names and comparisons. Use `eslint-plugin-boundaries` to enforce actual module responsibilities and keep additional policy minimal and tied to domain behavior. Configuration and dependency versions belong in the executable project configuration. Refactor around meaningful responsibilities instead of adding wrappers to satisfy arbitrary thresholds.
27
+
28
+ The dependency policy follows the current modules: document discovery and Markdown parsing do not import knowledge, review or model execution; knowledge storage and ingestion may use documents; review may use documents and knowledge. Model execution is self-contained, retrieval may use shared errors, and CLI commands compose these responsibilities. Tests may use production modules; production cannot import tests. New source files must be classified before they can participate in these dependencies.
29
+
30
+ Runtime settings identify Bun globals and Bun executables while keeping the preset rules enabled. The browser compatibility target is the server-side JavaScript environment, not a browser application. Runtime APIs used by the code must also be verified on the supported Bun version.
31
+
32
+ ## Tests protect behavior
33
+
34
+ TDD guides development through meaningful failing examples; it does not require a test for every function, component, wrapper or line. A test must identify a supported behavior, meaningful invariant or regression it protects. Prefer the caller's observable interface and results that survive an internal refactor.
35
+
36
+ For UI, test visible content, accessibility, interactions and loading/error/empty-state behavior. Do not freeze arbitrary child arrays, wrapper counts or class/style arrangements. A visual dimension needs a test only when it is an intentional requirement worth maintaining. For example, displaying "2 of 4" is a behavior; representing it as exactly three React children is not.
37
+
38
+ Mocks, call counts, ordering and exact bytes are not automatically wrong. They can protect an external protocol, idempotency, a query budget or faithful source reproduction. Their justification must be the contract, not the current arrangement of internal helpers. Expected results must be independent examples, not the implementation's own calculation repeated in the test.
39
+
40
+ Review existing tests as retain, rewrite, consolidate or remove. Remove tests for retired behavior with that behavior; preserve still-needed guarantees at the replacement's actual interface. Do not port a legacy battery mechanically, chase a test-count target or retain duplicate suites indefinitely.
41
+
42
+ ## Files and runtime data have a lifecycle
43
+
44
+ Create a source file for a meaningful responsibility and a document for a distinct authoritative purpose. Do not create files for every helper, task, turn, attempt or handoff merely to satisfy a layout convention or a lint threshold.
45
+
46
+ Before introducing persistent state, define its purpose, location, owner and retention. Prefer a small project-local data store to an unbounded tree of per-event files. A per-unit atomic checkpoint can be a database transaction; it does not require a separate file. Fewer filenames alone do not bound data growth: cached data, run history and diagnostics also need size/count/age limits and cleanup behavior.
47
+
48
+ Normal read-only queries should leave no per-query artifacts. Clean up owned temporary resources on ordinary completion and handled failures. Interrupted work must remain recoverable without being silently retried or discarded. Export diagnostic bundles when needed rather than automatically writing a new report for every successful step. Retention must preserve the accepted state and the evidence needed by supported historical/recovery operations; it must not invent a successful cleanup.
49
+
50
+ ## Documentation is maintained authority
51
+
52
+ Code must be self-explanatory through clear names, structure and behavior. Repository Markdown is the source of truth for intent, constraints, decisions and reasons that code cannot explain. Do not write a parallel implementation manual or use documentation to compensate for unclear code. Accepted source history and Markdown retain authority; caches, model output and search hits do not. An accepted status alone does not settle amendments, exceptions or contradictions. Keep unresolved evidence explicit. Never promote a historical agent's description of an owner ruling without checking its provenance and applicability.
53
+
54
+ Capture every decision worth preserving in its appropriate repository document as part of the work. Do not leave accepted knowledge only in a conversation, issue comment or runtime log. Update the existing canonical document when it already owns the topic and scope; create a new one only when it has a distinct purpose. An issue can track the work and preserve discussion, but it is not a substitute for incorporating the resulting doctrine into the documentation.
55
+
56
+ Keep docs with the monorepo, workspace or module they describe. Link to common rules instead of copying them. Recommended new Markdown should state purpose/scope, use stable headings and suitable metadata, keep a rule with its conditions/exceptions, and link its sources and replacements. Accept compatible existing Markdown without forcing those authors to adopt our template. Do not generate empty documentation for every module or add non-Markdown readers to the current scope.
57
+
58
+ Use repository decisions and review evidence for durable knowledge, not private agent memory. Checkpoints identify the exact commit, verified work and remaining work. Choose a context handoff when the task needs it; Hivex does not impose the retired machinery's fixed token thresholds. Knowledge-model operations use the admitted Luna/max profile and record actual usage, including failed or interrupted attempts. Deterministic retrieval and maintenance do not require a model.
59
+
60
+ The replacement workflow follows [ADR 0010](../adr/0010-practical-knowledge-assistance.md). It processes bounded document batches with one additional knowledge check, keeps partial knowledge usable and preserves a work budget across phases and resumption. A consultation maintains one pending batch before answering, and a source-based repair replaces interpretations without changing doctrine. Keep check warnings scoped and public evidence limited to source coordinates, version and text. Avoid a new abstraction or protocol unless it protects a concrete requirement. The owner-authorized implementation can replace the earlier cohort/admission pipeline; its historical evidence remains unchanged.
61
+
62
+ Hivex assists the principal reviewer with decisions, dependencies, exceptions and possible conflicts. The reviewer verifies its findings. Missing context or uncertainty limits the conclusions it affects; a definitive finding must refer to the actual document and implementation versions reviewed.
63
+
64
+ ## Retire mechanisms without losing knowledge
65
+
66
+ After knowledge recovery and replacement validation, remove obsolete orchestration code, scripts, hooks, configuration, tests, dependencies and active instructions. Do not carry an unused legacy framework into Hivex under another name. Preserve useful decisions in their canonical docs and retain necessary historical evidence in Git or a bounded private archive outside the active worktree. Do not rewrite Git history or destroy the accepted Opus graph before its replacement is admitted.
67
+
68
+ A replacement workflow can be used before every historical artifact is retired when the remaining work is explicit. Complete closure requires useful historical knowledge in Markdown and obsolete active machinery retired wherever it is no longer needed. Validate the workflow against bounded real cases, not identity with an old model's graph or an exhaustive replay prerequisite. Release packages exclude private project evidence and retired runtime.
69
+
70
+ ## Distribution
71
+
72
+ The owner selected `@h1v35/hivex` for the npm package on 2026-09-08, retaining `hivex` as the installed command, and approved the MIT license. The scoped name avoids the unrelated existing unscoped npm package. Use an authenticated account authorized for that scope; do not infer npm ownership from a matching GitHub name. Release preparation must verify the packed contents and exclude private project evidence and runtime stores. Project integration follows the normal release process after the complete cycle is validated; this decision alone does not mean a package has been published.
73
+
74
+ Before publication, inspect and scan the exact package archive for secrets and unintended private content. Record its hash and the completed scan result; a repack requires a fresh check. Publish the same verified artifact, not an unchecked reconstruction from a changed working tree.
@@ -0,0 +1,7 @@
1
+ # Self-hosted GitHub Actions runner
2
+
3
+ Follow the [engineering guidelines](../guidelines/engineering.md#development-and-verification) for runner labels, execution boundaries and verification requirements.
4
+
5
+ Runner installation is repository administration, outside Hivex's product. Register the admitted macOS ARM64 release from GitHub's runner settings in its own directory, verify the official checksum, and use the generated `svc.sh install/start/status/stop` commands. Keep automatic updates enabled, a stable Homebrew/system PATH and the Mac awake and connected under the logged-in user. The runner work directory must be separate from the developer checkout and other repository runners. Only trusted code may run on this persistent host; review that boundary before public contributions. See [GitHub's runner reference](https://docs.github.com/en/actions/reference/runners/self-hosted-runners).
6
+
7
+ During a host migration, disable Actions, register and confirm the runner is online, and merge all workflow routes before re-enabling Actions. Then dispatch Quality on that exact revision and check the assigned runner and completed result. The route change alone is not functional verification.
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@h1v35/hivex",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "type": "module",
5
5
  "description": "Versioned project knowledge for people and agents.",
6
6
  "scripts": {
7
7
  "hivex": "bun src/cli.ts",
8
8
  "test": "bun test --timeout 15000 ./src",
9
9
  "typecheck": "node_modules/typescript-native/bin/tsc --noEmit",
10
- "lint": "eslint src test tooling eslint.config.js eslint.base.config.js",
10
+ "lint": "eslint src test eslint.config.js prettier.config.js",
11
11
  "format:check": "prettier --check ."
12
12
  },
13
13
  "dependencies": {
@@ -23,14 +23,31 @@
23
23
  },
24
24
  "devDependencies": {
25
25
  "@eslint/js": "10.0.1",
26
- "typescript-native": "npm:typescript@7.0.2",
27
- "@types/bun": "1.3.14",
28
- "eslint": "10.7.0",
29
- "eslint-plugin-sonarjs": "1.0.4",
30
- "globals": "16.5.0",
26
+ "@types/bun": "1.4.0",
27
+ "@typescript-eslint/eslint-plugin": "8.69.0",
28
+ "@typescript-eslint/parser": "8.69.0",
29
+ "eslint": "10.9.1",
30
+ "eslint-config-prettier": "10.1.8",
31
+ "eslint-import-resolver-typescript": "4.4.5",
32
+ "eslint-plugin-boundaries": "7.2.0",
33
+ "eslint-plugin-compat": "7.0.2",
34
+ "eslint-plugin-cypress": "7.0.1",
35
+ "eslint-plugin-github": "6.1.2",
36
+ "eslint-plugin-html": "8.2.0",
37
+ "eslint-plugin-import-x": "4.17.1",
38
+ "eslint-plugin-jsdoc": "64.3.5",
39
+ "eslint-plugin-n": "18.3.0",
40
+ "eslint-plugin-prettier": "5.5.6",
41
+ "eslint-plugin-promise": "7.3.0",
42
+ "eslint-plugin-sonarjs": "4.2.0",
43
+ "eslint-plugin-storybook": "10.6.0",
44
+ "eslint-plugin-unicorn": "74.0.0",
45
+ "eslint-plugin-unused-imports": "4.4.1",
46
+ "globals": "17.12.0",
47
+ "prettier": "3.8.4",
31
48
  "typescript": "npm:@typescript/typescript6@6.0.2",
32
- "typescript-eslint": "8.64.0",
33
- "prettier": "3.8.4"
49
+ "typescript-native": "npm:typescript@7.0.2",
50
+ "ultracite": "7.10.8"
34
51
  },
35
52
  "trustedDependencies": [],
36
53
  "packageManager": "bun@1.4.2",
@@ -46,7 +63,8 @@
46
63
  "!src/**/*.test.ts",
47
64
  "docs/README.md",
48
65
  "docs/CONTEXT.md",
49
- "docs/engineering.md",
66
+ "docs/guidelines/engineering.md",
67
+ "docs/procedures/self-hosted-runner.md",
50
68
  "docs/adr/0003-independent-bun-installation.md",
51
69
  "docs/adr/0010-practical-knowledge-assistance.md",
52
70
  "docs/adr/0011-shared-knowledge-and-selective-history.md",
@@ -61,5 +79,8 @@
61
79
  "publishConfig": {
62
80
  "access": "public",
63
81
  "registry": "https://registry.npmjs.org/"
64
- }
82
+ },
83
+ "browserslist": [
84
+ "node 25"
85
+ ]
65
86
  }
@@ -5,130 +5,66 @@ description: Retrieve project decisions and their dependencies and exceptions wi
5
5
 
6
6
  # Hivex
7
7
 
8
- Hivex gives the implementing and reviewing agents project context. Markdown is documentary
9
- authority; the graph is derived assistance. The principal agent remains responsible for the work.
10
- Recover settled decisions before asking the owner to decide them again.
8
+ Hivex gives the implementing and reviewing agents project context. Markdown is documentary authority; the graph is derived assistance. The principal agent remains responsible for the work. Recover settled decisions before asking the owner to decide them again.
11
9
 
12
10
  ## Start with the installed interface
13
11
 
14
- Read the project's agent instructions and source configuration. Run `hivex --help` when the installed
15
- interface is unfamiliar. In a Bun project, `bun hivex` resolves the installed CLI. The package is
16
- `@h1v35/hivex`; do not fetch the unrelated unscoped package.
12
+ Read the project's agent instructions and source configuration. Run `hivex --help` when the installed interface is unfamiliar. In a Bun project, `bun hivex` resolves the installed CLI. The package is `@h1v35/hivex`; do not fetch the unrelated unscoped package.
17
13
 
18
- Use the capabilities advertised by that version. Do not invent commands, silently switch models or
19
- pretend a planned capability exists. Hivex's current validated knowledge profile is Luna/max through
20
- native Codex; the principal agent's model is independent of that choice.
14
+ Use the capabilities advertised by that version. Do not invent commands, silently switch models or pretend a planned capability exists. Hivex's current validated knowledge profile is Luna/max through native Codex; the principal agent's model is independent of that choice.
21
15
 
22
- Projects may declare additional historical Markdown with `history` globs in `hivex.json`. Those
23
- sources are available to `sources` and `read`, but remain outside ordinary update and consultation
24
- selection. Use `--source <document>` with `ask` or `review` for a focused retrieval; a known graph
25
- relationship may bring back only the bounded evidence it needs. Explicit `exclude` globs still win,
26
- and the CLI continues to reject symlinks, protected directories and paths outside the project.
16
+ Projects may declare additional historical Markdown with `history` globs in `hivex.json`. Those sources are available to `sources` and `read`, but remain outside ordinary update and consultation selection. Use `--source <document>` with `ask` or `review` for a focused retrieval; a known graph relationship may bring back only the bounded evidence it needs. Explicit `exclude` globs still win, and the CLI continues to reject symlinks, protected directories and paths outside the project.
27
17
 
28
- Native Codex must be able to write its own local state. When the host sandbox prevents that,
29
- use its normal execution-approval mechanism within the existing authorized scope. Keep a failed
30
- launch in the same work history when resuming; an initialization failure is not a model verdict.
18
+ Native Codex must be able to write its own local state. When the host sandbox prevents that, use its normal execution-approval mechanism within the existing authorized scope. Keep a failed launch in the same work history when resuming; an initialization failure is not a model verdict.
31
19
 
32
20
  ## Before implementation
33
21
 
34
- For a coherent feature or behavior change, ask about the intended task and recover the relevant
35
- decisions. Read their evidence and follow relevant dependencies, exceptions and replacements,
36
- including indirect relationships. A search preview or accepted label alone does not settle scope.
22
+ For a coherent feature or behavior change, ask about the intended task and recover the relevant decisions. Read their evidence and follow relevant dependencies, exceptions and replacements, including indirect relationships. A search preview or accepted label alone does not settle scope.
37
23
 
38
- Use Hivex's source/version references. Keep conditions with their rules; a partial exception does
39
- not revoke an entire document. If the evidence answers the question, apply it without asking the
40
- owner again. Ask only when information is missing, sources cannot resolve a real ambiguity or a
41
- new decision requires the owner's involvement. Present the sources, impact and your recommendation.
24
+ Use Hivex's source/version references. Keep conditions with their rules; a partial exception does not revoke an entire document. If the evidence answers the question, apply it without asking the owner again. Ask only when information is missing, sources cannot resolve a real ambiguity or a new decision requires the owner's involvement. Present the sources, impact and your recommendation.
42
25
 
43
- Queries should be focused. Reuse context that remains current rather than asking again per file or
44
- implementation step. Respect declared incomplete exploration and unavailable evidence.
26
+ Queries should be focused. Reuse context that remains current rather than asking again per file or implementation step. Respect declared incomplete exploration and unavailable evidence.
45
27
 
46
28
  ## During review
47
29
 
48
- The principal reviewer directs the review. Run `hivex review "<task>" --base <git-ref>` from the
49
- Git project root. It examines tracked and untracked working changes, recovers relevant documentary
50
- context and makes one review call after at most one update/check batch. The default total budget is
51
- three calls; resume the same task/base with the intended total limit to continue retained work.
52
- Expanding a partial report keeps its work identity and consumed budget; a larger context does not
53
- create another allowance.
30
+ The principal reviewer directs the review. Run `hivex review "<task>" --base <git-ref>` from the Git project root. It examines tracked and untracked working changes, recovers relevant documentary context and makes one review call after at most one update/check batch. The default total budget is three calls; resume the same task/base with the intended total limit to continue retained work. Expanding a partial report keeps its work identity and consumed budget; a larger context does not create another allowance.
54
31
 
55
- Check each finding against its cited before/after code and Markdown versions, including dependencies,
56
- conditions and exceptions. Resolve a demonstrated contradiction before closing the change, by
57
- correcting the implementation or recording an approved decision change. Uncertainty calls for focused
58
- investigation; absence of a finding is not implementation approval. Missing context may be addressed
59
- with a focused task, explicit `--source` or an appropriate context limit, not automatic semantic retries.
32
+ Check each finding against its cited before/after code and Markdown versions, including dependencies, conditions and exceptions. Resolve a demonstrated contradiction before closing the change, by correcting the implementation or recording an approved decision change. Uncertainty calls for focused investigation; absence of a finding is not implementation approval. Missing context may be addressed with a focused task, explicit `--source` or an appropriate context limit, not automatic semantic retries.
60
33
 
61
- Save a report outside the reviewed project or in an ignored path when it must survive the session.
62
- `hivex review --check <saved-report.json> --root <project>` checks documentary and implementation
63
- freshness without a model. A current report is not proof of correct code; a stale report does not
64
- cover subsequent changes. Review output never replaces general code review, lint or tests.
34
+ Save a report outside the reviewed project or in an ignored path when it must survive the session. `hivex review --check <saved-report.json> --root <project>` checks documentary and implementation freshness without a model. A current report is not proof of correct code; a stale report does not cover subsequent changes. Review output never replaces general code review, lint or tests.
65
35
 
66
36
  ## Maintain knowledge
67
37
 
68
- The implementing agent maintains the documents as part of the change. Hivex may identify affected
69
- documents or suggest a correction, but does not rewrite project decisions on its own. Correct an
70
- incorrect graph interpretation against its source; do not alter doctrine to satisfy the model.
38
+ The implementing agent maintains the documents as part of the change. Hivex may identify affected documents or suggest a correction, but does not rewrite project decisions on its own. Correct an incorrect graph interpretation against its source; do not alter doctrine to satisfy the model.
71
39
 
72
- Keep documents at their monorepo, package or module authority. Follow the project's existing layout
73
- and format. When establishing or improving documentation, use the optional
74
- [Markdown convention](references/markdown.md); it is guidance, not an installation prerequisite.
40
+ Keep documents at their monorepo, package or module authority. Follow the project's existing layout and format. When establishing or improving documentation, use the optional [Markdown convention](references/markdown.md); it is guidance, not an installation prerequisite.
75
41
 
76
- Detect new, changed or removed documents before relying on the graph. Use the installed update
77
- workflow within the same work budget. Working documents may be queried without a commit, but that
78
- state is not approval; preserve the exact versions used by a review. Pending or uncertain knowledge
79
- limits the conclusions that depend on it, without making unrelated context unusable.
42
+ Detect new, changed or removed documents before relying on the graph. Use the installed update workflow within the same work budget. Working documents may be queried without a commit, but that state is not approval; preserve the exact versions used by a review. Pending or uncertain knowledge limits the conclusions that depend on it, without making unrelated context unusable.
80
43
 
81
- `ask` updates at most one relevant pending batch before answering, under the same total call/input
82
- budget. Its default is three calls. Omitted limits preserve a resumed work item's budget. Repeat the same task to resume; changing its budget changes the
83
- total ceiling, never the consumed count. Pending corpus coverage is explicit; use `update` when more
84
- rounds are needed, rather than issuing repeated identical questions to force indexing.
44
+ `ask` updates at most one relevant pending batch before answering, under the same total call/input budget. Its default is three calls. Omitted limits preserve a resumed work item's budget. Repeat the same task to resume; changing its budget changes the total ceiling, never the consumed count. Pending corpus coverage is explicit; use `update` when more rounds are needed, rather than issuing repeated identical questions to force indexing.
85
45
 
86
- An ordinary consultation does not ingest every declared historical source. A focused source is marked
87
- as historical in supplied packets, decisions and evidence, and its extracted decisions retain
88
- historical status with their conditions, exceptions, warnings and source ranges. If a required
89
- historical dependency is outside the declared scope, inspect `unavailableDocuments` and the reported
90
- coverage instead of treating the answer as complete.
46
+ An ordinary consultation does not ingest every declared historical source. A focused source is marked as historical in supplied packets, decisions and evidence, and its extracted decisions retain historical status with their conditions, exceptions, warnings and source ranges. If a required historical dependency is outside the declared scope, inspect `unavailableDocuments` and the reported coverage instead of treating the answer as complete.
91
47
 
92
- Repair a demonstrably wrong interpretation with `update --repair <document> --reason <correction>`.
93
- Check the Markdown first. This revises derived knowledge and its relationships without changing the
94
- document or authorizing new policy. Do not use it to suppress a genuine contradiction. Review source-local
95
- warnings in their stated scope and inspect `unavailableDocuments` for changed or removed dependencies.
48
+ Repair a demonstrably wrong interpretation with `update --repair <document> --reason <correction>`. Check the Markdown first. This revises derived knowledge and its relationships without changing the document or authorizing new policy. Do not use it to suppress a genuine contradiction. Review source-local warnings in their stated scope and inspect `unavailableDocuments` for changed or removed dependencies.
96
49
 
97
50
  ## Share reusable knowledge
98
51
 
99
- `hivex snapshot export` saves the current graph to `.hivex/graph.json`, suitable for Git alongside its
100
- Markdown sources. It retains source versions, evidence, available provenance and partial/uncertain
101
- coverage; it does not export local attempts, budgets, process locks or model caches. Snapshot commands
102
- make no model calls. Keep the SQLite store and locks ignored while allowing the shared JSON file.
52
+ `hivex snapshot export` saves the current graph to `.hivex/graph.json`, suitable for Git alongside its Markdown sources. It retains source versions, evidence, available provenance and partial/uncertain coverage; it does not export local attempts, budgets, process locks or model caches. Snapshot commands make no model calls. Keep the SQLite store and locks ignored while allowing the shared JSON file.
103
53
 
104
- A clone without local knowledge can read the snapshot directly and reuse its matching units on the
105
- first update. Existing local knowledge takes precedence; `hivex snapshot import` explicitly adopts
106
- the shared graph and refuses if work is unfinished. Preserve that work and its accounting rather than
107
- deleting the store to force import. Stale or unavailable source versions remain explicit, and source
108
- freshness is not semantic approval. Export when knowledge changes; ordinary reads do not dirty the
109
- shared artifact.
54
+ A clone without local knowledge can read the snapshot directly and reuse its matching units on the first update. Existing local knowledge takes precedence; `hivex snapshot import` explicitly adopts the shared graph and refuses if work is unfinished. Preserve that work and its accounting rather than deleting the store to force import. Stale or unavailable source versions remain explicit, and source freshness is not semantic approval. Export when knowledge changes; ordinary reads do not dirty the shared artifact.
55
+
56
+ When Markdown moves, use `hivex snapshot relocate <old-document> <new-document>` before updating knowledge. The old source must no longer be selected, and the destination must be selected current Markdown. This explicit operation preserves decision and relationship IDs and does not call the model or rewrite earlier work, answers, attempts or budgets. Unfinished work must be resolved through its normal lifecycle first.
57
+
58
+ An identical document at a previously unknown destination reuses its knowledge and ingestion coverage when retained evidence has matching, known source versions. Changed content, mixed or missing source versions, or consolidation into an existing destination leaves that destination pending for the normal update/check; it does not certify the old interpretation against new text. Retain the relocation report with the change and export the resulting graph alongside its Markdown. Do not relocate unrelated knowledge merely to hide unavailable evidence.
110
59
 
111
60
  ## Control consumption
112
61
 
113
- Large Markdown is ingested in bounded rounds. Inspect pending units and coverage, and resume the
114
- same work; do not wipe the store or resend the whole corpus when only a later round remains.
62
+ Large Markdown is ingested in bounded rounds. Inspect pending units and coverage, and resume the same work; do not wipe the store or resend the whole corpus when only a later round remains.
115
63
 
116
- A budget covers the complete work item, its phases and attempts. Resume retained progress with its
117
- original accounting; do not start a fresh counter to bypass an exhausted limit. Separate initial
118
- indexing, maintenance, consultation and review costs and report actual usage and unknown consumption.
119
- Deterministic reads do not require another model call, although the caller consumes context tokens.
64
+ A budget covers the complete work item, its phases and attempts. Resume retained progress with its original accounting; do not start a fresh counter to bypass an exhausted limit. Separate initial indexing, maintenance, consultation and review costs and report actual usage and unknown consumption. Deterministic reads do not require another model call, although the caller consumes context tokens.
120
65
 
121
- Do not automatically retry semantic disagreements or keep correcting until the model says green.
122
- After a crash, use `recover` to inspect retained work. It must not alter live owners or processes.
123
- An explicit `--acknowledge-uncertain` preserves uncertainty and cost; it does not certify a remote
124
- outcome or authorize an automatic retry. Resume only the intended work with its existing budget.
125
- Use `prune` for obsolete completed work and cached responses when needed; keep unfinished work and
126
- export evidence that must outlive cache retention.
66
+ Do not automatically retry semantic disagreements or keep correcting until the model says green. After a crash, use `recover` to inspect retained work. It must not alter live owners or processes. An explicit `--acknowledge-uncertain` preserves uncertainty and cost; it does not certify a remote outcome or authorize an automatic retry. Resume only the intended work with its existing budget. Use `prune` for obsolete completed work and cached responses when needed; keep unfinished work and export evidence that must outlive cache retention.
127
67
 
128
- Preserve useful results and their limits. At a budget boundary, explain what remains and obtain an
129
- authorized extension before spending more. Existing user authorization remains valid; the skill does
130
- not require another permission question for already authorized work.
68
+ Preserve useful results and their limits. At a budget boundary, explain what remains and obtain an authorized extension before spending more. Existing user authorization remains valid; the skill does not require another permission question for already authorized work.
131
69
 
132
- If maintenance reports `context-limit`, inspect `work.contextLimit` for required documents and bytes.
133
- Restore missing evidence or adjust the context bound, then resume the same task. No extraction call
134
- is spent while its known relationship evidence is unavailable or exceeds that bound.
70
+ If maintenance reports `context-limit`, inspect `work.contextLimit` for required documents and bytes. Restore missing evidence or adjust the context bound, then resume the same task. No extraction call is spent while its known relationship evidence is unavailable or exceeds that bound.
@@ -1,17 +1,12 @@
1
1
  # Optional Markdown convention
2
2
 
3
- Use the project's existing Markdown as it is. Hivex must not require this convention, frontmatter,
4
- numbered ADRs or a particular directory structure. Recommend these practices when adopting Hivex or
5
- writing documentation, without repeatedly proposing a migration of an established project.
3
+ Use the project's existing Markdown as it is. Hivex must not require this convention, frontmatter, numbered ADRs or a particular directory structure. Recommend these practices when adopting Hivex or writing documentation, without repeatedly proposing a migration of an established project.
6
4
 
7
- These practices draw on Compi's authority map and documentation layout and the domain-modeling
8
- skill. They preserve the useful documentation discipline, not Compi's retired machinery.
5
+ These practices draw on established authority-map and documentation-layout patterns and the domain-modeling skill. They preserve useful documentation discipline without prescribing retired machinery from any one project.
9
6
 
10
7
  ## Give knowledge one authoritative home
11
8
 
12
- Keep shared decisions at project or monorepo level. Package-specific or module-specific knowledge
13
- can stay with that package or module. Link shared rules instead of copying them into each area.
14
- Folders and files appear only when there is useful content to put in them.
9
+ Keep shared decisions at project or monorepo level. Package-specific or module-specific knowledge can stay with that package or module. Link shared rules instead of copying them into each area. Folders and files appear only when there is useful content to put in them.
15
10
 
16
11
  A useful catalogue distinguishes:
17
12
 
@@ -23,57 +18,32 @@ A useful catalogue distinguishes:
23
18
  - Procedures for concrete operational or recovery tasks.
24
19
  - Research and evidence identified as dated support, not automatically current decisions.
25
20
 
26
- For example, a project may use `docs/README.md`, `docs/CONTEXT.md`, `docs/adr/`,
27
- `docs/guidelines/`, `docs/process/`, `docs/procedures/` and `docs/research/`. These are examples,
28
- not required paths. Multiple bounded contexts may have their own glossary and decisions with a
29
- small context map linking them; a monorepo need not duplicate one shared product glossary.
21
+ For example, a project may use `docs/README.md`, `docs/CONTEXT.md`, `docs/adr/`, `docs/guidelines/`, `docs/procedures/` and `docs/research/`. Keep standing rules and design guidance in `guidelines`, and instructions for carrying out tasks in `procedures`; avoid overlapping directories with indistinct purposes. These are examples, not required paths. Multiple bounded contexts may have their own glossary and decisions with a small context map linking them; a monorepo need not duplicate one shared product glossary.
30
22
 
31
23
  ## Write decisions for the next reader
32
24
 
33
- State what was decided and why. Include the scope, conditions and exceptions that change how the
34
- rule is applied. Link the source or decision it depends on or replaces. A short paragraph can be
35
- enough; optional sections should carry information rather than serve as boxes to fill in.
25
+ State what was decided and why. Include the scope, conditions and exceptions that change how the rule is applied. Link the source or decision it depends on or replaces. A short paragraph can be enough; optional sections should carry information rather than serve as boxes to fill in.
36
26
 
37
27
  For a consequential architectural trade-off, an ADR might be:
38
28
 
39
29
  ```markdown
40
30
  # Remove private cached data when access is revoked
41
31
 
42
- Cached private data is removed immediately when access is revoked. The normal cache lifetime
43
- still applies while access remains valid. This prevents stale local access after a permission
44
- change. See the cache policy for the general retention rule.
32
+ Cached private data is removed immediately when access is revoked. The normal cache lifetime still applies while access remains valid. This prevents stale local access after a permission change. See the cache policy for the general retention rule.
45
33
  ```
46
34
 
47
- A title, truthful status and decision date can improve cataloguing. Tags are optional. If a rule is
48
- replaced, identify the replacement and whether the change is partial. Keep the historical reasoning
49
- readable; do not silently rewrite the past. A missing status means uncertainty to resolve from the
50
- content, not permission to assume acceptance.
35
+ A title, truthful status and decision date can improve cataloguing. Tags are optional. If a rule is replaced, identify the replacement and whether the change is partial. Keep the historical reasoning readable; do not silently rewrite the past. A missing status means uncertainty to resolve from the content, not permission to assume acceptance.
51
36
 
52
- Use an ADR when the choice is consequential, reflects a real trade-off and would be surprising
53
- without its rationale. Do not create one for every routine edit or dependency. Sequential names
54
- such as `0001-short-decision.md` are convenient if the project adopts that convention.
37
+ Use an ADR when the choice is consequential, reflects a real trade-off and would be surprising without its rationale. Do not create one for every routine edit or dependency. Sequential names such as `0001-short-decision.md` are convenient if the project adopts that convention.
55
38
 
56
39
  ## Compact an ADR without losing its history
57
40
 
58
- When replaced text obscures a decision's current meaning, preserve that history in a clearly marked
59
- Markdown archive and keep the active document focused on applicable rules, reasons, dependencies
60
- and exceptions. A wholly superseded ADR can remain as a short pointer to its replacement and archive.
61
- Preserve referenced anchors or update their links. Do not archive a live exception merely because it
62
- is old, or change what an earlier decision meant while shortening its current presentation.
41
+ When replaced text obscures a decision's current meaning, preserve that history in a clearly marked Markdown archive and keep the active document focused on applicable rules, reasons, dependencies and exceptions. A wholly superseded ADR can remain as a short pointer to its replacement and archive. Preserve referenced anchors or update their links. Do not archive a live exception merely because it is old, or change what an earlier decision meant while shortening its current presentation.
63
42
 
64
- Compi uses `docs/archive/adr/` for this purpose; other layouts remain valid. Historical evidence should
65
- be available for focused consultation without being loaded into every model context. Declare its
66
- relative globs in `hivex.json` under `history`, then use the installed CLI's `--source` selection or
67
- a known relationship for bounded retrieval. Compaction must not silently make necessary evidence
68
- inaccessible. The human or implementing agent maintains these documents; Hivex does not rewrite or
69
- move the sources.
43
+ A project may use `docs/archive/adr/` for this purpose; other layouts remain valid. Historical evidence should be available for focused consultation without being loaded into every model context. Declare its relative globs in `hivex.json` under `history`, then use the installed CLI's `--source` selection or a known relationship for bounded retrieval. Compaction must not silently make necessary evidence inaccessible. The human or implementing agent maintains these documents; Hivex does not rewrite or move the sources.
70
44
 
71
45
  ## Keep the glossary focused
72
46
 
73
- Define each project-specific concept briefly and use that term consistently. A glossary explains
74
- what a concept is; it is not an implementation manual, task plan or collection of general programming
75
- terms. Group related concepts when it helps and link context-specific definitions instead of copying.
47
+ Define each project-specific concept briefly and use that term consistently. A glossary explains what a concept is; it is not an implementation manual, task plan or collection of general programming terms. Group related concepts when it helps and link context-specific definitions instead of copying.
76
48
 
77
- Code and executable contracts explain mechanics. Markdown preserves the intent, constraints,
78
- decisions and reasons that code cannot explain. Update that knowledge alongside the change rather
79
- than leaving the only explanation in a conversation or private agent memory.
49
+ Code and executable contracts explain mechanics. Markdown preserves the intent, constraints, decisions and reasons that code cannot explain. Update that knowledge alongside the change rather than leaving the only explanation in a conversation or private agent memory.
@@ -1,26 +1,36 @@
1
1
  import { HivexError } from '../errors.ts';
2
2
 
3
- function bounded(text: string) {
3
+ const bounded = (text: string) => {
4
4
  let result = '';
5
5
  for (const char of text) {
6
- if (Buffer.byteLength(JSON.stringify(result + char)) > 256) break;
6
+ if (Buffer.byteLength(JSON.stringify(result + char)) > 256) {
7
+ break;
8
+ }
7
9
  result += char;
8
10
  }
9
11
  return result;
10
- }
11
-
12
- export function diagnostic(error: unknown) {
12
+ };
13
+ export const diagnostic = (error: unknown) => {
13
14
  let failure = new HivexError({
14
15
  code: 'READ_FAILED',
15
16
  message: 'Unable to read project knowledge',
16
17
  });
17
- if (error instanceof HivexError) failure = error;
18
- else if (error instanceof Error)
18
+ if (error instanceof HivexError) {
19
+ failure = error;
20
+ } else if (Error.isError(error)) {
19
21
  failure = new HivexError({ code: 'READ_FAILED', message: error.message });
20
- let details = failure.details;
21
- if (details && Buffer.byteLength(JSON.stringify(details)) > 384) details = { omitted: true };
22
+ }
23
+ let { details } = failure;
24
+ if (details && Buffer.byteLength(JSON.stringify(details)) > 384) {
25
+ details = { omitted: true };
26
+ }
22
27
  const message = bounded(failure.message);
23
28
  return {
24
- error: { code: failure.code, message, messageTruncated: message !== failure.message, details },
29
+ error: {
30
+ code: failure.code,
31
+ details,
32
+ message,
33
+ messageTruncated: message !== failure.message,
34
+ },
25
35
  };
26
- }
36
+ };