@dotdotgod/hermes 0.0.0-stage → 0.6.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.
package/LICENSE ADDED
@@ -0,0 +1,94 @@
1
+ Elastic License 2.0 (ELv2)
2
+
3
+ Copyright 2026 JooYoung Kim
4
+
5
+ ## Acceptance
6
+
7
+ By using the software, you agree to all of the terms and conditions below.
8
+
9
+ ## Copyright License
10
+
11
+ The licensor grants you a non-exclusive, royalty-free, worldwide,
12
+ non-sublicensable, non-transferable license to use, copy, distribute, make
13
+ available, and prepare derivative works of the software, in each case subject
14
+ to the limitations and conditions below.
15
+
16
+ ## Limitations
17
+
18
+ You may not provide the software to third parties as a hosted or managed
19
+ service, where the service provides users with access to any substantial set
20
+ of the features or functionality of the software.
21
+
22
+ You may not move, change, disable, or circumvent the license key
23
+ functionality in the software, and you may not remove or obscure any
24
+ functionality in the software that is protected by the license key.
25
+
26
+ You may not alter, remove, or obscure any licensing, copyright, or other
27
+ notices of the licensor in the software. Any use of the licensor's trademarks
28
+ is subject to applicable law.
29
+
30
+ ## Patents
31
+
32
+ The licensor grants you a license, under any patent claims the licensor can
33
+ license, or becomes able to license, to make, have made, use, sell, offer for
34
+ sale, import and have imported the software, in each case subject to the
35
+ limitations and conditions in this license. This license does not cover any
36
+ patent claims that you cause to be infringed by modifications or additions to
37
+ the software. If you or your company make any written claim that the software
38
+ infringes or contributes to infringement of any patent, your patent license
39
+ for the software granted under these terms ends immediately. If your company
40
+ makes such a claim, your patent license ends immediately for work on behalf
41
+ of your company.
42
+
43
+ ## Notices
44
+
45
+ You must ensure that anyone who gets a copy of any part of the software from
46
+ you also gets a copy of these terms.
47
+
48
+ If you modify the software, you must include in any modified copies of the
49
+ software prominent notices stating that you have modified the software.
50
+
51
+ ## No Other Rights
52
+
53
+ These terms do not imply any licenses other than those expressly granted in
54
+ these terms.
55
+
56
+ ## Termination
57
+
58
+ If you use the software in violation of these terms, such use is not
59
+ licensed, and your licenses will automatically terminate. If the licensor
60
+ provides you with a notice of your violation, and you cease all violation of
61
+ this license no later than 30 days after you receive that notice, your
62
+ licenses will be reinstated retroactively. However, if you violate these
63
+ terms after such reinstatement, any additional violation of these terms will
64
+ cause your licenses to terminate automatically and permanently.
65
+
66
+ ## No Liability
67
+
68
+ *As far as the law allows, the software comes as is, without any warranty or
69
+ condition, and the licensor will not be liable to you for any damages arising
70
+ out of these terms or the use or nature of the software, under any kind of
71
+ legal claim.*
72
+
73
+ ## Definitions
74
+
75
+ The **licensor** is the entity offering these terms, and the **software** is
76
+ the software the licensor makes available under these terms, including any
77
+ portion of it.
78
+
79
+ **you** refers to the individual or entity agreeing to these terms.
80
+
81
+ **your company** is any legal entity, sole proprietorship, or other kind of
82
+ organization that you work for, plus all organizations that have control over,
83
+ are under the control of, or are under common control with that organization.
84
+ **control** means ownership of substantially all the assets of an entity, or
85
+ the power to direct its management and policies by vote, contract, or
86
+ otherwise. Control can be direct or indirect.
87
+
88
+ **your licenses** are all the licenses granted to you for the software under
89
+ these terms.
90
+
91
+ **use** means anything you do with the software requiring one of your
92
+ licenses.
93
+
94
+ **trademark** means trademarks, service marks, and similar rights.
package/README.md CHANGED
@@ -1,3 +1,127 @@
1
- # Temporary Holding Version
1
+ # @dotdotgod/hermes
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Hermes CLI and messaging-gateway project memory adapter, without Plan Mode.
4
+ Target host revision: `19b57f11d6eefb17e3e8a58e40b0b16aeb8b83b9`.
5
+
6
+ ## Installation
7
+
8
+ Requires Python 3.11+ (use the host's supported Python version), Node 22.19+,
9
+ Git for impact tracking, and an explicitly enabled native Hermes plugin.
10
+ The installed directory must contain plugin.yaml and __init__.py at its root.
11
+
12
+ For a source checkout:
13
+
14
+ ```bash
15
+ pnpm install
16
+ pnpm run generate
17
+ mkdir -p "$HOME/.hermes/plugins"
18
+ cp -R packages/hermes "$HOME/.hermes/plugins/dotdotgod"
19
+ hermes plugins enable dotdotgod
20
+ ```
21
+
22
+ For npm distribution, run npm pack @dotdotgod/hermes@0.6.0 and extract its package
23
+ directory into the same native plugin location. npm installation alone does not
24
+ activate a Hermes plugin. Generated MCP/CLI/client artifacts are self-contained;
25
+ consumer node_modules, a global dotdotgod CLI and Python MCP dependencies are not
26
+ required for core operation. Restart Hermes after installation/resource changes.
27
+ Do not enable a separate profile-wide dotdotgod MCP server for these tools.
28
+
29
+ Optional semantic embeddings use the existing explicit installation workflow;
30
+ map/README routing works without them. Do not automatically install dependencies.
31
+
32
+ ## Gateway Repository Access
33
+
34
+ The operator configures labels and principal-specific grants in config.yaml:
35
+
36
+ ```yaml
37
+ plugins:
38
+ enabled: [dotdotgod]
39
+ entries:
40
+ dotdotgod:
41
+ settings:
42
+ roots:
43
+ app: /absolute/path/to/app
44
+ docs: /absolute/path/to/docs-project
45
+ gateway_access:
46
+ "telegram:123456": [app]
47
+ "discord:987654": [docs]
48
+ ```
49
+
50
+ Use the trusted sender ID supplied by your Hermes gateway, not a display name.
51
+ The model cannot grant itself a root or choose arbitrary filesystem paths.
52
+ On an unbound gateway session the adapter requests dotdotgod_select_root with an
53
+ authorized label before substantive work. Missing/changed grants deny access.
54
+ CLI starts at the launch directory; optional cli_root sets its repository.
55
+
56
+ One bridge and MCP server are created lazily per authorized repository/host
57
+ session. Same-repository connections share the project SQLite DB, not mutable
58
+ connection-session identity. Explicit context session_resume affects only the
59
+ caller's connection; its last resumed ID survives transport reconnects.
60
+ Selections persist in profile-owned plugin state and are reauthorized on restore.
61
+ Startup/restored sessions conservatively reassess project memory; abandoned
62
+ sibling completion is not inherited.
63
+
64
+ This is routing isolation, not multi-tenant OS isolation. Hermes and enabled
65
+ plugins retain host permissions. Authorized users of the same repository share
66
+ project data; context scope/session filters are not access-control lists.
67
+
68
+ ## Features
69
+
70
+ - Generated project-initializer, project-load, impact-review and document-clarify
71
+ skills from canonical shared sources.
72
+ - Automatic load-required instructions; call dotdotgod_project_load once with an
73
+ agent-selected focus and continue the original request. Explicit load uses the
74
+ same tool/skill; full map depth is 5, focused map depth 3 with up to 30 query hits.
75
+ - `dd:no-load` in a request skips only that request's automatic load instruction.
76
+ - Explicit/fuzzy reference evidence via the bundled CLI; no full auto-validation.
77
+ - Native dotdotgod execution/context/operations tools backed by per-session MCP.
78
+ They return a JSON envelope with content and structuredContent. Do not parse the
79
+ Markdown content as JSON or assume Pi's codemode object-return contract.
80
+ - dotdotgod_select_root and dotdotgod_impact_status are adapter-local tools.
81
+ - Pending impact is derived from Git dirty/untracked fingerprints and durable
82
+ checked fingerprints. Successful checks clear only checked, unchanged paths.
83
+ Source edits reopen pending state; reads and impact checks remain available.
84
+ - Native Hermes delegate_task is the delegation mechanism. Child hooks inherit
85
+ only an already authorized matching-principal parent repository, with a separate
86
+ context connection; impact covers their changes in the shared worktree.
87
+
88
+ No dedicated planning state, wizard, source-edit approval UI, compaction feature,
89
+ Pi TUI implementation, or pi-subagents port is included.
90
+
91
+ ## Gate And Lifecycle Limits
92
+
93
+ Recognized git commit/push/tag, npm/pnpm/yarn test/verify/build/lint/check/publish/deploy and common
94
+ Python/Node test commands are blocked while impact is pending. Execute batches
95
+ are checked inside the adapter too. Opaque execute_file calls are blocked while
96
+ pending because their effects cannot be inferred safely.
97
+
98
+ Native file path arguments and terminal workdir are rooted to the selected local
99
+ repository; reads may also access the installed bundled skill resources. This adapter targets local host worktrees, not remote/container path
100
+ translation. Shell paths, patch bodies, arbitrary programs and other plugins are
101
+ not a filesystem sandbox; keep Hermes's own approvals and OS isolation.
102
+ Shell mutations hidden inside one combined mutation/release command are not fully
103
+ recognized. Native hooks can fail open under host errors/timeouts; no universal
104
+ bypass-prevention claim is made.
105
+
106
+ Interrupted turns close their context connection without replaying writes.
107
+ Finalized/reset sessions release processes. Normal end-of-turn retains connections
108
+ and background jobs. Transport failure ends the uncertain call; only a subsequent
109
+ user/model call reconnects, with no automatic mutation replay. In-flight requests
110
+ have a 660-second MCP and 690-second bridge timeout; cancellation kills the local
111
+ process group after sending SDK cancellation so the server can reap detached
112
+ command groups. Forced transport loss cannot guarantee termination of all detached
113
+ commands; uncertain calls are never replayed. Persisted ingestion jobs retain
114
+ shared runtime restart semantics. Cleanup is POSIX-tested; Windows is unverified.
115
+
116
+ ## Verification
117
+
118
+ ```bash
119
+ pnpm --filter @dotdotgod/hermes run verify
120
+ pnpm --filter @dotdotgod/hermes run pack:dry-run
121
+ ```
122
+
123
+ Tests exercise native registration/lifecycle callbacks with host-shaped fixtures
124
+ and real generated MCP processes, including concurrent roots/sessions, restore,
125
+ reference/load fallback, impact failure/subsets/re-edits and cancellation.
126
+ Live pinned host installation and messaging smoke results are recorded separately;
127
+ fixture success alone is not a claim that every host lifecycle path was exercised.
package/__init__.py ADDED
@@ -0,0 +1,48 @@
1
+ """dotdotgod native Hermes plugin; no Plan Mode and no shared-profile MCP connection."""
2
+ import json
3
+ from pathlib import Path
4
+
5
+ from .runtime import Runtime
6
+
7
+ NAMES = {
8
+ "index": "dotdotgod_context_index", "search": "dotdotgod_context_search",
9
+ "stats": "dotdotgod_context_stats", "doctor": "dotdotgod_context_doctor",
10
+ "purge": "dotdotgod_context_purge", "session_resume": "dotdotgod_context_session_resume",
11
+ }
12
+
13
+
14
+ def register(ctx):
15
+ runtime = Runtime(ctx)
16
+ for skill in sorted((Path(__file__).parent / "skills").glob("*/SKILL.md")):
17
+ ctx.register_skill(skill.parent.name, skill)
18
+ tools = json.loads((Path(__file__).parent / "mcp" / "tools.json").read_text())
19
+ for tool in tools:
20
+ remote = tool["name"]
21
+ name = NAMES.get(remote, remote if remote.startswith("dotdotgod_") else "dotdotgod_" + remote)
22
+
23
+ def handle(args, session_id="", _remote=remote, **kwargs):
24
+ try:
25
+ return json.dumps(runtime.call(_remote, args, session_id), ensure_ascii=False)
26
+ except Exception as error:
27
+ return json.dumps({"error": str(error), "ok": False}, ensure_ascii=False)
28
+
29
+ ctx.register_tool(name=name, toolset="dotdotgod", schema={
30
+ "name": name, "description": tool["description"], "parameters": tool["inputSchema"],
31
+ }, handler=handle, description=tool["description"])
32
+
33
+ for name, schema, description in [
34
+ ("dotdotgod_select_root", {"type": "object", "properties": {"label": {"type": "string"}}, "required": ["label"], "additionalProperties": False}, "Select an operator-authorized repository for this host session."),
35
+ ("dotdotgod_impact_status", {"type": "object", "properties": {}, "additionalProperties": False}, "Read pending impact paths for the selected repository; does not clear them."),
36
+ ]:
37
+ def handle_local(args, session_id="", _name=name, **kwargs):
38
+ try:
39
+ return json.dumps(runtime.call(_name, args, session_id), ensure_ascii=False)
40
+ except Exception as error:
41
+ return json.dumps({"error": str(error), "ok": False}, ensure_ascii=False)
42
+ ctx.register_tool(name=name, toolset="dotdotgod", schema={"name": name, "description": description, "parameters": schema}, handler=handle_local, description=description)
43
+
44
+ ctx.register_hook("pre_llm_call", runtime.before_llm)
45
+ ctx.register_hook("pre_tool_call", runtime.before_tool)
46
+ ctx.register_hook("on_session_finalize", runtime.finalize)
47
+ ctx.register_hook("on_session_reset", runtime.finalize)
48
+ ctx.register_hook("on_session_end", runtime.end_turn)
@@ -0,0 +1,41 @@
1
+ // Adapter-owned stdio MCP client. One process/connection per repository + host session.
2
+ import { Client } from '@modelcontextprotocol/sdk/client/index.js';
3
+ import { StdioClientTransport } from '@modelcontextprotocol/sdk/client/stdio.js';
4
+ import { createInterface } from 'node:readline';
5
+ import { fileURLToPath } from 'node:url';
6
+ import { realpathSync } from 'node:fs';
7
+
8
+ const root = realpathSync(process.argv[2]);
9
+ const sessionId = process.argv[3];
10
+ const client = new Client({ name: 'dotdotgod-hermes', version: '0.6.0' });
11
+ const transport = new StdioClientTransport({
12
+ command: process.execPath, args: [fileURLToPath(new URL('./server.mjs', import.meta.url))], cwd: root,
13
+ env: { ...process.env, DOTDOTGOD_PROJECT_ROOT: root, DOTDOTGOD_SESSION_ID: sessionId }, stderr: 'inherit',
14
+ });
15
+ const input = createInterface({ input: process.stdin, crlfDelay: Infinity });
16
+ const lines = input[Symbol.asyncIterator](); // Subscribe before MCP startup; early requests must not be dropped.
17
+ let active;
18
+ let stopping = false;
19
+ process.on('SIGTERM', () => { stopping = true; active?.abort(); input.close(); });
20
+ try {
21
+ await client.connect(transport);
22
+ for await (const line of lines) {
23
+ try {
24
+ const request = JSON.parse(line);
25
+ active = new AbortController();
26
+ // Session resumes are validated by the existing shared contract. Do not replay failed writes.
27
+ const value = request.list ? await client.listTools() : await client.callTool({
28
+ name: request.name, arguments: request.arguments ?? {},
29
+ }, undefined, { timeout: 660000, signal: active.signal });
30
+ process.stdout.write(`${JSON.stringify({ ok: true, value })}\n`);
31
+ } catch (error) {
32
+ process.stdout.write(`${JSON.stringify({ ok: false, error: String(error.message ?? error) })}\n`);
33
+ }
34
+ active = undefined;
35
+ if (stopping) break;
36
+ }
37
+ } finally {
38
+ // Let the server consume SDK cancellation and reap detached command groups before transport teardown.
39
+ if (stopping) await new Promise(resolve => setTimeout(resolve, 1000));
40
+ await client.close();
41
+ }