@sporhq/spor 0.1.1 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE CHANGED
@@ -1,21 +1,201 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 Anthony Allen
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 Anthony Allen
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/NOTICE ADDED
@@ -0,0 +1,13 @@
1
+ Spor
2
+ Copyright 2026 Anthony Allen
3
+
4
+ This product is developed as part of the Spor project (https://sporhq.io).
5
+
6
+ Licensed under the Apache License, Version 2.0 (see the "LICENSE" file in this
7
+ distribution). Unless required by applicable law or agreed to in writing,
8
+ software distributed under the License is distributed on an "AS IS" BASIS,
9
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
+
11
+ "Spor" and "sporhq" are trademarks of Anthony Allen. The Apache License grants
12
+ no permission to use these marks; their use is governed separately by the
13
+ trademark policy in the "TRADEMARKS.md" file.
package/README.md CHANGED
@@ -20,7 +20,7 @@ dispatcher hosts call):
20
20
  npm install -g @sporhq/spor
21
21
  ```
22
22
 
23
- Requires Node 18+ and nothing else — the client is zero-dependency. To run
23
+ Requires Node 20+ and nothing else — the client is zero-dependency. To run
24
24
  from a checkout instead (e.g. to hack on it), clone the repo and `npm link`
25
25
  from its root; that symlinks the same two commands onto your PATH.
26
26
 
@@ -36,15 +36,32 @@ time you're unsure whether Spor is active or which graph you're on. (Without
36
36
  the `spor` CLI on your PATH the equivalent is
37
37
  `mkdir -p ~/.spor/nodes && git -C ~/.spor init && printf 'journal/\n' > ~/.spor/.gitignore`.)
38
38
 
39
- Then install for your agent. In Claude Code:
39
+ Then install for your agent. One verb wires up any supported host — it
40
+ resolves the adapter manifest to this checkout and drops it into the host's
41
+ config:
42
+
43
+ ```bash
44
+ spor install claude # Claude Code (via its plugin CLI — no marketplace browsing)
45
+ spor install codex # also: gemini, cursor, copilot, opencode
46
+ spor install # no host => list the hosts detected on this machine
47
+ ```
48
+
49
+ `--scope user` (default) installs for you; `--scope repo` writes a committable
50
+ per-repo config. `--all` installs every detected host, `--print` is a dry run,
51
+ and `--server <url> --token <tok>` also points the client at a team graph in
52
+ the same step. Re-running is idempotent — it refreshes the path and never
53
+ duplicates your other hooks.
54
+
55
+ In Claude Code you can still install from the marketplace by hand if you
56
+ prefer:
40
57
 
41
58
  ```
42
59
  /plugin marketplace add sporhq/spor
43
60
  /plugin install spor@spor
44
61
  ```
45
62
 
46
- For every other host Codex CLI, Gemini CLI, Cursor, Copilot CLI, OpenCode,
47
- and an `AGENTS.md` fallback for hosts with no hook support see
63
+ For the per-host event mapping, fidelity notes, distiller backend, and the
64
+ `AGENTS.md` fallback for hosts with no hook support, see
48
65
  [adapters/](adapters/).
49
66
 
50
67
  To start with a populated graph, point the bundled `spor-backfill` agent at
@@ -202,3 +219,17 @@ verifiable rather than asserted:
202
219
  write semantics, identity and auth, and client configuration.
203
220
  - [adapters/](adapters/) — supported coding agents and how install works on
204
221
  each, including the `AGENTS.md` floor for hosts without hooks.
222
+
223
+ ## License
224
+
225
+ Spor (this client) is licensed under the [Apache License 2.0](LICENSE) — a
226
+ permissive license with an explicit patent grant. See [NOTICE](NOTICE) for
227
+ attribution.
228
+
229
+ "Spor" and "sporhq" are trademarks of the project; the Apache License grants no
230
+ rights to the marks. Their use is governed by the [Trademark Policy](TRADEMARKS.md)
231
+ — in short, build "an adapter **for** Spor," not a product **named** Spor.
232
+
233
+ Contributions are welcome under inbound = outbound (Apache-2.0); see
234
+ [CONTRIBUTING.md](CONTRIBUTING.md), [SECURITY.md](SECURITY.md), and the
235
+ [Code of Conduct](CODE_OF_CONDUCT.md).
package/TRADEMARKS.md ADDED
@@ -0,0 +1,102 @@
1
+ # Trademark Policy
2
+
3
+ This document, the "Policy," describes how you may use the trademarks of the
4
+ Spor project (the "Project"). Spor's software is available under a free and
5
+ open source license — the [Apache License 2.0](LICENSE) — but that copyright
6
+ license grants **no** right, express or implied, to use the Project's
7
+ trademarks (see Section 6 of the Apache License). This Policy is where we
8
+ describe the use we permit.
9
+
10
+ The role of a trademark is to assure people about the source and quality of
11
+ the thing carrying it. Because the open source license lets you modify the
12
+ software freely, we cannot guarantee that a modified version distributed under
13
+ our name still behaves the way users expect. This Policy describes how you may
14
+ use our marks to accurately describe your relationship to Spor without creating
15
+ that confusion.
16
+
17
+ ## Marks covered
18
+
19
+ This Policy covers the following word marks (the "Marks"):
20
+
21
+ | Mark | Common descriptive name |
22
+ | ----------- | ----------------------------------- |
23
+ | Spor | knowledge-graph context software |
24
+ | spor | knowledge-graph context software |
25
+ | sporhq | knowledge-graph context software |
26
+ | sporhq.io | knowledge-graph context software |
27
+
28
+ It also covers the Spor logo and visual identity ("trade dress").
29
+
30
+ **Registration is not required.** Trademark rights arise from use in commerce.
31
+ Some or all of the Marks may be unregistered; this Policy and our rights apply
32
+ whether or not a Mark is registered. Until a registration issues for a Mark, it
33
+ is identified with a "™" symbol; a registered Mark would use "®".
34
+
35
+ ## Universal considerations
36
+
37
+ Whenever you use a Mark you must do so in a way that does not mislead anyone,
38
+ directly or by omission, about what they are getting and from whom. In
39
+ particular:
40
+
41
+ - You may not use a Mark in a way that suggests your product, service, or site
42
+ is produced, endorsed, or sponsored by the Project when it is not.
43
+ - You may not use or register a Mark, in whole or in part, as part of your own
44
+ trademark, product name, service name, company name, domain name, or social
45
+ account.
46
+ - You may not use a confusingly similar variant — a phonetic equivalent,
47
+ translation, misspelling, or abbreviation — for a similar or competing
48
+ product or service.
49
+ - You may not use a Mark in connection with software that you are distributing
50
+ out of compliance with the Apache License.
51
+
52
+ Any goodwill from your use of the Marks inures solely to the Project.
53
+
54
+ ## Uses that do not need permission
55
+
56
+ - **Redistributing the unmodified software.** If you redistribute an official,
57
+ unmodified release of Spor, you may keep the Marks and notices it ships with.
58
+ - **Describing compatibility or a relationship truthfully.** Use a Mark after a
59
+ verb or preposition that describes the relationship — for example
60
+ "an adapter **for** Spor", "works **with** Spor", "compatible **with** Spor",
61
+ "built **on** Spor". Do not use a Mark as the name of your own thing
62
+ ("Spor Pro", "SporCloud", "Spor for X" as a product name).
63
+ - **Nominative reference.** You may use a Mark as much as is reasonably
64
+ necessary to identify Spor in articles, talks, documentation, and tutorials,
65
+ provided you do not imply endorsement.
66
+ - **Functional, non-trademark use.** Using the word `spor` functionally inside
67
+ software — as a command name, package name on a registry where it identifies
68
+ this Project's software, file or directory name, config key, or environment
69
+ variable (e.g. `spor install`, `SPOR_SERVER`, `@sporhq/spor`) — is not a
70
+ trademark use and is unrestricted.
71
+
72
+ ## Uses that need our permission
73
+
74
+ - Using a Mark on a **modified** build of Spor distributed to others (it may no
75
+ longer behave as users expect under our name).
76
+ - Using a Mark, or a confusingly similar term, as part of a **product, service,
77
+ company, or domain name**, including for a hosted/SaaS offering.
78
+ - Using the Spor **logo** other than in unmodified redistribution or clearly
79
+ nominative reference.
80
+ - Using a Mark on **merchandise** or in advertising in a way that implies
81
+ endorsement.
82
+
83
+ If you want to do any of these, ask first (see below).
84
+
85
+ ## Proper use
86
+
87
+ Distinguish a Mark from surrounding text (initial capital — "Spor", not
88
+ "spor", except in the functional/technical uses above), use it as an adjective
89
+ ("a Spor briefing", not "a Spor" / "to Spor something"), do not pluralize or
90
+ hyphenate it, and do not translate it.
91
+
92
+ ## Questions and reports
93
+
94
+ To ask about a use not covered here, request permission, or report misuse,
95
+ open an issue at <https://github.com/sporhq/spor/issues> or contact us via
96
+ <https://sporhq.io>.
97
+
98
+ ---
99
+
100
+ These guidelines are adapted from the
101
+ [Model Trademark Guidelines](http://www.modeltrademarkguidelines.org), used
102
+ under a Creative Commons Attribution 3.0 Unported license.
@@ -1,5 +1,13 @@
1
1
  # Host adapters
2
2
 
3
+ > **Installing:** `spor install <host>` (e.g. `spor install codex`) automates
4
+ > the per-host recipe below — it resolves the `__SPOR_ROOT__` placeholder to
5
+ > your checkout and merges the manifest into the host's config (idempotently;
6
+ > `--scope user|repo`, `--all`, `--print`). The manual steps in each adapter's
7
+ > README remain valid for hand-installs or when you want to see exactly what
8
+ > lands where. Claude Code installs via its own plugin CLI (`spor install
9
+ > claude`), not a file drop.
10
+
3
11
  The Spor client is a portable core behind per-host adapters
4
12
  (dec-cc-portable-core-adapters):
5
13
 
package/bin/spor.js CHANGED
@@ -18,6 +18,7 @@
18
18
  // never dumps a stack trace at the user.
19
19
 
20
20
  const fs = require("fs");
21
+ const os = require("os");
21
22
  const path = require("path");
22
23
  const { spawnSync } = require("child_process");
23
24
 
@@ -32,6 +33,9 @@ Usage: spor <verb> [args]
32
33
 
33
34
  Getting started
34
35
  init create the local graph home (nodes/, git, .gitignore)
36
+ install [host...] wire spor into an agent: claude codex gemini opencode
37
+ copilot cursor (no host => list detected). --scope
38
+ user|repo, --all, --print, --server/--token to configure
35
39
  status resolved mode, graph, project, identity, health
36
40
  join <url> <token> point the client at a graph (writes user config)
37
41
  migrate <url> push the local graph to a remote you own (solo-remote)
@@ -345,6 +349,24 @@ async function cmdAdd(cfg, args) {
345
349
  return 0;
346
350
  }
347
351
 
352
+ // Persist server/token into the USER config (never a committable repo config).
353
+ // Shared by 'join' and the 'install --server/--token' configure step. Only the
354
+ // keys given are touched, so a token-only update keeps the existing server.
355
+ function writeServerToken(home, server, token) {
356
+ const cfgFile = path.join(home, "config.json");
357
+ let data = {};
358
+ try {
359
+ data = JSON.parse(fs.readFileSync(cfgFile, "utf8")) || {};
360
+ } catch {
361
+ /* absent or malformed — start fresh */
362
+ }
363
+ if (server) data.server = server.replace(/\/+$/, "");
364
+ if (token) data.token = token;
365
+ fs.mkdirSync(home, { recursive: true });
366
+ fs.writeFileSync(cfgFile, JSON.stringify(data, null, 2) + "\n");
367
+ return cfgFile;
368
+ }
369
+
348
370
  // --- spor join / login --------------------------------------------------
349
371
  // Write server+token to USER config (never a committable repo config), then
350
372
  // confirm immediately — the upgrade research found no one-step way to point a
@@ -357,21 +379,11 @@ async function cmdJoin(cfg, args) {
357
379
  err("usage: spor join <server-url> <token>");
358
380
  return 1;
359
381
  }
360
- const home = cfg.graphHome();
361
- const cfgFile = path.join(home, "config.json");
362
- let data = {};
363
- try {
364
- data = JSON.parse(fs.readFileSync(cfgFile, "utf8")) || {};
365
- } catch {
366
- /* absent or malformed — start fresh */
367
- }
368
- data.server = server.replace(/\/+$/, "");
369
- if (token) data.token = token;
382
+ let cfgFile;
370
383
  try {
371
- fs.mkdirSync(home, { recursive: true });
372
- fs.writeFileSync(cfgFile, JSON.stringify(data, null, 2) + "\n");
384
+ cfgFile = writeServerToken(cfg.graphHome(), server, token);
373
385
  } catch (e) {
374
- err(`could not write ${cfgFile}: ${e.message}`);
386
+ err(`could not write config: ${e.message}`);
375
387
  return 1;
376
388
  }
377
389
  out(`wrote server${token ? " + token" : ""} to ${cfgFile}`);
@@ -640,6 +652,259 @@ function cmdLink(args) {
640
652
  return 0;
641
653
  }
642
654
 
655
+ // --- spor install / setup: wire spor into a host agent ---------------------
656
+ // dec-cc-portable-core-adapters ships a manifest per host under adapters/<host>/
657
+ // with a __SPOR_ROOT__ placeholder; installing one resolves the placeholder to
658
+ // THIS checkout and drops/merges the manifest into the host's config location.
659
+ // Until now this was a manual sed/ln recipe in each adapter README — this verb
660
+ // is its automation. Claude Code is special: it has no flat hook file, so we
661
+ // shell out to its plugin CLI (this repo IS the marketplace) rather than
662
+ // hand-edit ~/.claude/settings.json, which the CLI owns.
663
+ const HOSTS = {
664
+ claude: { kind: "claude", label: "Claude Code" },
665
+ codex: { kind: "hooks", label: "Codex CLI", src: ["adapters", "codex", "hooks.json"], user: [".codex", "hooks.json"], repo: [".codex", "hooks.json"] },
666
+ cursor: { kind: "hooks", label: "Cursor", src: ["adapters", "cursor", "hooks.json"], user: [".cursor", "hooks.json"], repo: [".cursor", "hooks.json"] },
667
+ copilot: { kind: "hooks", label: "GitHub Copilot CLI", src: ["adapters", "copilot", "spor.json"], user: [".copilot", "hooks", "spor.json"], repo: [".github", "hooks", "spor.json"] },
668
+ gemini: { kind: "hooks", label: "Gemini CLI", src: ["adapters", "gemini", "hooks", "hooks.json"], user: [".gemini", "settings.json"], repo: [".gemini", "settings.json"] },
669
+ opencode: { kind: "plugin", label: "OpenCode", src: ["adapters", "opencode", "spor.js"], user: [".config", "opencode", "plugins", "spor.js"], repo: [".opencode", "plugins", "spor.js"] },
670
+ };
671
+
672
+ // The config dir whose presence means a host is set up on this machine.
673
+ const HOST_PROBE = {
674
+ codex: [".codex"],
675
+ cursor: [".cursor"],
676
+ copilot: [".copilot"],
677
+ gemini: [".gemini"],
678
+ opencode: [".config", "opencode"],
679
+ claude: [".claude"],
680
+ };
681
+
682
+ // $HOME first so tests (and conventional overrides) win; os.homedir() is the
683
+ // cross-platform fallback (USERPROFILE on Windows).
684
+ function homeDir() {
685
+ return process.env.HOME || process.env.USERPROFILE || os.homedir();
686
+ }
687
+
688
+ // Options that consume the following token, so positional parsing can skip it.
689
+ const INSTALL_VALUE_OPTS = new Set(["scope", "server", "token"]);
690
+ function positionals(args) {
691
+ const pos = [];
692
+ for (let i = 0; i < args.length; i++) {
693
+ const a = args[i];
694
+ if (a.startsWith("--")) {
695
+ if (INSTALL_VALUE_OPTS.has(a.slice(2))) i++; // skip its value
696
+ continue;
697
+ }
698
+ pos.push(a);
699
+ }
700
+ return pos;
701
+ }
702
+
703
+ function deepReplace(v, from, to) {
704
+ if (typeof v === "string") return v.split(from).join(to);
705
+ if (Array.isArray(v)) return v.map((x) => deepReplace(x, from, to));
706
+ if (v && typeof v === "object") {
707
+ const o = {};
708
+ for (const k of Object.keys(v)) o[k] = deepReplace(v[k], from, to);
709
+ return o;
710
+ }
711
+ return v;
712
+ }
713
+
714
+ // Parse the manifest template as JSON, THEN substitute the root into string
715
+ // values — so a Windows root with backslashes never has to survive JSON escaping.
716
+ function renderManifest(srcSegs) {
717
+ const raw = fs.readFileSync(path.join(ROOT, ...srcSegs), "utf8");
718
+ return deepReplace(JSON.parse(raw), "__SPOR_ROOT__", ROOT);
719
+ }
720
+
721
+ function readJsonOr(file, fallback) {
722
+ try {
723
+ return JSON.parse(fs.readFileSync(file, "utf8")) || fallback;
724
+ } catch {
725
+ return fallback;
726
+ }
727
+ }
728
+
729
+ // Merge our hooks.{event:[...]} into an existing host config without clobbering
730
+ // the user's own hooks or top-level keys. Idempotent: prior spor entries (any
731
+ // whose command mentions spor-hook) are dropped first, so re-install refreshes a
732
+ // stale __SPOR_ROOT__ path instead of duplicating.
733
+ function mergeHooks(existing, incoming) {
734
+ const merged = existing && typeof existing === "object" && !Array.isArray(existing) ? existing : {};
735
+ for (const k of Object.keys(incoming)) {
736
+ if (k === "hooks") continue;
737
+ if (merged[k] === undefined) merged[k] = incoming[k];
738
+ }
739
+ merged.hooks = merged.hooks && typeof merged.hooks === "object" ? merged.hooks : {};
740
+ const inHooks = incoming.hooks || {};
741
+ for (const event of Object.keys(inHooks)) {
742
+ const prior = Array.isArray(merged.hooks[event]) ? merged.hooks[event] : [];
743
+ const kept = prior.filter((e) => !JSON.stringify(e).includes("spor-hook"));
744
+ merged.hooks[event] = kept.concat(inHooks[event]);
745
+ }
746
+ return merged;
747
+ }
748
+
749
+ function targetPath(spec, scope) {
750
+ return scope === "repo" ? path.join(repoRoot(), ...spec.repo) : path.join(homeDir(), ...spec.user);
751
+ }
752
+
753
+ function hasCmd(cmd) {
754
+ try {
755
+ return !spawnSync(cmd, ["--version"], { stdio: "ignore" }).error;
756
+ } catch {
757
+ return false;
758
+ }
759
+ }
760
+
761
+ function detectHosts() {
762
+ const home = homeDir();
763
+ const found = [];
764
+ for (const h of Object.keys(HOST_PROBE)) {
765
+ if (h === "claude") {
766
+ if (hasCmd("claude") || fs.existsSync(path.join(home, ".claude"))) found.push(h);
767
+ continue;
768
+ }
769
+ if (fs.existsSync(path.join(home, ...HOST_PROBE[h]))) found.push(h);
770
+ }
771
+ return found;
772
+ }
773
+
774
+ // Claude Code: shell out to its plugin CLI (the stable contract; settings.json
775
+ // is CLI-owned). The marketplace IS this repo (.claude-plugin/marketplace.json,
776
+ // name "spor"), so 'marketplace add <ROOT>' then 'install spor@spor'.
777
+ function installClaude(scope, dryRun) {
778
+ const cliScope = scope === "repo" ? "project" : "user";
779
+ const addArgs = ["plugin", "marketplace", "add", ROOT];
780
+ const instArgs = ["plugin", "install", "spor@spor", "--scope", cliScope];
781
+ if (dryRun) {
782
+ out(`would run: claude ${addArgs.join(" ")}`);
783
+ out(`would run: claude ${instArgs.join(" ")}`);
784
+ return 0;
785
+ }
786
+ if (!hasCmd("claude")) {
787
+ err("claude CLI not on PATH — install Claude Code, then re-run 'spor install claude'.");
788
+ err(`meanwhile, load spor without a marketplace per session: claude --plugin-dir ${ROOT}`);
789
+ return 1;
790
+ }
791
+ const add = spawnSync("claude", addArgs, { encoding: "utf8" });
792
+ if (add.status !== 0 && !/already|exists|known/i.test((add.stderr || "") + (add.stdout || ""))) {
793
+ err(`claude plugin marketplace add failed: ${(add.stderr || add.stdout || "").trim() || "unknown error"}`);
794
+ return 1;
795
+ }
796
+ const inst = spawnSync("claude", instArgs, { stdio: "inherit" });
797
+ if (inst.status !== 0) {
798
+ err(`claude plugin install failed (exit ${inst.status == null ? "?" : inst.status})`);
799
+ return 1;
800
+ }
801
+ out(`installed spor@spor into Claude Code (scope: ${cliScope}) — no marketplace browsing needed.`);
802
+ return 0;
803
+ }
804
+
805
+ // JSON-hook hosts (codex/cursor/copilot/gemini): render + merge into the target.
806
+ function installHookHost(spec, scope, dryRun) {
807
+ const target = targetPath(spec, scope);
808
+ const merged = mergeHooks(readJsonOr(target, {}), renderManifest(spec.src));
809
+ if (dryRun) {
810
+ out(`would write ${target}:`);
811
+ out(JSON.stringify(merged, null, 2));
812
+ return 0;
813
+ }
814
+ fs.mkdirSync(path.dirname(target), { recursive: true });
815
+ fs.writeFileSync(target, JSON.stringify(merged, null, 2) + "\n");
816
+ out(`installed spor for ${spec.label} → ${target} (scope: ${scope})`);
817
+ return 0;
818
+ }
819
+
820
+ // OpenCode has no command hooks — a JS plugin file is symlinked into place so it
821
+ // resolves the core via the link; copy is the Windows/EPERM fallback.
822
+ function installPluginHost(spec, scope, dryRun) {
823
+ const src = path.join(ROOT, ...spec.src);
824
+ const target = targetPath(spec, scope);
825
+ if (dryRun) {
826
+ out(`would link ${target} -> ${src}`);
827
+ return 0;
828
+ }
829
+ fs.mkdirSync(path.dirname(target), { recursive: true });
830
+ try {
831
+ fs.rmSync(target, { force: true });
832
+ } catch {
833
+ /* nothing there */
834
+ }
835
+ let how = "linked";
836
+ try {
837
+ fs.symlinkSync(src, target);
838
+ } catch {
839
+ fs.copyFileSync(src, target);
840
+ how = "copied";
841
+ }
842
+ out(`installed spor for ${spec.label} → ${target} (${how}, scope: ${scope})`);
843
+ if (how === "copied") out(` note: copied (no symlink here) — export SPOR_ROOT=${ROOT} so the plugin finds its core.`);
844
+ return 0;
845
+ }
846
+
847
+ async function cmdInstall(cfg, args) {
848
+ const dryRun = args.includes("--print") || args.includes("--dry-run");
849
+ let scope = optVal(args, "scope") || "user";
850
+ if (scope === "project") scope = "repo";
851
+ if (scope !== "user" && scope !== "repo") {
852
+ err(`invalid --scope '${scope}' — use 'user' or 'repo'`);
853
+ return 1;
854
+ }
855
+
856
+ const pos = positionals(args);
857
+ const bad = pos.find((a) => !HOSTS[a]);
858
+ if (bad) {
859
+ err(`unknown host '${bad}' — known: ${Object.keys(HOSTS).join(", ")}`);
860
+ return 1;
861
+ }
862
+ let hosts = pos.slice();
863
+ if (args.includes("--all")) hosts = detectHosts();
864
+
865
+ // The "configure" half: persist server/token to user config when given.
866
+ const server = optVal(args, "server");
867
+ const token = optVal(args, "token");
868
+ if ((server || token) && !dryRun) {
869
+ try {
870
+ const f = writeServerToken(cfg.graphHome(), server, token);
871
+ out(`wrote ${[server && "server", token && "token"].filter(Boolean).join(" + ")} to ${f}`);
872
+ } catch (e) {
873
+ err(`could not write config: ${e.message}`);
874
+ }
875
+ }
876
+
877
+ if (!hosts.length) {
878
+ // Discovery mode — show what is installable; touch nothing.
879
+ const found = detectHosts();
880
+ out("Usage: spor install <host>... [--scope user|repo] [--all] [--print]");
881
+ out(`Hosts: ${Object.keys(HOSTS).join(", ")}`);
882
+ out(found.length ? `Detected here: ${found.join(", ")} (try: spor install ${found.join(" ")})` : "No host config dirs detected yet.");
883
+ out("Claude Code: 'spor install claude' wires the plugin via its CLI — no marketplace browsing.");
884
+ return 0;
885
+ }
886
+
887
+ let rc = 0;
888
+ for (const host of hosts) {
889
+ const spec = HOSTS[host];
890
+ let r;
891
+ if (spec.kind === "claude") r = installClaude(scope, dryRun);
892
+ else if (spec.kind === "plugin") r = installPluginHost(spec, scope, dryRun);
893
+ else r = installHookHost(spec, scope, dryRun);
894
+ if (r !== 0) rc = r;
895
+ }
896
+
897
+ if (!dryRun && hosts.some((h) => HOSTS[h].kind !== "claude")) {
898
+ out("");
899
+ out("next:");
900
+ if (cfg.mode() === "remote") out(` remote mode is configured (${remote.base(cfg)}).`);
901
+ else out(" point at a graph: spor join <server-url> <token> (or export SPOR_SERVER/SPOR_TOKEN)");
902
+ out(" distiller backend (hosts without the claude CLI) + on-demand MCP access: see adapters/<host>/README.md");
903
+ out(" approve the hooks on first run if the host prompts.");
904
+ }
905
+ return rc;
906
+ }
907
+
643
908
  function version() {
644
909
  try {
645
910
  return require(path.join(ROOT, "package.json")).version || "0.0.0";
@@ -668,6 +933,9 @@ async function main() {
668
933
  return 0;
669
934
  case "init":
670
935
  return cmdInit(cfg);
936
+ case "install":
937
+ case "setup":
938
+ return await cmdInstall(cfg, args);
671
939
  case "status":
672
940
  return await cmdStatus(cfg);
673
941
  case "whoami":
package/lib/remote.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  // remote.js — minimal zero-dependency REST client for the Spor server, used by
3
3
  // the bin/spor CLI in remote mode (dec-cc-spor-cli-universal-surface step 3).
4
- // `fetch` is a Node 18+ global (package.json engines), so no dependency.
4
+ // `fetch` is a Node 20+ global (package.json engines), so no dependency.
5
5
  //
6
6
  // Fail-open parity with the hooks (dec-cc-fail-open-hooks): a transport error
7
7
  // (DNS, refused, timeout) resolves to { ok:false, transport:true } rather than
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@sporhq/spor",
3
- "version": "0.1.1",
3
+ "version": "0.2.1",
4
4
  "description": "Spor — a shared memory substrate for teams and agents. Decisions, their reasons, and the traces they leave. Knowledge-graph context compiler: session-start briefings, per-prompt digests, capture at discovery, end-of-session distillation, decision queue.",
5
- "license": "MIT",
5
+ "license": "Apache-2.0",
6
6
  "author": "Anthony Allen",
7
7
  "homepage": "https://sporhq.io",
8
8
  "repository": {
@@ -39,13 +39,15 @@
39
39
  "workers/",
40
40
  "API.md",
41
41
  "GRAPH.md",
42
- "QUEUE.md"
42
+ "QUEUE.md",
43
+ "NOTICE",
44
+ "TRADEMARKS.md"
43
45
  ],
44
46
  "scripts": {
45
47
  "test": "node --test test/*.test.js",
46
48
  "conformance": "node conformance/runner.js"
47
49
  },
48
50
  "engines": {
49
- "node": ">=18"
51
+ "node": ">=20"
50
52
  }
51
53
  }