@agentteams/cli 0.1.131 → 0.1.133

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/.eslintcache +1 -1
  2. package/dist/api/runner.d.ts +26 -0
  3. package/dist/api/runner.d.ts.map +1 -0
  4. package/dist/api/runner.js +49 -0
  5. package/dist/api/runner.js.map +1 -0
  6. package/dist/commands/init.d.ts +32 -7
  7. package/dist/commands/init.d.ts.map +1 -1
  8. package/dist/commands/init.js +121 -21
  9. package/dist/commands/init.js.map +1 -1
  10. package/dist/commands/initRunner.d.ts +92 -0
  11. package/dist/commands/initRunner.d.ts.map +1 -0
  12. package/dist/commands/initRunner.js +371 -0
  13. package/dist/commands/initRunner.js.map +1 -0
  14. package/dist/mcp/deleteConfirmation.d.ts +73 -0
  15. package/dist/mcp/deleteConfirmation.d.ts.map +1 -0
  16. package/dist/mcp/deleteConfirmation.js +93 -0
  17. package/dist/mcp/deleteConfirmation.js.map +1 -0
  18. package/dist/mcp/server.d.ts +24 -0
  19. package/dist/mcp/server.d.ts.map +1 -1
  20. package/dist/mcp/server.js +246 -3
  21. package/dist/mcp/server.js.map +1 -1
  22. package/dist/mcp/skillLocalCopies.d.ts +28 -0
  23. package/dist/mcp/skillLocalCopies.d.ts.map +1 -0
  24. package/dist/mcp/skillLocalCopies.js +53 -0
  25. package/dist/mcp/skillLocalCopies.js.map +1 -0
  26. package/dist/mcp/skillSource.d.ts +66 -0
  27. package/dist/mcp/skillSource.d.ts.map +1 -0
  28. package/dist/mcp/skillSource.js +108 -0
  29. package/dist/mcp/skillSource.js.map +1 -0
  30. package/dist/mcp/writeTools.d.ts +8 -0
  31. package/dist/mcp/writeTools.d.ts.map +1 -1
  32. package/dist/mcp/writeTools.js +9 -0
  33. package/dist/mcp/writeTools.js.map +1 -1
  34. package/dist/program/init.d.ts +9 -1
  35. package/dist/program/init.d.ts.map +1 -1
  36. package/dist/program/init.js +37 -11
  37. package/dist/program/init.js.map +1 -1
  38. package/dist/utils/conventionLink.d.ts +26 -0
  39. package/dist/utils/conventionLink.d.ts.map +1 -1
  40. package/dist/utils/conventionLink.js +78 -1
  41. package/dist/utils/conventionLink.js.map +1 -1
  42. package/dist/utils/initOutput.d.ts +5 -1
  43. package/dist/utils/initOutput.d.ts.map +1 -1
  44. package/dist/utils/initOutput.js +264 -8
  45. package/dist/utils/initOutput.js.map +1 -1
  46. package/dist/utils/spinner.d.ts +13 -0
  47. package/dist/utils/spinner.d.ts.map +1 -1
  48. package/dist/utils/spinner.js +15 -1
  49. package/dist/utils/spinner.js.map +1 -1
  50. package/package.json +1 -1
@@ -0,0 +1,26 @@
1
+ /** A runner as the member-facing list returns it. Only the fields init reads. */
2
+ export interface RunnerSummary {
3
+ id: string;
4
+ machineId: string | null;
5
+ label: string | null;
6
+ }
7
+ export interface RegisteredRunner {
8
+ id: string;
9
+ /** Returned exactly once, by registration. Never log or print it. */
10
+ token: string;
11
+ }
12
+ /** Runners owned by the signed-in member. Needs a personal login, not an agent key. */
13
+ export declare function listRunners(apiUrl: string, headers: Record<string, string>): Promise<RunnerSummary[]>;
14
+ export declare function registerRunner(apiUrl: string, headers: Record<string, string>, body: {
15
+ label: string;
16
+ }): Promise<RegisteredRunner>;
17
+ export declare function deleteRunner(apiUrl: string, headers: Record<string, string>, runnerId: string): Promise<void>;
18
+ /**
19
+ * Which runner a locally stored runner token belongs to, or `null` when the server
20
+ * no longer accepts it. Authenticates with the runner token itself, the way the
21
+ * runner does.
22
+ */
23
+ export declare function identifyRunnerToken(apiUrl: string, runnerToken: string): Promise<{
24
+ id: string;
25
+ } | null>;
26
+ //# sourceMappingURL=runner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../../src/api/runner.ts"],"names":[],"mappings":"AAEA,iFAAiF;AACjF,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CACtB;AAED,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,qEAAqE;IACrE,KAAK,EAAE,MAAM,CAAC;CACf;AAMD,uFAAuF;AACvF,wBAAsB,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC,CAU3G;AAED,wBAAsB,cAAc,CAClC,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC/B,IAAI,EAAE;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,GACtB,OAAO,CAAC,gBAAgB,CAAC,CAO3B;AAED,wBAAsB,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAEnH;AAED;;;;GAIG;AACH,wBAAsB,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAAC,CAY7G"}
@@ -0,0 +1,49 @@
1
+ import httpClient from '../utils/httpClient.js';
2
+ function asString(value) {
3
+ return typeof value === 'string' && value.length > 0 ? value : null;
4
+ }
5
+ /** Runners owned by the signed-in member. Needs a personal login, not an agent key. */
6
+ export async function listRunners(apiUrl, headers) {
7
+ const response = await httpClient.get(`${apiUrl}/api/daemons`, { headers });
8
+ const data = response.data?.data;
9
+ if (!Array.isArray(data))
10
+ return [];
11
+ return data.flatMap((entry) => {
12
+ const record = (entry ?? {});
13
+ const id = asString(record.id);
14
+ return id ? [{ id, machineId: asString(record.machineId), label: asString(record.label) }] : [];
15
+ });
16
+ }
17
+ export async function registerRunner(apiUrl, headers, body) {
18
+ const response = await httpClient.post(`${apiUrl}/api/daemons`, body, { headers });
19
+ const data = (response.data?.data ?? {});
20
+ const id = asString(data.id);
21
+ const token = asString(data.token);
22
+ if (!id || !token)
23
+ throw new Error('The server did not return a runner id and token.');
24
+ return { id, token };
25
+ }
26
+ export async function deleteRunner(apiUrl, headers, runnerId) {
27
+ await httpClient.delete(`${apiUrl}/api/daemons/${encodeURIComponent(runnerId)}`, { headers });
28
+ }
29
+ /**
30
+ * Which runner a locally stored runner token belongs to, or `null` when the server
31
+ * no longer accepts it. Authenticates with the runner token itself, the way the
32
+ * runner does.
33
+ */
34
+ export async function identifyRunnerToken(apiUrl, runnerToken) {
35
+ try {
36
+ const response = await httpClient.get(`${apiUrl}/api/daemons/me`, {
37
+ headers: { 'X-AgentTeams-Client': 'cli', 'x-daemon-token': runnerToken },
38
+ });
39
+ const id = asString(response.data?.data?.id);
40
+ return id ? { id } : null;
41
+ }
42
+ catch (error) {
43
+ const status = error.response?.status;
44
+ if (status === 401 || status === 403 || status === 404)
45
+ return null;
46
+ throw error;
47
+ }
48
+ }
49
+ //# sourceMappingURL=runner.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runner.js","sourceRoot":"","sources":["../../src/api/runner.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,wBAAwB,CAAC;AAehD,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;AACtE,CAAC;AAED,uFAAuF;AACvF,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,MAAc,EAAE,OAA+B;IAC/E,MAAM,QAAQ,GAAG,MAAM,UAAU,CAAC,GAAG,CAAC,GAAG,MAAM,cAAc,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;IAC5E,MAAM,IAAI,GAAY,QAAQ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,MAAM,gBAAgB,kBAAkB,CAAC,QAAQ,CAAC,EAAE,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;AAChG,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,MAAc,EAAE,WAAmB;IAC3E,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,MAAM,UAAU,CAAC,GAAG,CAAC,GAAG,MAAM,iBAAiB,EAAE;YAChE,OAAO,EAAE,EAAE,qBAAqB,EAAE,KAAK,EAAE,gBAAgB,EAAE,WAAW,EAAE;SACzE,CAAC,CAAC;QACH,MAAM,EAAE,GAAG,QAAQ,CAAE,QAAQ,CAAC,IAAI,EAAE,IAA4C,EAAE,EAAE,CAAC,CAAC;QACtF,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;IAC5B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,MAAM,GAAI,KAA4C,CAAC,QAAQ,EAAE,MAAM,CAAC;QAC9E,IAAI,MAAM,KAAK,GAAG,IAAI,MAAM,KAAK,GAAG,IAAI,MAAM,KAAK,GAAG;YAAE,OAAO,IAAI,CAAC;QACpE,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC"}
@@ -4,6 +4,7 @@ import type { AuthMode, Config } from '../types/index.js';
4
4
  import { type WorktreeInitResult } from './initWorktree.js';
5
5
  import type { InstallOutcome, McpPathContext, McpRegistrationDependencies } from '../mcp-registration/index.js';
6
6
  import type { DetectionDependencies } from '../mcp-registration/detect.js';
7
+ import { type InitRunnerDependencies, type InitRunnerResult } from './initRunner.js';
7
8
  import type { SessionHookStatus } from '../session-hooks/install.js';
8
9
  import { type EnsurePostCheckoutHookResult } from '../utils/conventionLink.js';
9
10
  export { bootstrapLinkedWorktree } from './initWorktree.js';
@@ -43,6 +44,13 @@ type InitOptions = {
43
44
  * Absent means init writes no client configuration at all.
44
45
  */
45
46
  mcp?: boolean;
47
+ /**
48
+ * Where MCP registration goes. `user` is what the `agentteams init` command asks
49
+ * for by default; `project` is `--mcp`; `off` is `--no-mcp`. Left unset — as tests
50
+ * and other callers of this function do — nothing is registered unless `mcp` is
51
+ * true, so no caller edits a machine-wide client config without saying so.
52
+ */
53
+ mcpScope?: InitAdapterScope | 'off';
46
54
  /** Injection seam so tests drive a temporary HOME/PATH and a fake vendor CLI. */
47
55
  mcpDependencies?: McpRegistrationDependencies;
48
56
  /**
@@ -50,6 +58,16 @@ type InitOptions = {
50
58
  * Absent means init writes no hook configuration at all.
51
59
  */
52
60
  sessionHook?: boolean;
61
+ /** Same contract as `mcpScope`, for the Claude Code SessionStart hook. */
62
+ sessionHookScope?: InitAdapterScope | 'off';
63
+ /**
64
+ * Register, install and start a runner on this machine. The `agentteams init`
65
+ * command turns this on by default and `--no-runner` turns it off; left unset, as
66
+ * tests and other callers do, nothing is installed.
67
+ */
68
+ runner?: boolean;
69
+ /** Test seam for the runner step: processes, files and the server are all injected. */
70
+ runnerDependencies?: InitRunnerDependencies;
53
71
  /** Injection seam so tests drive Claude Code detection with a temporary HOME/PATH. */
54
72
  sessionHookDependencies?: InitSessionHookDependencies;
55
73
  };
@@ -61,9 +79,11 @@ export type InitSessionHookDependencies = {
61
79
  * What `--session-hook` did. Present only when the flag was passed, so its absence is
62
80
  * the proof that a plain `agentteams init` touched no hook configuration.
63
81
  */
82
+ /** Which client configuration an init step writes: this machine's, or this repository's. */
83
+ export type InitAdapterScope = 'user' | 'project';
64
84
  export type InitSessionHookResult = {
65
85
  clientId: 'claude-code';
66
- scope: 'project';
86
+ scope: InitAdapterScope;
67
87
  /** `skipped`: Claude Code was not detected. `failed`: the install could not run. */
68
88
  status: SessionHookStatus | 'skipped' | 'failed';
69
89
  configPath: string | null;
@@ -82,12 +102,8 @@ export type InitMcpClientOutcome = {
82
102
  configPath: string;
83
103
  manualSnippet?: string;
84
104
  };
85
- /**
86
- * What `--mcp` did. Present only when the flag was passed, so its absence is the
87
- * proof that a plain `agentteams init` touched no client configuration.
88
- */
89
105
  export type InitMcpResult = {
90
- scope: 'project';
106
+ scope: InitAdapterScope;
91
107
  summary: {
92
108
  applied: number;
93
109
  skipped: number;
@@ -125,7 +141,12 @@ export type InitAdapterOutcome = {
125
141
  };
126
142
  export type AgentFileEntry = {
127
143
  relativePath: string;
128
- type: 'created' | 'example' | 'skipped' | 'upgraded';
144
+ /**
145
+ * `appended`: an existing file got the reference block added at its end.
146
+ * `referenced`: an existing file already pointed at the conventions; unchanged.
147
+ * `skipped`: an existing file that could not be extended safely; unchanged.
148
+ */
149
+ type: 'created' | 'example' | 'skipped' | 'upgraded' | 'appended' | 'referenced';
129
150
  };
130
151
  /** One entry point path that could not be written, and why. */
131
152
  export type AgentEntryPointWriteFailure = {
@@ -165,6 +186,8 @@ type OAuthInitResult = {
165
186
  mcp?: InitMcpResult;
166
187
  /** Present only when `--session-hook` was passed. Additive. */
167
188
  sessionHook?: InitSessionHookResult;
189
+ /** Present only when the runner step ran. Additive. */
190
+ runner?: InitRunnerResult;
168
191
  /** Canonical project root used for config, adapters, MCP, and hooks. */
169
192
  projectRoot?: string;
170
193
  /** Set when init was invoked from a subdirectory and operated on the enclosing project/git root. */
@@ -193,6 +216,8 @@ export type ConfiguredProjectInitResult = {
193
216
  mcp?: InitMcpResult;
194
217
  /** Present only when `--session-hook` was passed. Additive. */
195
218
  sessionHook?: InitSessionHookResult;
219
+ /** Present only when the runner step ran. Additive. */
220
+ runner?: InitRunnerResult;
196
221
  /** Canonical project root used for config, adapters, MCP, and hooks. */
197
222
  projectRoot?: string;
198
223
  /** Set when init was invoked from a subdirectory and operated on the enclosing project/git root. */
@@ -1 +1 @@
1
- {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AA0CA,OAAO,EAIL,KAAK,sBAAsB,EAC5B,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAwB,KAAK,YAAY,EAAE,MAAM,aAAa,CAAC;A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C;AAErF,MAAM,MAAM,iBAAiB,GAAG,iBAAiB,GAAG,oBAAoB,GAAG,aAAa,CAAC;AAEzF,MAAM,MAAM,oBAAoB,GAAG;IACjC,IAAI,EAAE,iBAAiB,CAAC;IACxB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC;IAC/B,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAoCF,wBAAgB,YAAY,IAAI,OAAO,GAAG,OAAO,GAAG,SAAS,GAAG,SAAS,CAcxE;AAED,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;;OAKG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,iBAAiB,GAAG,MAAM,CA0BlE;AA+UD;;;;;;;;;;;GAWG;AACH,wBAAgB,0BAA0B,CACxC,GAAG,EAAE,MAAM,EACX,gBAAgB,CAAC,EAAE,QAAQ,EAC3B,WAAW,GAAE,MAAkB,GAC9B,oBAAoB,CA6BtB;AAMD,wBAAsB,kBAAkB,CAAC,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC,CAEnF"}
@@ -21,7 +21,8 @@ import { readOrCreateMachineId } from '../utils/machineId.js';
21
21
  import { buildAuthHeaders } from '../utils/apiContext.js';
22
22
  import { AGENT_ENTRY_POINT_FILES, detectAgentEntryPointFiles, parseAgentFilesOption, } from '../utils/agentEntryPoints.js';
23
23
  import { bootstrapLinkedWorktree, resolveLinkedWorktreeSource } from './initWorktree.js';
24
- import { DEFAULT_CONVENTION_REFERENCE, upgradeLegacyConventionReference, ensurePostCheckoutHook, } from '../utils/conventionLink.js';
24
+ import { runInitRunnerStep } from './initRunner.js';
25
+ import { appendConventionReferenceBlock, DEFAULT_CONVENTION_REFERENCE, hasConventionReference, upgradeLegacyConventionReference, ensurePostCheckoutHook, } from '../utils/conventionLink.js';
25
26
  export { bootstrapLinkedWorktree } from './initWorktree.js';
26
27
  const AUTH_BASE_URL = process.env.AGENTTEAMS_WEB_URL || 'https://agentteams.run';
27
28
  const CONFIG_DIR = '.agentteams';
@@ -37,6 +38,26 @@ kmeQx6wGzG3OtYytKoOgbCY7wuRFOFoCphNPbaRzofnob/QM3hfLIyvgPDq6f6qG
37
38
  HVz0XnMxh/7GdXCHHBTasxC965LHgOcJRhMJ51vadetmX4Xv8yoo5zkAmvb37/yo
38
39
  JwIDAQAB
39
40
  -----END PUBLIC KEY-----`;
41
+ function resolveAdapterScope(scope, legacyFlag) {
42
+ if (scope === 'off')
43
+ return null;
44
+ if (scope)
45
+ return scope;
46
+ return legacyFlag === true ? 'project' : null;
47
+ }
48
+ /**
49
+ * What the MCP registration step did. Absent when the step did not run (`--no-mcp`,
50
+ * or a caller that never asked for it), so its absence is the proof that no client
51
+ * configuration was touched.
52
+ */
53
+ function readsAsConventionReference(fullPath) {
54
+ try {
55
+ return hasConventionReference(readFileSync(fullPath, 'utf-8'));
56
+ }
57
+ catch {
58
+ return false;
59
+ }
60
+ }
40
61
  function isSshEnvironment() {
41
62
  return Boolean(process.env.SSH_CONNECTION || process.env.SSH_CLIENT || process.env.SSH_TTY);
42
63
  }
@@ -304,7 +325,23 @@ function generateAgentEntryPointFiles(cwd, selectedFiles, options) {
304
325
  continue;
305
326
  }
306
327
  if (!options.createExample) {
307
- entries.push({ relativePath, type: 'skipped' });
328
+ // The Cursor rule file is ours alone and carries frontmatter that has to
329
+ // stay on its first line, so a different body there is not ours to extend.
330
+ // One that already names the conventions needs nothing, and saying it was
331
+ // "left untouched" on every re-run would report a problem that is not there.
332
+ const outcome = relativePath.endsWith('.mdc')
333
+ ? readsAsConventionReference(fullPath)
334
+ ? 'referenced'
335
+ : 'unsupported'
336
+ : appendConventionReferenceBlock(fullPath);
337
+ entries.push({
338
+ relativePath,
339
+ type: outcome === 'appended' || outcome === 'refreshed'
340
+ ? 'appended'
341
+ : outcome === 'referenced'
342
+ ? 'referenced'
343
+ : 'skipped',
344
+ });
308
345
  continue;
309
346
  }
310
347
  const ext = relativePath.includes('.') ? `.${relativePath.split('.').pop()}` : '';
@@ -712,12 +749,12 @@ async function runLegacyApiKeySetup(context) {
712
749
  * registry, and the scope is pinned to `project` — init may not choose the
713
750
  * machine-wide scope on the user's behalf.
714
751
  */
715
- async function runMcpRegistrationStep(cwd, dependencies) {
752
+ async function runMcpRegistrationStep(cwd, scope, dependencies) {
716
753
  try {
717
754
  const { applyMcpBatchInstall } = await import('../mcp-registration/index.js');
718
- const outcome = applyMcpBatchInstall({ scope: 'project' }, { ...dependencies, context: { cwd, ...(dependencies?.context ?? {}) } });
755
+ const outcome = applyMcpBatchInstall({ scope }, { ...dependencies, context: { cwd, ...(dependencies?.context ?? {}) } });
719
756
  return {
720
- scope: 'project',
757
+ scope,
721
758
  summary: outcome.summary,
722
759
  clients: outcome.results.map((result) => ({
723
760
  clientId: result.clientId,
@@ -730,14 +767,16 @@ async function runMcpRegistrationStep(cwd, dependencies) {
730
767
  }
731
768
  catch (error) {
732
769
  return {
733
- scope: 'project',
770
+ scope,
734
771
  summary: { applied: 0, skipped: 0, failed: 0 },
735
772
  clients: [],
736
773
  error: toErrorMessage(error),
737
774
  };
738
775
  }
739
776
  }
740
- const SESSION_HOOK_MANUAL_COMMAND = 'agentteams session hook install';
777
+ function sessionHookManualCommand(scope) {
778
+ return scope === 'user' ? 'agentteams session hook install --scope user --yes' : 'agentteams session hook install';
779
+ }
741
780
  /**
742
781
  * Install the Claude Code SessionStart hook for this project.
743
782
  *
@@ -750,8 +789,9 @@ const SESSION_HOOK_MANUAL_COMMAND = 'agentteams session hook install';
750
789
  * Like the MCP step it is imported lazily, pinned to project scope, and never throws —
751
790
  * a hook that could not be installed is a reported detail, not a failed init.
752
791
  */
753
- async function runSessionHookStep(cwd, dependencies) {
754
- const base = { clientId: 'claude-code', scope: 'project' };
792
+ async function runSessionHookStep(cwd, scope, dependencies) {
793
+ const manualCommand = sessionHookManualCommand(scope);
794
+ const base = { clientId: 'claude-code', scope };
755
795
  try {
756
796
  const [{ detectClients }, { installSessionHook }] = await Promise.all([
757
797
  import('../mcp-registration/index.js'),
@@ -766,10 +806,10 @@ async function runSessionHookStep(cwd, dependencies) {
766
806
  configPath: null,
767
807
  backupPath: null,
768
808
  message: 'Claude Code was not detected in this environment; no hook configuration was written.',
769
- manualCommand: SESSION_HOOK_MANUAL_COMMAND,
809
+ manualCommand,
770
810
  };
771
811
  }
772
- const installed = installSessionHook({ clientId: 'claude-code', scope: 'project', cwd });
812
+ const installed = installSessionHook({ clientId: 'claude-code', scope, cwd, homeDir: context.homeDir });
773
813
  return {
774
814
  ...base,
775
815
  status: installed.status,
@@ -785,12 +825,12 @@ async function runSessionHookStep(cwd, dependencies) {
785
825
  configPath: null,
786
826
  backupPath: null,
787
827
  message: 'The session hook could not be installed.',
788
- manualCommand: SESSION_HOOK_MANUAL_COMMAND,
828
+ manualCommand,
789
829
  error: toErrorMessage(error),
790
830
  };
791
831
  }
792
832
  }
793
- async function runConfiguredProjectInit(cwd, executionContext, adapterOptions, mcpOptions, sessionHookOptions) {
833
+ async function runConfiguredProjectInit(cwd, executionContext, adapterOptions, mcpOptions, sessionHookOptions, runnerOptions) {
794
834
  const configPath = executionContext.configPath;
795
835
  const projectConfig = executionContext.config;
796
836
  if (!configPath || !projectConfig) {
@@ -837,13 +877,22 @@ async function runConfiguredProjectInit(cwd, executionContext, adapterOptions, m
837
877
  const adapterPass = await runLocalAdapterPass(cwd, adapterOptions);
838
878
  // Registration runs after the binding and the credential are verified, because the
839
879
  // entry it writes is only useful once `agentteams mcp` can resolve this project.
840
- const mcp = mcpOptions.requested ? await runMcpRegistrationStep(cwd, mcpOptions.dependencies) : undefined;
880
+ const mcp = mcpOptions.scope
881
+ ? await runMcpRegistrationStep(cwd, mcpOptions.scope, mcpOptions.dependencies)
882
+ : undefined;
841
883
  // Same ordering reason: the hook runs `agentteams session sync`, which needs this binding.
842
- const sessionHook = sessionHookOptions.requested
843
- ? await runSessionHookStep(cwd, sessionHookOptions.dependencies)
884
+ const sessionHook = sessionHookOptions.scope
885
+ ? await runSessionHookStep(cwd, sessionHookOptions.scope, sessionHookOptions.dependencies)
844
886
  : undefined;
845
887
  const doctor = await executeDoctorCommand({ cwd, installWorktreeHook: adapterOptions.installWorktreeHook });
846
888
  const configuredAuthMode = runtimeConfig.credentialSource === 'personal-token' ? 'personal-token' : 'api-key';
889
+ const runner = runnerOptions.requested
890
+ ? await runInitRunnerStep({
891
+ apiUrl: runtimeConfig.apiUrl,
892
+ headers: buildAuthHeaders(runtimeConfig.apiKey),
893
+ personalLogin: configuredAuthMode === 'personal-token',
894
+ }, withEngineCount(runnerOptions.dependencies, mcp))
895
+ : undefined;
847
896
  const readiness = buildConfiguredProjectReadiness(conventionError, doctor, adapterPass.adapters);
848
897
  return {
849
898
  success: true,
@@ -864,6 +913,7 @@ async function runConfiguredProjectInit(cwd, executionContext, adapterOptions, m
864
913
  ...(adapterPass.postCheckoutHook ? { postCheckoutHook: adapterPass.postCheckoutHook } : {}),
865
914
  ...(mcp ? { mcp } : {}),
866
915
  ...(sessionHook ? { sessionHook } : {}),
916
+ ...(runner ? { runner } : {}),
867
917
  };
868
918
  }
869
919
  /**
@@ -1035,13 +1085,13 @@ async function runLocalAdapterPass(cwd, options) {
1035
1085
  };
1036
1086
  }
1037
1087
  const skipped = agentFiles.filter((file) => file.type === 'skipped');
1038
- if (skipped.length === agentFiles.length) {
1088
+ if (skipped.length > 0 && skipped.length === agentFiles.length) {
1039
1089
  return {
1040
1090
  status: 'SKIPPED',
1041
1091
  issues: [
1042
1092
  {
1043
1093
  code: 'agent-entry-points-exist',
1044
- message: `Left ${skipped.map((file) => file.relativePath).join(', ')} untouched because the file already exists.`,
1094
+ message: `Left ${skipped.map((file) => file.relativePath).join(', ')} untouched because the file could not be extended safely.`,
1045
1095
  },
1046
1096
  ],
1047
1097
  };
@@ -1131,6 +1181,8 @@ async function executeInitCommandWithContext(options) {
1131
1181
  allowPrompt: true,
1132
1182
  interactive: options?.interactive === true,
1133
1183
  };
1184
+ const mcpScope = resolveAdapterScope(options?.mcpScope, options?.mcp);
1185
+ const sessionHookScope = resolveAdapterScope(options?.sessionHookScope, options?.sessionHook);
1134
1186
  const executionContext = detectInitExecutionContext(cwd, options?.authMode);
1135
1187
  const projectRoot = executionContext.projectRoot;
1136
1188
  const reusedRootFromSubdir = toComparablePath(projectRoot) !== toComparablePath(cwd);
@@ -1141,7 +1193,7 @@ async function executeInitCommandWithContext(options) {
1141
1193
  }
1142
1194
  if (executionContext.kind === 'configured-project') {
1143
1195
  try {
1144
- const configuredResult = await runConfiguredProjectInit(projectRoot, executionContext, { ...adapterOptions, allowPrompt: adapterOptions.interactive }, { requested: options?.mcp === true, dependencies: options?.mcpDependencies }, { requested: options?.sessionHook === true, dependencies: options?.sessionHookDependencies });
1196
+ const configuredResult = await runConfiguredProjectInit(projectRoot, executionContext, { ...adapterOptions, allowPrompt: adapterOptions.interactive }, { scope: mcpScope, dependencies: options?.mcpDependencies }, { scope: sessionHookScope, dependencies: options?.sessionHookDependencies }, { requested: options?.runner === true, dependencies: options?.runnerDependencies });
1145
1197
  return {
1146
1198
  ...configuredResult,
1147
1199
  projectRoot,
@@ -1192,8 +1244,13 @@ async function executeInitCommandWithContext(options) {
1192
1244
  // Everything below runs *after* the credential and the config are stored, so
1193
1245
  // none of it may fail the init. Each adapter reports itself.
1194
1246
  const { adapters: localAdapters, agentFiles, postCheckoutHook, } = await runLocalAdapterPass(projectRoot, adapterOptions);
1195
- const mcp = options?.mcp === true ? await runMcpRegistrationStep(projectRoot, options?.mcpDependencies) : undefined;
1196
- const sessionHook = options?.sessionHook === true ? await runSessionHookStep(projectRoot, options?.sessionHookDependencies) : undefined;
1247
+ const mcp = mcpScope ? await runMcpRegistrationStep(projectRoot, mcpScope, options?.mcpDependencies) : undefined;
1248
+ const sessionHook = sessionHookScope
1249
+ ? await runSessionHookStep(projectRoot, sessionHookScope, options?.sessionHookDependencies)
1250
+ : undefined;
1251
+ const runner = options?.runner === true
1252
+ ? await runNewProjectRunnerStep(projectRoot, authMode, withEngineCount(options?.runnerDependencies, mcp))
1253
+ : undefined;
1197
1254
  const seedPlanId = setup.seedPlanId;
1198
1255
  const seedPlanWebUrl = seedPlanId ? `${AUTH_BASE_URL.replace(/\/+$/, '')}/go?type=plan&id=${seedPlanId}` : null;
1199
1256
  return {
@@ -1217,6 +1274,49 @@ async function executeInitCommandWithContext(options) {
1217
1274
  ...(setup.personalLogin ? { personalLogin: setup.personalLogin } : {}),
1218
1275
  ...(mcp ? { mcp } : {}),
1219
1276
  ...(sessionHook ? { sessionHook } : {}),
1277
+ ...(runner ? { runner } : {}),
1220
1278
  };
1221
1279
  }
1280
+ /**
1281
+ * Let the runner step say when there is no agent CLI for it to drive. The MCP step
1282
+ * has already looked for them, so its answer is reused instead of probing every
1283
+ * client a second time; when that step did not run, the note is simply not made.
1284
+ */
1285
+ function withEngineCount(dependencies, mcp) {
1286
+ if (dependencies?.countAgentEngines || !mcp || mcp.error)
1287
+ return dependencies;
1288
+ const found = mcp.clients.filter((client) => client.outcome !== 'SKIPPED_NOT_DETECTED' && client.outcome !== 'SKIPPED_NO_EXECUTABLE').length;
1289
+ return { ...dependencies, countAgentEngines: () => found };
1290
+ }
1291
+ /**
1292
+ * The runner step for a project this run just connected. The credential is read
1293
+ * back the way every later command will read it, so the step proves the stored
1294
+ * login works rather than reusing what the setup flow still holds in memory.
1295
+ */
1296
+ async function runNewProjectRunnerStep(projectRoot, authMode, dependencies) {
1297
+ try {
1298
+ const runtimeConfig = await loadConfigWithCredential({}, { cwd: projectRoot });
1299
+ if (!runtimeConfig) {
1300
+ return {
1301
+ status: 'degraded',
1302
+ reason: 'The stored login could not be read back to set up a runner.',
1303
+ notes: [],
1304
+ retryCommand: 'agentteams init',
1305
+ };
1306
+ }
1307
+ return await runInitRunnerStep({
1308
+ apiUrl: runtimeConfig.apiUrl,
1309
+ headers: buildAuthHeaders(runtimeConfig.apiKey),
1310
+ personalLogin: authMode === 'personal-token',
1311
+ }, dependencies);
1312
+ }
1313
+ catch (error) {
1314
+ return {
1315
+ status: 'degraded',
1316
+ reason: `The runner step stopped unexpectedly (${toErrorMessage(error)}).`,
1317
+ notes: [],
1318
+ retryCommand: 'agentteams init',
1319
+ };
1320
+ }
1321
+ }
1222
1322
  //# sourceMappingURL=init.js.map