@meshpoint/cli 1.0.0-rc.4 → 1.1.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 CHANGED
@@ -1,202 +1,21 @@
1
-
2
- Apache License
3
- Version 2.0, January 2004
4
- http://www.apache.org/licenses/
5
-
6
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
-
8
- 1. Definitions.
9
-
10
- "License" shall mean the terms and conditions for use, reproduction,
11
- and distribution as defined by Sections 1 through 9 of this document.
12
-
13
- "Licensor" shall mean the copyright owner or entity authorized by
14
- the copyright owner that is granting the License.
15
-
16
- "Legal Entity" shall mean the union of the acting entity and all
17
- other entities that control, are controlled by, or are under common
18
- control with that entity. For the purposes of this definition,
19
- "control" means (i) the power, direct or indirect, to cause the
20
- direction or management of such entity, whether by contract or
21
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
- outstanding shares, or (iii) beneficial ownership of such entity.
23
-
24
- "You" (or "Your") shall mean an individual or Legal Entity
25
- exercising permissions granted by this License.
26
-
27
- "Source" form shall mean the preferred form for making modifications,
28
- including but not limited to software source code, documentation
29
- source, and configuration files.
30
-
31
- "Object" form shall mean any form resulting from mechanical
32
- transformation or translation of a Source form, including but
33
- not limited to compiled object code, generated documentation,
34
- and conversions to other media types.
35
-
36
- "Work" shall mean the work of authorship, whether in Source or
37
- Object form, made available under the License, as indicated by a
38
- copyright notice that is included in or attached to the work
39
- (an example is provided in the Appendix below).
40
-
41
- "Derivative Works" shall mean any work, whether in Source or Object
42
- form, that is based on (or derived from) the Work and for which the
43
- editorial revisions, annotations, elaborations, or other modifications
44
- represent, as a whole, an original work of authorship. For the purposes
45
- of this License, Derivative Works shall not include works that remain
46
- separable from, or merely link (or bind by name) to the interfaces of,
47
- the Work and Derivative Works thereof.
48
-
49
- "Contribution" shall mean any work of authorship, including
50
- the original version of the Work and any modifications or additions
51
- to that Work or Derivative Works thereof, that is intentionally
52
- submitted to Licensor for inclusion in the Work by the copyright owner
53
- or by an individual or Legal Entity authorized to submit on behalf of
54
- the copyright owner. For the purposes of this definition, "submitted"
55
- means any form of electronic, verbal, or written communication sent
56
- to the Licensor or its representatives, including but not limited to
57
- communication on electronic mailing lists, source code control systems,
58
- and issue tracking systems that are managed by, or on behalf of, the
59
- Licensor for the purpose of discussing and improving the Work, but
60
- excluding communication that is conspicuously marked or otherwise
61
- designated in writing by the copyright owner as "Not a Contribution."
62
-
63
- "Contributor" shall mean Licensor and any individual or Legal Entity
64
- on behalf of whom a Contribution has been received by Licensor and
65
- subsequently incorporated within the Work.
66
-
67
- 2. Grant of Copyright License. Subject to the terms and conditions of
68
- this License, each Contributor hereby grants to You a perpetual,
69
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
- copyright license to reproduce, prepare Derivative Works of,
71
- publicly display, publicly perform, sublicense, and distribute the
72
- Work and such Derivative Works in Source or Object form.
73
-
74
- 3. Grant of Patent License. Subject to the terms and conditions of
75
- this License, each Contributor hereby grants to You a perpetual,
76
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
- (except as stated in this section) patent license to make, have made,
78
- use, offer to sell, sell, import, and otherwise transfer the Work,
79
- where such license applies only to those patent claims licensable
80
- by such Contributor that are necessarily infringed by their
81
- Contribution(s) alone or by combination of their Contribution(s)
82
- with the Work to which such Contribution(s) was submitted. If You
83
- institute patent litigation against any entity (including a
84
- cross-claim or counterclaim in a lawsuit) alleging that the Work
85
- or a Contribution incorporated within the Work constitutes direct
86
- or contributory patent infringement, then any patent licenses
87
- granted to You under this License for that Work shall terminate
88
- as of the date such litigation is filed.
89
-
90
- 4. Redistribution. You may reproduce and distribute copies of the
91
- Work or Derivative Works thereof in any medium, with or without
92
- modifications, and in Source or Object form, provided that You
93
- meet the following conditions:
94
-
95
- (a) You must give any other recipients of the Work or
96
- Derivative Works a copy of this License; and
97
-
98
- (b) You must cause any modified files to carry prominent notices
99
- stating that You changed the files; and
100
-
101
- (c) You must retain, in the Source form of any Derivative Works
102
- that You distribute, all copyright, patent, trademark, and
103
- attribution notices from the Source form of the Work,
104
- excluding those notices that do not pertain to any part of
105
- the Derivative Works; and
106
-
107
- (d) If the Work includes a "NOTICE" text file as part of its
108
- distribution, then any Derivative Works that You distribute must
109
- include a readable copy of the attribution notices contained
110
- within such NOTICE file, excluding those notices that do not
111
- pertain to any part of the Derivative Works, in at least one
112
- of the following places: within a NOTICE text file distributed
113
- as part of the Derivative Works; within the Source form or
114
- documentation, if provided along with the Derivative Works; or,
115
- within a display generated by the Derivative Works, if and
116
- wherever such third-party notices normally appear. The contents
117
- of the NOTICE file are for informational purposes only and
118
- do not modify the License. You may add Your own attribution
119
- notices within Derivative Works that You distribute, alongside
120
- or as an addendum to the NOTICE text from the Work, provided
121
- that such additional attribution notices cannot be construed
122
- as modifying the License.
123
-
124
- You may add Your own copyright statement to Your modifications and
125
- may provide additional or different license terms and conditions
126
- for use, reproduction, or distribution of Your modifications, or
127
- for any such Derivative Works as a whole, provided Your use,
128
- reproduction, and distribution of the Work otherwise complies with
129
- the conditions stated in this License.
130
-
131
- 5. Submission of Contributions. Unless You explicitly state otherwise,
132
- any Contribution intentionally submitted for inclusion in the Work
133
- by You to the Licensor shall be under the terms and conditions of
134
- this License, without any additional terms or conditions.
135
- Notwithstanding the above, nothing herein shall supersede or modify
136
- the terms of any separate license agreement you may have executed
137
- with Licensor regarding such Contributions.
138
-
139
- 6. Trademarks. This License does not grant permission to use the trade
140
- names, trademarks, service marks, or product names of the Licensor,
141
- except as required for reasonable and customary use in describing the
142
- origin of the Work and reproducing the content of the NOTICE file.
143
-
144
- 7. Disclaimer of Warranty. Unless required by applicable law or
145
- agreed to in writing, Licensor provides the Work (and each
146
- Contributor provides its Contributions) on an "AS IS" BASIS,
147
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
- implied, including, without limitation, any warranties or conditions
149
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
- PARTICULAR PURPOSE. You are solely responsible for determining the
151
- appropriateness of using or redistributing the Work and assume any
152
- risks associated with Your exercise of permissions under this License.
153
-
154
- 8. Limitation of Liability. In no event and under no legal theory,
155
- whether in tort (including negligence), contract, or otherwise,
156
- unless required by applicable law (such as deliberate and grossly
157
- negligent acts) or agreed to in writing, shall any Contributor be
158
- liable to You for damages, including any direct, indirect, special,
159
- incidental, or consequential damages of any character arising as a
160
- result of this License or out of the use or inability to use the
161
- Work (including but not limited to damages for loss of goodwill,
162
- work stoppage, computer failure or malfunction, or any and all
163
- other commercial damages or losses), even if such Contributor
164
- has been advised of the possibility of such damages.
165
-
166
- 9. Accepting Warranty or Additional Liability. While redistributing
167
- the Work or Derivative Works thereof, You may choose to offer,
168
- and charge a fee for, acceptance of support, warranty, indemnity,
169
- or other liability obligations and/or rights consistent with this
170
- License. However, in accepting such obligations, You may act only
171
- on Your own behalf and on Your sole responsibility, not on behalf
172
- of any other Contributor, and only if You agree to indemnify,
173
- defend, and hold each Contributor harmless for any liability
174
- incurred by, or claims asserted against, such Contributor by reason
175
- of your accepting any such warranty or additional liability.
176
-
177
- END OF TERMS AND CONDITIONS
178
-
179
- APPENDIX: How to apply the Apache License to your work.
180
-
181
- To apply the Apache License to your work, attach the following
182
- boilerplate notice, with the fields enclosed by brackets "[]"
183
- replaced with your own identifying information. (Don't include
184
- the brackets!) The text should be enclosed in the appropriate
185
- comment syntax for the file format. We also recommend that a
186
- file or class name and description of purpose be included on the
187
- same "printed page" as the copyright notice for easier
188
- identification within third-party archives.
189
-
190
- Copyright [yyyy] [name of copyright owner]
191
-
192
- Licensed under the Apache License, Version 2.0 (the "License");
193
- you may not use this file except in compliance with the License.
194
- You may obtain a copy of the License at
195
-
196
- http://www.apache.org/licenses/LICENSE-2.0
197
-
198
- Unless required by applicable law or agreed to in writing, software
199
- distributed under the License is distributed on an "AS IS" BASIS,
200
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
- See the License for the specific language governing permissions and
202
- limitations under the License.
1
+ MIT License
2
+
3
+ Copyright (c) 2026 COMPUTERSHIT LLC
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.
package/README.md CHANGED
@@ -1,12 +1,11 @@
1
1
  # meshpoint clients
2
2
 
3
- The `meshpoint` CLI and harness adapters for Meshpoint 1.0. Adapters: Claude Code, Codex, Cursor, Antigravity, pi, opencode, OpenClaw. Claude Code, Codex, pi, opencode and OpenClaw are verified live against staging; Cursor and Antigravity are ported from their published hook docs and need a live check.
3
+ The `meshpoint` CLI and harness adapters for Meshpoint, shared agent memory for developer teams. Adapters: Claude Code, Codex, Cursor, Antigravity, pi, opencode, OpenClaw. Claude Code, Codex, pi, opencode and OpenClaw are verified live against staging; Cursor and Antigravity are ported from their published hook docs and need a live check.
4
4
 
5
5
  ## Install
6
6
 
7
7
  ```
8
- npm i -g @meshpoint/cli@next # 1.0.0-rc prereleases, until 1.0
9
- npm i -g @meshpoint/cli # at 1.0
8
+ npm i -g @meshpoint/cli
10
9
  ```
11
10
 
12
11
  ```
@@ -33,6 +32,7 @@ meshpoint status # config + project id for the current repo
33
32
  meshpoint items put --item gotcha 'title' 'body' # write items for the current repo and branch
34
33
  meshpoint items put < items.json # same, as a JSON array of {kind, title, body}
35
34
  meshpoint items retract 3f9c1a2b # retract by id or unique id prefix
35
+ meshpoint items confirm 3f9c1a2b # confirm by id or prefix (counts toward rank)
36
36
  ```
37
37
 
38
38
  `connect <harness>` without `--project` writes to your user config, so every repo you open is on the mesh. `--project <dir>` writes into one repo instead; the files then travel with the repo in git. The meshpoint testbed on the maintainers' machines uses `--project` only.
@@ -101,6 +101,16 @@ Distillation is agent-side: the platform runs no model. `connect` installs the `
101
101
 
102
102
  The session-start inject shows each item's id prefix so the skill can retract what the session made obsolete (`meshpoint items retract <prefix>...`, resolved against a fresh recall; ambiguous prefixes are refused).
103
103
 
104
+ ## Refs, verification and the edit hook
105
+
106
+ `items put` reads repo-relative paths out of each item's title and body (`src/auth.ts`, `package.json`, backticked `Makefile`), keeps the ones that exist as the item's `refs`, attaches the files edited on the branch since the last checkpoint (recorded by every adapter under `~/.local/state/meshpoint/touched/`) as `paths`, and records HEAD as `commit_sha`. Path-like tokens that resolve to nothing print `ref not found: <path>` so the agent can fix a typo.
107
+
108
+ At session start the tap asks for the whole branch, verifies every item with refs against the checkout (no model: `fs.stat` per ref, one `git log --since` per item, two seconds in total), and cuts the inject to 3,000 tokens itself. Verified items confirm; items whose refs changed since are marked `?`; items whose refs are gone move to a "Possibly stale" list the skill tells the agent to resolve. A checkout that does not contain the item's commit skips it. Sightings go to `POST /v1/items/verify`; three users seeing an item stale drop it from recall (the console can restore it).
109
+
110
+ The edit hook runs around file edits: Claude Code and Codex `PreToolUse` (Codex matches `apply_patch` under `Edit|Write` and the tap reads the files out of the patch), opencode `tool.execute.after`, pi `tool_result`, Cursor `postToolUse`. It injects the file's gotcha, decision and convention items (from the session-start cache, two at most) and anyone else who touched the file in the last five minutes on any branch (`GET /v1/context`, one second budget). One notice per file per session, kept in `~/.local/state/meshpoint/edits/`. Every path fails open.
111
+
112
+ A branch with no items and committed instruction files (`git ls-files` over CLAUDE.md, AGENTS.md, `.cursor/rules/*`, `.github/copilot-instructions.md`, `.kiro/steering/*.md` and friends) gets one nudge to run the `meshpoint-import` skill, which `connect` installs next to `meshpoint`.
113
+
104
114
  A checkpoint is due after 20 assistant replies or 60k chars of reply text since the later of the last checkpoint and the last nudge (`~/.local/state/meshpoint/nudges/<session>.json`). An ignored nudge is not repeated until the next pile. The benchmark behind this: one-shot items scored 0.67 resume correctness against 0.60 for a freeform summary and 0.32 for a transcript tail (ceiling 0.82).
105
115
 
106
116
  The project id is derived from `git remote get-url origin` (`host--owner--repo`); directories without an origin remote are ignored.
@@ -120,4 +130,4 @@ Publishing (maintainers, after `npm login`): `npm publish` in `../meshpoint-sdk`
120
130
 
121
131
  ## License
122
132
 
123
- Apache-2.0. See [LICENSE](LICENSE).
133
+ MIT. See [LICENSE](LICENSE).
@@ -1,7 +1,7 @@
1
1
  import { mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
2
2
  import { homedir } from "node:os";
3
3
  import path from "node:path";
4
- import { skillMarkdown, SKILL_NAME } from "../claude-code/skill.js";
4
+ import { IMPORT_SKILL_NAME, importSkillMarkdown, skillMarkdown, SKILL_NAME } from "../claude-code/skill.js";
5
5
  export const ANTIGRAVITY_TAP_COMMAND = "meshpoint tap antigravity";
6
6
  export const MESHPOINT_GROUP = "meshpoint";
7
7
  export const ANTIGRAVITY_EVENTS = ["SessionStart", "PreInvocation", "Stop"];
@@ -40,11 +40,15 @@ export function connectAntigravity(opts) {
40
40
  else
41
41
  rmSync(paths.hooks, { force: true });
42
42
  rmSync(paths.skillDir, { recursive: true, force: true });
43
+ rmSync(path.join(path.dirname(paths.skillDir), IMPORT_SKILL_NAME), { recursive: true, force: true });
43
44
  return `removed the ${MESHPOINT_GROUP} hook group from ${paths.hooks} and ${paths.skillDir}`;
44
45
  }
45
46
  mkdirSync(path.dirname(paths.hooks), { recursive: true });
46
47
  writeFileSync(paths.hooks, `${JSON.stringify(installAntigravityHooks(file), null, 2)}\n`);
47
48
  mkdirSync(paths.skillDir, { recursive: true });
48
49
  writeFileSync(path.join(paths.skillDir, "SKILL.md"), skillMarkdown({ allowedTools: false }));
50
+ const importDir = path.join(path.dirname(paths.skillDir), IMPORT_SKILL_NAME);
51
+ mkdirSync(importDir, { recursive: true });
52
+ writeFileSync(path.join(importDir, "SKILL.md"), importSkillMarkdown({ allowedTools: false }));
49
53
  return `installed the ${MESHPOINT_GROUP} hook group in ${paths.hooks} (${ANTIGRAVITY_EVENTS.join(", ")}) and ${paths.skillDir}/SKILL.md. Antigravity loads hooks.json on the next conversation; toggle it under Customizations > Hooks.`;
50
54
  }
@@ -70,6 +70,9 @@ export async function runAntigravityTap(payload, deps) {
70
70
  ...(deps.fetch ? { fetch: deps.fetch } : {}),
71
71
  ...(deps.presenceWaitMs !== undefined ? { presenceWaitMs: deps.presenceWaitMs } : {}),
72
72
  ...(deps.refresh ? { refresh: deps.refresh } : {}),
73
+ ...(deps.touched ? { touched: deps.touched } : {}),
74
+ ...(deps.cache ? { cache: deps.cache } : {}),
75
+ ...(deps.local ? { local: deps.local(repo.root) } : {}),
73
76
  });
74
77
  const conversations = new Conversations(deps.stateDir);
75
78
  const transcript = () => {
package/dist/bin.js CHANGED
@@ -16,11 +16,14 @@ import { ReplyLog, runOpenclawTap } from "./openclaw/tap.js";
16
16
  import { connectPi } from "./pi/connect.js";
17
17
  import { Checkpoints } from "./checkpoints.js";
18
18
  import { configPath, deleteConfig, loadConfig, repoContext, saveConfig, spoolDir, stateDir } from "./config.js";
19
+ import { SessionCache } from "./context.js";
20
+ import { localChecks } from "./tap.js";
21
+ import { Touched } from "./touched.js";
19
22
  import { MeshpointError } from "@meshpoint/sdk";
20
23
  import { api, ApiError, canOpenBrowser, deviceLogin, freshConfig, login } from "./control.js";
21
24
  import { detectHarnesses, renderDetected } from "./detect.js";
22
25
  import { renderDoctor, runDoctor } from "./doctor.js";
23
- import { parseItemArgs, parseItems, putItems, retractItems } from "./items.js";
26
+ import { confirmItems, parseItemArgs, parseItems, putItems, retractItems } from "./items.js";
24
27
  import { Spool } from "./spool.js";
25
28
  const USAGE = `meshpoint <command>
26
29
 
@@ -68,6 +71,7 @@ const USAGE = `meshpoint <command>
68
71
  write items for the current repo and branch; the file or
69
72
  stdin form takes a JSON array of {kind, title, body}
70
73
  items retract <id>... retract items on the current branch; an id may be a prefix
74
+ items confirm <id>... confirm items on the current branch (counts toward their rank)
71
75
  tap claude-code | codex | cursor | antigravity [<event>] | openclaw
72
76
  hook entry point; reads one hook payload on stdin
73
77
  `;
@@ -231,8 +235,8 @@ async function main(argv) {
231
235
  return 0;
232
236
  }
233
237
  case "items": {
234
- if (rest[0] !== "put" && rest[0] !== "retract")
235
- throw new Error("items supports: put, retract");
238
+ if (rest[0] !== "put" && rest[0] !== "retract" && rest[0] !== "confirm")
239
+ throw new Error("items supports: put, retract, confirm");
236
240
  const config = await requireConfig();
237
241
  const repo = repoContext(process.cwd());
238
242
  if (!repo)
@@ -241,9 +245,15 @@ async function main(argv) {
241
245
  console.log(JSON.stringify(await withAuth(config, (c) => retractItems(rest.slice(1), { config: c, repo }))));
242
246
  return 0;
243
247
  }
248
+ if (rest[0] === "confirm") {
249
+ console.log(JSON.stringify(await withAuth(config, (c) => confirmItems(rest.slice(1), { config: c, repo }))));
250
+ return 0;
251
+ }
244
252
  const file = flag(rest, "--file");
245
253
  const drafts = rest.includes("--item") ? parseItemArgs(rest.slice(1)) : parseItems(file ? readFileSync(file, "utf8") : await readStdin());
246
- const out = await withAuth(config, (c) => putItems(drafts, { config: c, repo, checkpoints: new Checkpoints(stateDir()) }));
254
+ const { missing, ...out } = await withAuth(config, (c) => putItems(drafts, { config: c, repo, checkpoints: new Checkpoints(stateDir()), touched: new Touched(stateDir()) }));
255
+ for (const m of missing)
256
+ console.error(`ref not found: ${m}`);
247
257
  console.log(JSON.stringify({ ...out, project: repo.project, branch: repo.branch }));
248
258
  return 0;
249
259
  }
@@ -270,6 +280,9 @@ async function main(argv) {
270
280
  readTranscript: (file) => readFileSync(file, "utf8"),
271
281
  spool: new Spool(spoolDir()),
272
282
  checkpoints: new Checkpoints(stateDir()),
283
+ touched: new Touched(stateDir()),
284
+ cache: new SessionCache(stateDir()),
285
+ local: (root) => localChecks(root),
273
286
  });
274
287
  // Each harness has its own "do nothing" answer, needed even without a login.
275
288
  if (harness === "cursor") {
@@ -2,7 +2,7 @@ import { mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
2
2
  import { homedir } from "node:os";
3
3
  import path from "node:path";
4
4
  import { installTapHooks, removeTapHooks } from "./settings.js";
5
- import { SKILL_MD, SKILL_NAME } from "./skill.js";
5
+ import { IMPORT_SKILL_MD, IMPORT_SKILL_NAME, SKILL_MD, SKILL_NAME } from "./skill.js";
6
6
  export function claudeConfigDir(env = process.env, home = homedir()) {
7
7
  return env.CLAUDE_CONFIG_DIR || path.join(home, ".claude");
8
8
  }
@@ -12,6 +12,7 @@ export function connectClaudeCode(opts) {
12
12
  const configDir = opts.configDir ?? claudeConfigDir();
13
13
  const settingsPath = path.join(configDir, "settings.json");
14
14
  const skillDir = path.join(configDir, "skills", SKILL_NAME);
15
+ const importSkillDir = path.join(configDir, "skills", IMPORT_SKILL_NAME);
15
16
  let settings = {};
16
17
  try {
17
18
  settings = JSON.parse(readFileSync(settingsPath, "utf8"));
@@ -27,9 +28,12 @@ export function connectClaudeCode(opts) {
27
28
  writeFileSync(settingsPath, `${JSON.stringify(next, null, 2)}\n`);
28
29
  if (opts.remove) {
29
30
  rmSync(skillDir, { recursive: true, force: true });
30
- return `removed meshpoint hooks from ${settingsPath} and ${skillDir}`;
31
+ rmSync(importSkillDir, { recursive: true, force: true });
32
+ return `removed meshpoint hooks from ${settingsPath}, ${skillDir} and ${importSkillDir}`;
31
33
  }
32
34
  mkdirSync(skillDir, { recursive: true });
33
35
  writeFileSync(path.join(skillDir, "SKILL.md"), SKILL_MD);
34
- return `installed meshpoint hooks in ${settingsPath} (SessionStart, UserPromptSubmit, Stop, PreCompact, SessionEnd) and ${skillDir}/SKILL.md`;
36
+ mkdirSync(importSkillDir, { recursive: true });
37
+ writeFileSync(path.join(importSkillDir, "SKILL.md"), IMPORT_SKILL_MD);
38
+ return `installed meshpoint hooks in ${settingsPath} (SessionStart, UserPromptSubmit, PreToolUse on edits, Stop, PreCompact, SessionEnd), ${skillDir}/SKILL.md and ${importSkillDir}/SKILL.md`;
35
39
  }
@@ -2,10 +2,14 @@
2
2
  // meshpoint tap, so re-running connect upgrades in place and never touches hooks the user wrote.
3
3
  export const TAP_COMMAND = "meshpoint tap claude-code";
4
4
  const HOOK_TIMEOUT_S = 30;
5
- // SessionStart includes "compact": the items are what survives a context loss.
5
+ export const EDIT_TOOLS_MATCHER = "Edit|Write|MultiEdit|NotebookEdit";
6
+ const EDIT_HOOK_TIMEOUT_S = 5;
7
+ // SessionStart includes "compact": the items are what survives a context loss. PreToolUse on the
8
+ // editing tools carries the file-level notice (items naming the file, teammates on it).
6
9
  export const MANAGED_EVENTS = [
7
10
  { event: "SessionStart", matcher: "startup|resume|clear|compact" },
8
11
  { event: "UserPromptSubmit" },
12
+ { event: "PreToolUse", matcher: EDIT_TOOLS_MATCHER, timeout: EDIT_HOOK_TIMEOUT_S },
9
13
  { event: "Stop" },
10
14
  { event: "PreCompact" },
11
15
  { event: "SessionEnd" },
@@ -21,10 +25,10 @@ function withoutManaged(groups) {
21
25
  }
22
26
  export function installTapHooks(settings, spec = CLAUDE_CODE_SPEC) {
23
27
  const hooks = { ...settings.hooks };
24
- for (const { event, matcher } of spec.events) {
28
+ for (const { event, matcher, timeout } of spec.events) {
25
29
  hooks[event] = [
26
30
  ...withoutManaged(hooks[event]),
27
- { ...(matcher === undefined ? {} : { matcher }), hooks: [{ type: "command", command: spec.command, timeout: HOOK_TIMEOUT_S, ...spec.extra }] },
31
+ { ...(matcher === undefined ? {} : { matcher }), hooks: [{ type: "command", command: spec.command, timeout: timeout ?? HOOK_TIMEOUT_S, ...spec.extra }] },
28
32
  ];
29
33
  }
30
34
  return { ...settings, hooks };
@@ -32,6 +32,8 @@ Each item is an object \`{"kind", "title", "body"}\`. \`kind\` is one of:
32
32
  - Only what this session established. Never invent.
33
33
  - Skip anything already listed under "Team knowledge" in the session-start context unless it changed; a changed decision or status gets a new item.
34
34
  - Retract items that this session made wrong or obsolete: a finished todo, a superseded status, a reversed decision. The first column of "Team knowledge" is the item id.
35
+ - Items under "Possibly stale" name a file that is gone from this checkout. Check whether each still holds; retract it or write a corrected item. Do not leave them.
36
+ - Name files by their repo-relative path (\`src/auth/token.ts\`, not "the token file"). Meshpoint links the item to those files, checks them in later checkouts, and shows the item when someone edits them. The command warns about paths it cannot find.
35
37
  - Prefer durable knowledge over moment-to-moment detail. Aim for 5 to 30 items; one \`status\` item at most.
36
38
  - No secrets, tokens, or credentials.
37
39
 
@@ -54,3 +56,45 @@ meshpoint items retract 3f9c1a2b 7d0e44aa
54
56
  Then continue the work you were doing.
55
57
  `;
56
58
  export const SKILL_MD = skillMarkdown({ allowedTools: true });
59
+ // The import skill: seeds a branch with no memory from the repository's committed instruction
60
+ // files. Offered once per branch by the session-start inject.
61
+ export const IMPORT_SKILL_NAME = "meshpoint-import";
62
+ export function importSkillMarkdown(opts) {
63
+ return `---
64
+ name: ${IMPORT_SKILL_NAME}
65
+ description: Seed Meshpoint team knowledge for a branch that has none from the repository's committed instruction files (CLAUDE.md, AGENTS.md, Cursor rules, Copilot instructions). Use when the Meshpoint session-start context says the branch has no team knowledge yet.
66
+ ${opts.allowedTools ? "allowed-tools: Bash(meshpoint items put:*), Bash(git ls-files:*)\n" : ""}---
67
+ ${IMPORT_SKILL_BODY}`;
68
+ }
69
+ const IMPORT_SKILL_BODY = `
70
+ # Meshpoint import
71
+
72
+ Turn the repository's instruction files into Meshpoint items, once.
73
+
74
+ ## Read
75
+
76
+ The session-start context lists the files. Read each one. They are committed files such as \`CLAUDE.md\`, \`AGENTS.md\`, \`.cursor/rules/*\`, \`.github/copilot-instructions.md\`.
77
+
78
+ ## Select
79
+
80
+ Keep only statements about this repository that a teammate's agent needs:
81
+
82
+ - \`convention\`: how things are done here ("tests run with \`pnpm test\`", "migrations live in \`db/migrations\`").
83
+ - \`fact\`: a stable truth about the code or environment ("CI pins Node 22").
84
+ - \`gotcha\`: something that bites ("\`npm install\` fails without the private registry token").
85
+
86
+ Skip instructions aimed at the model rather than the repository ("be concise", "ask before refactoring"), prose that only introduces a section, and anything already true of every project. One item per rule. At most 30 items. Name files by their repo-relative path.
87
+
88
+ ## Write
89
+
90
+ One command, one \`--item kind title body\` per item. Single quotes; no single quote character inside (write "do not", not "don't").
91
+
92
+ \`\`\`bash
93
+ meshpoint items put \\
94
+ --item convention 'Tests run with pnpm test' 'package.json scripts.test runs vitest; CI runs the same command.' \\
95
+ --item fact 'CI pins Node 22' '.github/workflows/ci.yml uses actions/setup-node with node-version 22.'
96
+ \`\`\`
97
+
98
+ Then continue the work you were doing. Do not run this skill again on this branch.
99
+ `;
100
+ export const IMPORT_SKILL_MD = importSkillMarkdown({ allowedTools: true });
@@ -1,6 +1,21 @@
1
+ import { patchFilePaths } from "../codex/transcript.js";
1
2
  import { Tap } from "../tap.js";
2
3
  import { lastAssistantTurn, parseTranscript as parseClaudeCodeTranscript } from "./transcript.js";
3
4
  export { renderInject } from "../tap.js";
5
+ const TOOL_PATH_KEYS = ["file_path", "path", "notebook_path"];
6
+ // One apply_patch can touch several files; the notice covers the first few.
7
+ const PATCH_FILES_MAX = 3;
8
+ // The files an editing tool call is about: Claude Code names one in tool_input; Codex's
9
+ // apply_patch carries the whole patch in tool_input.command.
10
+ export function toolFilePaths(input) {
11
+ for (const key of TOOL_PATH_KEYS) {
12
+ const v = input?.[key];
13
+ if (typeof v === "string" && v)
14
+ return [v];
15
+ }
16
+ const command = input?.command;
17
+ return typeof command === "string" ? patchFilePaths(command).slice(0, PATCH_FILES_MAX) : [];
18
+ }
4
19
  // One hook event in, one JSON answer out. Claude Code and Codex share the hook protocol (event
5
20
  // names, payload fields, additionalContext, Stop block), so one wrapper serves both. The Tap
6
21
  // swallows mesh failures; this layer only speaks the hook protocol.
@@ -20,6 +35,9 @@ export async function runClaudeCodeTap(payload, deps) {
20
35
  ...(deps.fetch ? { fetch: deps.fetch } : {}),
21
36
  ...(deps.presenceWaitMs !== undefined ? { presenceWaitMs: deps.presenceWaitMs } : {}),
22
37
  ...(deps.refresh ? { refresh: deps.refresh } : {}),
38
+ ...(deps.touched ? { touched: deps.touched } : {}),
39
+ ...(deps.cache ? { cache: deps.cache } : {}),
40
+ ...(deps.local ? { local: deps.local(repo.root) } : {}),
23
41
  });
24
42
  const transcript = () => {
25
43
  if (!payload.transcript_path)
@@ -39,6 +57,16 @@ export async function runClaudeCodeTap(payload, deps) {
39
57
  case "UserPromptSubmit":
40
58
  await tap.user(payload.prompt ?? "");
41
59
  return "{}";
60
+ case "PreToolUse":
61
+ case "PostToolUse": {
62
+ const notices = [];
63
+ for (const file of toolFilePaths(payload.tool_input)) {
64
+ const text = await tap.edit(file);
65
+ if (text)
66
+ notices.push(text);
67
+ }
68
+ return notices.length > 0 ? JSON.stringify({ hookSpecificOutput: { hookEventName: event, additionalContext: notices.join("\n\n") } }) : "{}";
69
+ }
42
70
  case "Stop": {
43
71
  const entries = transcript();
44
72
  const turn = lastAssistantTurn(entries);
@@ -1,14 +1,15 @@
1
1
  import { mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
2
2
  import { homedir } from "node:os";
3
3
  import path from "node:path";
4
- import { skillMarkdown, SKILL_NAME } from "../claude-code/skill.js";
4
+ import { IMPORT_SKILL_NAME, importSkillMarkdown, skillMarkdown, SKILL_NAME } from "../claude-code/skill.js";
5
5
  import { installTapHooks, removeTapHooks } from "../claude-code/settings.js";
6
6
  export const CODEX_TAP_COMMAND = "meshpoint tap codex";
7
7
  // Codex truncates additionalContext at 2500 chars by default; a recall inject is up to ~12k.
8
8
  const CONTEXT_LIMIT = 100_000;
9
9
  export const CODEX_SPEC = {
10
10
  command: CODEX_TAP_COMMAND,
11
- events: [{ event: "SessionStart" }, { event: "UserPromptSubmit" }, { event: "Stop" }, { event: "PreCompact" }, { event: "SessionEnd" }],
11
+ // Codex matches apply_patch under the Edit|Write aliases; the hook reads the files out of the patch.
12
+ events: [{ event: "SessionStart" }, { event: "UserPromptSubmit" }, { event: "PreToolUse", matcher: "Edit|Write", timeout: 5 }, { event: "Stop" }, { event: "PreCompact" }, { event: "SessionEnd" }],
12
13
  extra: { additionalContextLimit: CONTEXT_LIMIT },
13
14
  };
14
15
  // Codex approves commands by prefix rules, not per skill; "allow" also runs them outside the
@@ -55,6 +56,7 @@ export function connectCodex(opts) {
55
56
  rmSync(paths.hooks, { force: true });
56
57
  rmSync(paths.rules, { force: true });
57
58
  rmSync(paths.skillDir, { recursive: true, force: true });
59
+ rmSync(path.join(path.dirname(paths.skillDir), IMPORT_SKILL_NAME), { recursive: true, force: true });
58
60
  return `removed meshpoint hooks from ${paths.hooks}, ${paths.rules} and ${paths.skillDir}`;
59
61
  }
60
62
  mkdirSync(path.dirname(paths.hooks), { recursive: true });
@@ -63,5 +65,8 @@ export function connectCodex(opts) {
63
65
  writeFileSync(paths.rules, RULES);
64
66
  mkdirSync(paths.skillDir, { recursive: true });
65
67
  writeFileSync(path.join(paths.skillDir, "SKILL.md"), skillMarkdown({ allowedTools: false }));
68
+ const importDir = path.join(path.dirname(paths.skillDir), IMPORT_SKILL_NAME);
69
+ mkdirSync(importDir, { recursive: true });
70
+ writeFileSync(path.join(importDir, "SKILL.md"), importSkillMarkdown({ allowedTools: false }));
66
71
  return `installed meshpoint hooks in ${paths.hooks}, rules in ${paths.rules} and ${paths.skillDir}/SKILL.md. Project .codex files load only once the project is trusted in config.toml; Codex asks to trust new hooks on the next run (/hooks).`;
67
72
  }
@@ -5,6 +5,10 @@ const PATCH_PATH_RE = /^\*\*\* (?:Add|Update|Delete) File: (.+)$/gm;
5
5
  function isRecord(v) {
6
6
  return typeof v === "object" && v !== null && !Array.isArray(v);
7
7
  }
8
+ // File paths named in an apply_patch body ("*** Update File: src/x.ts").
9
+ export function patchFilePaths(patch) {
10
+ return [...patch.matchAll(PATCH_PATH_RE)].map((m) => m[1].trim()).filter(Boolean);
11
+ }
8
12
  function patchPaths(args) {
9
13
  if (typeof args !== "string")
10
14
  return [];
@@ -18,7 +22,7 @@ function patchPaths(args) {
18
22
  const patch = isRecord(input) ? (input.patch ?? input.input) : undefined;
19
23
  if (typeof patch !== "string")
20
24
  return [];
21
- return [...patch.matchAll(PATCH_PATH_RE)].map((m) => m[1].trim()).filter(Boolean);
25
+ return patchFilePaths(patch);
22
26
  }
23
27
  export function parseCodexTranscript(jsonl) {
24
28
  const entries = [];