@swmansion/argent 0.14.1-next.9 → 0.15.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/README.md CHANGED
@@ -114,14 +114,41 @@ npm install -g @swmansion/argent
114
114
  argent init
115
115
  ```
116
116
 
117
+ #### Share Argent with your team (committable install)
118
+
119
+ By default Argent installs **globally**. To version Argent _with your repo_ so every
120
+ teammate gets the same setup on `npm install` — no per-developer global install, no
121
+ `argent init` — choose the local mode:
122
+
123
+ ```bash
124
+ npx @swmansion/argent init --local
125
+ ```
126
+
127
+ This adds `@swmansion/argent` to your project's `devDependencies` and writes MCP
128
+ configs that launch the project-local copy (`node node_modules/@swmansion/argent/dist/cli.js mcp`).
129
+ Commit `package.json` + your lockfile, the generated MCP config (`.mcp.json`,
130
+ `.cursor/mcp.json`, …), `.argent/install.json`, and the skills/rules/agents files.
131
+ Teammates then just run `npm install`.
132
+
133
+ Pass `--global` to force the default mode in scripts; `--local` and `--global` are
134
+ mutually exclusive. A non-interactive (`--yes`) run defaults to global unless the
135
+ project already opted into local mode (a committed `.argent/install.json`, or
136
+ `@swmansion/argent` declared in the project's own `package.json`).
137
+
138
+ > In local mode the committed MCP config runs the project-local copy, so the bare
139
+ > `argent` command is **not** on teammates' `PATH`. Note that `npm install` builds
140
+ > Argent's native deps (`tree-sitter`) on each machine — prebuilt for macOS, Linux
141
+ > x64, and Windows x64; other targets (Linux arm64, Windows arm) compile from source
142
+ > and need a C/C++ toolchain.
143
+
117
144
  ## CLI Reference
118
145
 
119
146
  | Command | Description |
120
147
  | ------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
121
- | `argent init` | Install globally and configure MCP in the current workspace |
148
+ | `argent init` | Install and configure MCP in the current workspace (`--global` default, `--local` for a committable devDependency) |
122
149
  | `argent install` | Alias for `init` command |
123
- | `argent update` | Pull the latest version and refresh workspace configuration |
124
- | `argent remove` | Unregister the MCP server and uninstall the package |
150
+ | `argent update` | Pull the latest version and refresh workspace configuration (acts on the present install — both when a global install and a project devDependency coexist; `--global`/`--local` select explicitly) |
151
+ | `argent remove` | Unregister the MCP server and uninstall the package (`--global`/`--local` choose which install — and its configs — is removed; non-interactive runs never remove a coexisting global install) |
125
152
  | `argent uninstall` | Alias for `remove` command |
126
153
  | `argent mcp` | Start MCP server instance, used internally by agent |
127
154
  | `argent tools` | List tools exposed by the tool-server (`describe <name>` for details) |
@@ -133,7 +160,7 @@ argent init
133
160
  | `argent enable` | Enable a predefined feature flag (`--scope project` for project-local) |
134
161
  | `argent disable` | Disable a feature flag (`--scope project` for project-local) |
135
162
  | `argent flags` | List available feature flags and their state |
136
- | `argent telemetry` | Manage anonymous telemetry: `status` / `enable` / `disable` |
163
+ | `argent telemetry` | Manage telemetry: `status` / `enable` / `disable` |
137
164
 
138
165
  ## Supported Editors
139
166
 
@@ -154,7 +181,7 @@ argent init
154
181
 
155
182
  ## Privacy
156
183
 
157
- Argent collects anonymous, opt-out usage and diagnostic telemetry to help us prioritise features and fix what breaks. It is minimal by design.
184
+ Argent collects opt-out usage and diagnostic telemetry to help us prioritise features and fix what breaks.
158
185
 
159
186
  You can opt out at any time:
160
187
 
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -1,2 +1,3 @@
1
1
  import type { ToolsServerPaths } from "@argent/tools-client";
2
+ export declare function findStablePackageDir(startDir: string, packageRoot: string): string | undefined;
2
3
  export declare const BUNDLED_RUNTIME_PATHS: ToolsServerPaths;
@@ -1,9 +1,140 @@
1
+ import * as fs from "node:fs";
1
2
  import * as path from "node:path";
2
- // __dirname in ESM (compiled from TS) will be dist/.
3
- // Bundle artifacts ship next to the compiled launcher.
3
+ // Installed package version, read from the shipped package.json. Lets the
4
+ // launcher detect a stale tool-server after an in-place version bump (a local
5
+ // devDependency update rewrites tool-server.cjs at the same path) and respawn
6
+ // it — without relying on the postinstall script, which is frequently disabled
7
+ // (--ignore-scripts, pnpm onlyBuiltDependencies, Yarn PnP, locked-down CI).
8
+ function readPackageVersion() {
9
+ try {
10
+ const pkg = JSON.parse(fs.readFileSync(path.join(import.meta.dirname, "..", "package.json"), "utf8"));
11
+ return pkg.version;
12
+ }
13
+ catch {
14
+ return undefined;
15
+ }
16
+ }
17
+ const PACKAGE_NAME = "@swmansion/argent";
18
+ // The project a local install belongs to: the nearest ancestor of cwd that
19
+ // DECLARES the package (any dependency field, matching the installer's
20
+ // readManifestDeclaration) or carries a committed .argent/install.json. Can
21
+ // sit BELOW the physical hoist root — npm workspaces hoist a member's
22
+ // devDependency, but update/uninstall must act on the declaring member.
23
+ function findDeclaringRoot(startDir) {
24
+ let dir = startDir;
25
+ for (;;) {
26
+ if (fs.existsSync(path.join(dir, ".argent", "install.json")))
27
+ return dir;
28
+ try {
29
+ const manifest = JSON.parse(fs.readFileSync(path.join(dir, "package.json"), "utf8"));
30
+ if (manifest.devDependencies?.[PACKAGE_NAME] ||
31
+ manifest.dependencies?.[PACKAGE_NAME] ||
32
+ manifest.optionalDependencies?.[PACKAGE_NAME]) {
33
+ return dir;
34
+ }
35
+ }
36
+ catch {
37
+ // no/unreadable manifest at this level — keep walking up
38
+ }
39
+ const parent = path.dirname(dir);
40
+ if (parent === dir)
41
+ return null;
42
+ dir = parent;
43
+ }
44
+ }
45
+ // The version-STABLE package dir: the conventional <dir>/node_modules/<pkg>
46
+ // symlink closest to cwd that resolves to the running package. Unlike
47
+ // import.meta's realpath — pnpm's version-pinned .pnpm store dir, pruned on a
48
+ // bump — this symlink survives an in-place update. In a pnpm WORKSPACE the
49
+ // symlink sits in the DECLARING member's node_modules, a level below the root
50
+ // where the .pnpm store lives, so scan every level from cwd up rather than
51
+ // only the level where the store matched. Only ever returns a path whose
52
+ // realpath equals the running package, so it can never point at a different
53
+ // install — just a different (stable) alias of the same real dir.
54
+ export function findStablePackageDir(startDir, packageRoot) {
55
+ let dir = startDir;
56
+ for (;;) {
57
+ const candidate = path.join(dir, "node_modules", PACKAGE_NAME);
58
+ try {
59
+ if (fs.realpathSync(candidate) === packageRoot)
60
+ return candidate;
61
+ }
62
+ catch {
63
+ // no symlink at this level — keep walking up
64
+ }
65
+ const parent = path.dirname(dir);
66
+ if (parent === dir)
67
+ return undefined;
68
+ dir = parent;
69
+ }
70
+ }
71
+ // Install topology of this running package: a project's local devDependency
72
+ // (package root inside a node_modules found by walking up from cwd) or the
73
+ // global PATH install — and, for local, WHICH project. Classified at process
74
+ // start, the moment cwd is trustworthy (a committed local MCP command only
75
+ // resolves with cwd at the project root); the launcher forwards both as
76
+ // ARGENT_INSTALL_KIND / ARGENT_PROJECT_ROOT so update-argent doesn't re-infer
77
+ // them from the detached server's editor-chosen cwd.
78
+ function classifyInstall() {
79
+ let packageRoot;
80
+ let dir;
81
+ let cwd;
82
+ try {
83
+ packageRoot = fs.realpathSync(path.join(import.meta.dirname, ".."));
84
+ // cwd can throw (ENOENT) when the shell's directory was deleted — and this
85
+ // runs at module import, before any fatal handler is installed.
86
+ cwd = process.cwd();
87
+ dir = cwd;
88
+ }
89
+ catch {
90
+ return { kind: "global" };
91
+ }
92
+ for (;;) {
93
+ try {
94
+ const nmReal = fs.realpathSync(path.join(dir, "node_modules"));
95
+ if (packageRoot === nmReal || packageRoot.startsWith(nmReal + path.sep)) {
96
+ // Local install. Prefer the DECLARING root over this physical hoist
97
+ // root: in a hoisted workspace the declaring manifest sits at cwd
98
+ // (the member root) or an ancestor below `dir`. The version-stable
99
+ // package dir (used for runtime paths that must survive a pnpm store
100
+ // prune) is found by its own cwd-up scan — see findStablePackageDir.
101
+ return {
102
+ kind: "local",
103
+ projectRoot: findDeclaringRoot(cwd) ?? dir,
104
+ stablePackageDir: findStablePackageDir(cwd, packageRoot),
105
+ };
106
+ }
107
+ }
108
+ catch {
109
+ // no node_modules at this level — keep walking up
110
+ }
111
+ const parent = path.dirname(dir);
112
+ if (parent === dir)
113
+ break;
114
+ dir = parent;
115
+ }
116
+ // Yarn PnP local installs have no node_modules anywhere: the package runs
117
+ // from the project's .yarn dir (unplugged/cache). Falling through to
118
+ // "global" would make the agent-triggered update target a global install
119
+ // the user may not even have.
120
+ if (packageRoot.includes(`${path.sep}.yarn${path.sep}`)) {
121
+ const declRoot = findDeclaringRoot(cwd);
122
+ if (declRoot)
123
+ return { kind: "local", projectRoot: declRoot };
124
+ }
125
+ return { kind: "global" };
126
+ }
127
+ const classifiedInstall = classifyInstall();
128
+ // __dirname in ESM (compiled from TS) will be dist/. Bundle artifacts ship
129
+ // next to the compiled launcher; prefer the version-stable package dir when
130
+ // the classification found one (see classifyInstall).
131
+ const packageDir = classifiedInstall.stablePackageDir ?? path.join(import.meta.dirname, "..");
4
132
  export const BUNDLED_RUNTIME_PATHS = {
5
- bundlePath: path.join(import.meta.dirname, "tool-server.cjs"),
6
- simulatorServerDir: path.join(import.meta.dirname, "..", "bin"),
7
- nativeDevtoolsDir: path.join(import.meta.dirname, "..", "dylibs"),
133
+ bundlePath: path.join(packageDir, "dist", "tool-server.cjs"),
134
+ simulatorServerDir: path.join(packageDir, "bin"),
135
+ nativeDevtoolsDir: path.join(packageDir, "dylibs"),
136
+ version: readPackageVersion(),
137
+ installKind: classifiedInstall.kind,
138
+ installProjectRoot: classifiedInstall.projectRoot,
8
139
  };
9
140
  //# sourceMappingURL=bundled-paths.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"bundled-paths.js","sourceRoot":"","sources":["../src/bundled-paths.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAGlC,qDAAqD;AACrD,uDAAuD;AACvD,MAAM,CAAC,MAAM,qBAAqB,GAAqB;IACrD,UAAU,EAAE,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,iBAAiB,CAAC;IAC7D,kBAAkB,EAAE,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,EAAE,KAAK,CAAC;IAC/D,iBAAiB,EAAE,IAAI,CAAC,IAAI,CAAC,M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