@intra-mart/accel 0.5.0-dev.202608040843 → 0.5.0-dev.202608180918

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 (114) hide show
  1. package/README.md +33 -31
  2. package/dist/asset/deployer.d.ts +2 -0
  3. package/dist/asset/deployer.js +11 -9
  4. package/dist/asset/git-provider.d.ts +1 -0
  5. package/dist/asset/git-provider.js +20 -9
  6. package/dist/asset/updater.d.ts +9 -2
  7. package/dist/asset/updater.js +12 -6
  8. package/dist/asset/walker.d.ts +2 -1
  9. package/dist/asset/walker.js +36 -0
  10. package/dist/commands/asset-provider.d.ts +1 -1
  11. package/dist/commands/asset-provider.js +2 -2
  12. package/dist/commands/attach.d.ts +116 -82
  13. package/dist/commands/attach.js +176 -145
  14. package/dist/commands/cache.js +11 -19
  15. package/dist/commands/deploy.d.ts +53 -32
  16. package/dist/commands/deploy.js +112 -75
  17. package/dist/commands/detach.d.ts +18 -0
  18. package/dist/commands/detach.js +69 -54
  19. package/dist/commands/init.d.ts +117 -83
  20. package/dist/commands/init.js +119 -98
  21. package/dist/commands/login.d.ts +12 -10
  22. package/dist/commands/login.js +14 -10
  23. package/dist/commands/preset.js +26 -33
  24. package/dist/commands/run-wrapper.d.ts +15 -0
  25. package/dist/commands/run-wrapper.js +62 -0
  26. package/dist/commands/switch.d.ts +48 -20
  27. package/dist/commands/switch.js +201 -176
  28. package/dist/commands/update.d.ts +142 -87
  29. package/dist/commands/update.js +342 -296
  30. package/dist/core/color-env.d.ts +1 -0
  31. package/dist/core/color-env.js +6 -0
  32. package/dist/core/constants.d.ts +0 -1
  33. package/dist/core/constants.js +0 -3
  34. package/dist/core/errors.d.ts +6 -0
  35. package/dist/core/errors.js +16 -0
  36. package/dist/core/logger.d.ts +15 -0
  37. package/dist/core/logger.js +1 -0
  38. package/dist/core/paths.d.ts +6 -0
  39. package/dist/core/paths.js +22 -0
  40. package/dist/core/types.d.ts +6 -1
  41. package/dist/core/validation.d.ts +34 -0
  42. package/dist/core/validation.js +87 -0
  43. package/dist/deploy/api-client.d.ts +1 -0
  44. package/dist/deploy/api-client.js +7 -1
  45. package/dist/git/config-file.d.ts +3 -0
  46. package/dist/git/config-file.js +178 -0
  47. package/dist/git/errors.d.ts +5 -0
  48. package/dist/git/errors.js +21 -2
  49. package/dist/git/git-objects.d.ts +11 -0
  50. package/dist/git/git-objects.js +49 -0
  51. package/dist/git/http.d.ts +2 -2
  52. package/dist/git/http.js +22 -10
  53. package/dist/git/index-file.d.ts +17 -0
  54. package/dist/git/index-file.js +111 -0
  55. package/dist/git/object-cache.d.ts +1 -0
  56. package/dist/git/object-cache.js +11 -15
  57. package/dist/git/object-store.d.ts +4 -0
  58. package/dist/git/object-store.js +82 -107
  59. package/dist/git/pack-parse.d.ts +19 -0
  60. package/dist/git/pack-parse.js +261 -0
  61. package/dist/git/pack-store.d.ts +20 -0
  62. package/dist/git/pack-store.js +144 -0
  63. package/dist/git/read-capped.d.ts +1 -0
  64. package/dist/git/read-capped.js +26 -0
  65. package/dist/git/redact-url.d.ts +1 -0
  66. package/dist/git/redact-url.js +14 -0
  67. package/dist/git/repo-layout.d.ts +5 -0
  68. package/dist/git/repo-layout.js +44 -0
  69. package/dist/git/smart-http.d.ts +3 -2
  70. package/dist/git/smart-http.js +5 -5
  71. package/dist/git/untracked.d.ts +11 -0
  72. package/dist/git/untracked.js +93 -0
  73. package/dist/git/worktree-status.d.ts +4 -0
  74. package/dist/git/worktree-status.js +140 -0
  75. package/dist/git/zlib-inflate.d.ts +7 -0
  76. package/dist/git/zlib-inflate.js +78 -0
  77. package/dist/i18n/en.js +12 -0
  78. package/dist/i18n/index.js +1 -1
  79. package/dist/i18n/ja.js +12 -0
  80. package/dist/i18n/zh_CN.js +12 -0
  81. package/dist/index.d.ts +1 -1
  82. package/dist/index.js +3 -2
  83. package/dist/interactive/asset-messages.d.ts +2 -1
  84. package/dist/interactive/asset-messages.js +4 -4
  85. package/dist/interactive/clack-logger.d.ts +2 -0
  86. package/dist/interactive/clack-logger.js +11 -0
  87. package/dist/interactive/credential-auth.d.ts +2 -0
  88. package/dist/interactive/credential-auth.js +7 -6
  89. package/dist/interactive/credentials-prompts.js +10 -6
  90. package/dist/interactive/next-steps.d.ts +2 -1
  91. package/dist/interactive/next-steps.js +3 -3
  92. package/dist/interactive/progress.d.ts +8 -1
  93. package/dist/interactive/progress.js +0 -0
  94. package/dist/interactive/prompts.d.ts +3 -33
  95. package/dist/interactive/prompts.js +23 -111
  96. package/dist/interactive/summary.d.ts +2 -1
  97. package/dist/interactive/summary.js +3 -3
  98. package/dist/juggling/resolve.d.ts +7 -0
  99. package/dist/juggling/resolve.js +18 -0
  100. package/dist/lib.d.ts +34 -0
  101. package/dist/lib.js +29 -0
  102. package/dist/utils/args.d.ts +4 -1
  103. package/dist/utils/args.js +26 -3
  104. package/dist/utils/githooks-sync.d.ts +3 -1
  105. package/dist/utils/githooks-sync.js +37 -37
  106. package/dist/utils/mcp-generate.d.ts +26 -0
  107. package/dist/utils/mcp-generate.js +313 -0
  108. package/dist/utils/preset-io.d.ts +1 -0
  109. package/dist/utils/preset-io.js +5 -2
  110. package/dist/utils/settings-io.d.ts +1 -0
  111. package/dist/utils/settings-io.js +1 -1
  112. package/package.json +20 -13
  113. package/dist/utils/mcp-sync.d.ts +0 -4
  114. package/dist/utils/mcp-sync.js +0 -103
@@ -1,6 +1,6 @@
1
- import * as p from "@clack/prompts";
2
1
  import { basename } from "node:path";
3
2
  import { getMessage } from "../i18n/index.js";
3
+ import { createClackLogger } from "./clack-logger.js";
4
4
  export const buildNextStepsBody = (opts) => {
5
5
  const steps = [];
6
6
  if (opts.isInit) {
@@ -17,9 +17,9 @@ export const buildNextStepsBody = (opts) => {
17
17
  }
18
18
  return steps.map((s, i) => `${i + 1}. ${s}`).join("\n");
19
19
  };
20
- export const printNextSteps = (opts) => {
20
+ export const printNextSteps = (opts, logger = createClackLogger()) => {
21
21
  const body = buildNextStepsBody(opts);
22
22
  if (body.length === 0)
23
23
  return;
24
- p.note(body, getMessage("nextSteps.heading", opts.locale));
24
+ logger.note(body, getMessage("nextSteps.heading", opts.locale));
25
25
  };
@@ -1,2 +1,9 @@
1
1
  import { type ProgressCallbacks } from "../asset/deployer.js";
2
- export declare const buildProgressCallbacks: (locale: string) => ProgressCallbacks;
2
+ import type { Logger } from "../core/logger.js";
3
+ type PathRejectedHandler = NonNullable<ProgressCallbacks["onPathRejected"]>;
4
+ export declare const buildPathRejectedWarning: (locale: string, logger: Logger) => PathRejectedHandler;
5
+ export declare const resolvePathRejected: (progress: {
6
+ onPathRejected?: PathRejectedHandler;
7
+ } | undefined, locale: string, logger: Logger) => PathRejectedHandler | undefined;
8
+ export declare const buildProgressCallbacks: (locale: string, logger?: Logger) => ProgressCallbacks;
9
+ export {};
Binary file
@@ -1,37 +1,7 @@
1
- import type { AccelSettings } from "../core/types.js";
2
1
  import { type Release } from "../core/catalog.js";
3
- import { type Validators } from "../core/validators.js";
4
- export type PromptOptions = {
5
- name?: string;
6
- artifactId?: string;
7
- jugglingProject?: string;
8
- accelplatformVersion?: string;
9
- module?: string[];
10
- feature?: string[];
11
- group?: string;
12
- projectVersion?: string;
13
- description?: string;
14
- database?: string;
15
- javascript?: boolean;
16
- agent?: string[];
17
- packageManager?: string;
18
- locale: string;
19
- withGit?: boolean;
20
- noInteraction?: boolean;
21
- isInit: boolean;
22
- mode?: "init" | "attach" | "update";
23
- skipIntro?: boolean;
24
- skipValidation?: boolean;
25
- };
26
- export type ResolvedOptions = Omit<AccelSettings, "cliVersion" | "createdAt" | "deployedAssets" | "assetSource" | "jugglingProject"> & {
27
- withGit: boolean;
28
- jugglingProject: string | null | undefined;
29
- };
30
- export declare const validateNonInteractive: (opts: PromptOptions) => string[];
31
- export declare const validateCliValues: (opts: PromptOptions, validators: Validators) => void;
32
- export declare const validateCatalogValues: (opts: PromptOptions, release: Release, locale: string) => void;
33
- export declare const collectSettingsErrors: (opts: PromptOptions, locale: string, releaseIdFallback?: string) => string[];
34
- export declare const printIntro: (mode: "init" | "attach" | "update" | "switch" | "preset", locale: string) => void;
2
+ import type { Logger } from "../core/logger.js";
3
+ import { type PromptOptions, type ResolvedOptions } from "../core/validation.js";
4
+ export declare const printIntro: (mode: "init" | "attach" | "update" | "switch" | "preset", locale: string, logger?: Logger) => void;
35
5
  export declare const promptModules: (release: Release, initialValues: string[], locale: string) => Promise<string[]>;
36
6
  export declare const promptFeatures: (release: Release, initialValues: string[] | undefined, locale: string) => Promise<string[]>;
37
7
  export declare const promptAgents: (initialValues: string[] | undefined, locale: string) => Promise<string[]>;
@@ -1,105 +1,17 @@
1
1
  import * as p from "@clack/prompts";
2
+ import { createCancelledError } from "../core/errors.js";
2
3
  import { getReleases, findReleaseById, resolveLabel, } from "../core/catalog.js";
3
4
  import { DATABASE_OPTIONS, AGENT_OPTIONS, DEFAULT_SETTINGS, } from "../core/constants.js";
4
- import { createValidators, createReleaseValidators, } from "../core/validators.js";
5
+ import { createValidators } from "../core/validators.js";
5
6
  import { getMessage } from "../i18n/index.js";
6
7
  import { withHint } from "./format.js";
8
+ import { createClackLogger } from "./clack-logger.js";
7
9
  import { detectAgents, detectDefaultAgents } from "./agent-detect.js";
8
- import { parseJugglingFile } from "../juggling/parser.js";
9
- import { extractVersion, extractModules, findRelease, } from "../juggling/extractor.js";
10
- import { stat } from "node:fs/promises";
11
- import { join } from "node:path";
12
- const resolveJuggling = async (jugglingPath, locale) => {
13
- const imPath = join(jugglingPath, "juggling.im");
14
- try {
15
- await stat(imPath);
16
- }
17
- catch {
18
- throw new Error(getMessage("juggling.notFound", locale, { path: imPath }));
19
- }
20
- const data = await parseJugglingFile(imPath);
21
- const release = findRelease(data) ?? null;
22
- const modules = release ? extractModules(data, release) : [];
23
- return { release, baseVersion: extractVersion(data), modules };
24
- };
25
- export const validateNonInteractive = (opts) => {
26
- const mode = opts.mode ?? (opts.isInit ? "init" : "attach");
27
- const errors = [];
28
- const missing = [];
29
- if (!opts.name) {
30
- if (mode === "init") {
31
- errors.push(getMessage("error.initNameArgumentMissing", opts.locale));
32
- }
33
- else {
34
- missing.push("--name");
35
- }
36
- }
37
- if (!opts.jugglingProject && !opts.accelplatformVersion) {
38
- missing.push("--accelplatform-version");
39
- }
40
- if (missing.length > 0) {
41
- errors.push(getMessage("error.missingRequiredOptions", opts.locale, {
42
- options: missing.join(", "),
43
- }));
44
- }
45
- return errors;
46
- };
47
- const collectFormatErrors = (opts, validators) => {
48
- const errors = [];
49
- const check = (validator, value) => {
50
- if (value === undefined)
51
- return;
52
- const err = validator(value);
53
- if (err)
54
- errors.push(err);
55
- };
56
- check(validators.name, opts.name);
57
- check(validators.artifactId, opts.artifactId);
58
- check(validators.group, opts.group);
59
- check(validators.projectVersion, opts.projectVersion);
60
- check(validators.accelplatformVersion, opts.accelplatformVersion);
61
- check(validators.database, opts.database);
62
- for (const a of opts.agent ?? [])
63
- check(validators.agent, a);
64
- check(validators.packageManager, opts.packageManager);
65
- return errors;
66
- };
67
- const collectCatalogErrors = (opts, release, locale) => {
68
- const releaseValidators = createReleaseValidators(locale, release);
69
- const errors = [];
70
- const check = (validator, value) => {
71
- const err = validator(value);
72
- if (err)
73
- errors.push(err);
74
- };
75
- for (const m of opts.module ?? [])
76
- check(releaseValidators.module, m);
77
- for (const f of opts.feature ?? [])
78
- check(releaseValidators.feature, f);
79
- return errors;
80
- };
81
- export const validateCliValues = (opts, validators) => {
82
- const [first] = collectFormatErrors(opts, validators);
83
- if (first)
84
- throw new Error(first);
85
- };
86
- export const validateCatalogValues = (opts, release, locale) => {
87
- const [first] = collectCatalogErrors(opts, release, locale);
88
- if (first)
89
- throw new Error(first);
90
- };
91
- export const collectSettingsErrors = (opts, locale, releaseIdFallback) => {
92
- const errors = collectFormatErrors(opts, createValidators(locale));
93
- const releaseId = opts.accelplatformVersion ?? releaseIdFallback;
94
- const release = releaseId ? findReleaseById(releaseId) : undefined;
95
- if (release) {
96
- errors.push(...collectCatalogErrors(opts, release, locale));
97
- }
98
- return errors;
99
- };
100
- export const printIntro = (mode, locale) => {
101
- p.intro("Accel CLI");
102
- p.note(getMessage(`intro.${mode}`, locale));
10
+ import { validateNonInteractive, validateCliValues, validateCatalogValues, } from "../core/validation.js";
11
+ import { resolveJugglingProject } from "../juggling/resolve.js";
12
+ export const printIntro = (mode, locale, logger = createClackLogger()) => {
13
+ logger.intro("Accel CLI");
14
+ logger.note(getMessage(`intro.${mode}`, locale));
103
15
  };
104
16
  export const promptModules = async (release, initialValues, locale) => {
105
17
  const releaseArtifactIds = release.modules.map((m) => m.artifactId);
@@ -113,7 +25,7 @@ export const promptModules = async (release, initialValues, locale) => {
113
25
  required: true,
114
26
  }));
115
27
  if (p.isCancel(modules))
116
- process.exit(0);
28
+ throw createCancelledError();
117
29
  return modules;
118
30
  };
119
31
  export const promptFeatures = async (release, initialValues, locale) => {
@@ -131,7 +43,7 @@ export const promptFeatures = async (release, initialValues, locale) => {
131
43
  required: true,
132
44
  }));
133
45
  if (p.isCancel(selected))
134
- process.exit(0);
46
+ throw createCancelledError();
135
47
  return selected;
136
48
  };
137
49
  export const promptAgents = async (initialValues, locale) => {
@@ -146,7 +58,7 @@ export const promptAgents = async (initialValues, locale) => {
146
58
  initialValues: defaults,
147
59
  }));
148
60
  if (p.isCancel(agents))
149
- process.exit(0);
61
+ throw createCancelledError();
150
62
  return agents;
151
63
  };
152
64
  export const runPrompts = async (opts) => {
@@ -162,7 +74,7 @@ export const runPrompts = async (opts) => {
162
74
  let jugglingRelease = null;
163
75
  let jugglingModules = [];
164
76
  if (opts.jugglingProject) {
165
- const resolved = await resolveJuggling(opts.jugglingProject, locale);
77
+ const resolved = await resolveJugglingProject(opts.jugglingProject, locale);
166
78
  if (!resolved.release) {
167
79
  throw new Error(getMessage("error.jugglingVersionUnknown", locale, {
168
80
  version: resolved.baseVersion,
@@ -214,7 +126,7 @@ export const runPrompts = async (opts) => {
214
126
  validate: validators.name,
215
127
  }));
216
128
  if (p.isCancel(name))
217
- process.exit(0);
129
+ throw createCancelledError();
218
130
  const artifactIdInitial = opts.artifactId ?? name;
219
131
  const artifactId = (await p.text({
220
132
  message: withHint("prompt.artifactId", locale),
@@ -223,19 +135,19 @@ export const runPrompts = async (opts) => {
223
135
  validate: validators.artifactId,
224
136
  }));
225
137
  if (p.isCancel(artifactId))
226
- process.exit(0);
138
+ throw createCancelledError();
227
139
  const jugglingInput = (await p.text({
228
140
  message: withHint("prompt.jugglingProject", locale),
229
141
  initialValue: opts.jugglingProject ?? "",
230
142
  }));
231
143
  if (p.isCancel(jugglingInput))
232
- process.exit(0);
144
+ throw createCancelledError();
233
145
  let jugglingRelease = null;
234
146
  let jugglingModules = [];
235
147
  const jugglingProject = jugglingInput || null;
236
148
  if (jugglingProject) {
237
149
  try {
238
- const resolved = await resolveJuggling(jugglingProject, locale);
150
+ const resolved = await resolveJugglingProject(jugglingProject, locale);
239
151
  if (resolved.release) {
240
152
  jugglingRelease = resolved.release;
241
153
  jugglingModules = resolved.modules;
@@ -273,7 +185,7 @@ export const runPrompts = async (opts) => {
273
185
  initialValue: versionDefault,
274
186
  }));
275
187
  if (p.isCancel(accelplatformVersionId))
276
- process.exit(0);
188
+ throw createCancelledError();
277
189
  const release = findReleaseById(accelplatformVersionId);
278
190
  if (!release) {
279
191
  throw new Error(getMessage("error.invalidVersion", locale, {
@@ -304,7 +216,7 @@ export const runPrompts = async (opts) => {
304
216
  validate: validators.group,
305
217
  }));
306
218
  if (p.isCancel(group))
307
- process.exit(0);
219
+ throw createCancelledError();
308
220
  const projectVersion = (await p.text({
309
221
  message: withHint("prompt.projectVersion", locale),
310
222
  defaultValue: opts.projectVersion ?? DEFAULT_SETTINGS.projectVersion,
@@ -312,27 +224,27 @@ export const runPrompts = async (opts) => {
312
224
  validate: validators.projectVersion,
313
225
  }));
314
226
  if (p.isCancel(projectVersion))
315
- process.exit(0);
227
+ throw createCancelledError();
316
228
  const description = (await p.text({
317
229
  message: withHint("prompt.description", locale),
318
230
  defaultValue: opts.description ?? DEFAULT_SETTINGS.description,
319
231
  initialValue: opts.description ?? DEFAULT_SETTINGS.description,
320
232
  }));
321
233
  if (p.isCancel(description))
322
- process.exit(0);
234
+ throw createCancelledError();
323
235
  const database = (await p.select({
324
236
  message: withHint("prompt.database", locale),
325
237
  options: DATABASE_OPTIONS.map((d) => ({ value: d, label: d })),
326
238
  initialValue: opts.database ?? DEFAULT_SETTINGS.database,
327
239
  }));
328
240
  if (p.isCancel(database))
329
- process.exit(0);
241
+ throw createCancelledError();
330
242
  const javascript = (await p.confirm({
331
243
  message: withHint("prompt.javascript", locale),
332
244
  initialValue: opts.javascript ?? DEFAULT_SETTINGS.javascript,
333
245
  }));
334
246
  if (p.isCancel(javascript))
335
- process.exit(0);
247
+ throw createCancelledError();
336
248
  const agents = await promptAgents(opts.agent, locale);
337
249
  let withGit = opts.withGit ?? true;
338
250
  if (opts.isInit) {
@@ -341,7 +253,7 @@ export const runPrompts = async (opts) => {
341
253
  initialValue: opts.withGit ?? true,
342
254
  }));
343
255
  if (p.isCancel(withGit))
344
- process.exit(0);
256
+ throw createCancelledError();
345
257
  }
346
258
  return {
347
259
  name,
@@ -1,3 +1,4 @@
1
1
  import type { AccelSettings } from "../core/types.js";
2
+ import type { Logger } from "../core/logger.js";
2
3
  export declare const buildSummaryBody: (settings: AccelSettings, outputDir: string, locale: string) => string;
3
- export declare const printSummary: (settings: AccelSettings, outputDir: string, locale: string) => void;
4
+ export declare const printSummary: (settings: AccelSettings, outputDir: string, locale: string, logger?: Logger) => void;
@@ -1,5 +1,5 @@
1
- import * as p from "@clack/prompts";
2
1
  import { getMessage } from "../i18n/index.js";
2
+ import { createClackLogger } from "./clack-logger.js";
3
3
  import { displayWidth } from "./format.js";
4
4
  const formatList = (values, emptyLabel) => values.length > 0 ? values.join(", ") : emptyLabel;
5
5
  const formatString = (value, emptyLabel) => value.length > 0 ? value : emptyLabel;
@@ -57,6 +57,6 @@ export const buildSummaryBody = (settings, outputDir, locale) => {
57
57
  })
58
58
  .join("\n");
59
59
  };
60
- export const printSummary = (settings, outputDir, locale) => {
61
- p.note(buildSummaryBody(settings, outputDir, locale), getMessage("summary.heading", locale));
60
+ export const printSummary = (settings, outputDir, locale, logger = createClackLogger()) => {
61
+ logger.note(buildSummaryBody(settings, outputDir, locale), getMessage("summary.heading", locale));
62
62
  };
@@ -0,0 +1,7 @@
1
+ import type { Release } from "../core/catalog.js";
2
+ export type JugglingResolved = {
3
+ release: Release | null;
4
+ baseVersion: string;
5
+ modules: string[];
6
+ };
7
+ export declare const resolveJugglingProject: (jugglingPath: string, locale: string) => Promise<JugglingResolved>;
@@ -0,0 +1,18 @@
1
+ import { stat } from "node:fs/promises";
2
+ import { join } from "node:path";
3
+ import { getMessage } from "../i18n/index.js";
4
+ import { parseJugglingFile } from "./parser.js";
5
+ import { extractVersion, extractModules, findRelease } from "./extractor.js";
6
+ export const resolveJugglingProject = async (jugglingPath, locale) => {
7
+ const imPath = join(jugglingPath, "juggling.im");
8
+ try {
9
+ await stat(imPath);
10
+ }
11
+ catch {
12
+ throw new Error(getMessage("juggling.notFound", locale, { path: imPath }));
13
+ }
14
+ const data = await parseJugglingFile(imPath);
15
+ const release = findRelease(data) ?? null;
16
+ const modules = release ? extractModules(data, release) : [];
17
+ return { release, baseVersion: extractVersion(data), modules };
18
+ };
package/dist/lib.d.ts ADDED
@@ -0,0 +1,34 @@
1
+ export { runDeploy, type RunDeployDeps, type DeployPrompts, type DeployRunResult, type SetupRunOutcome, type ConfirmInfo, } from "./commands/deploy.js";
2
+ export { runLogin, type RunLoginDeps } from "./commands/login.js";
3
+ export { runInit, type RunInitDeps } from "./commands/init.js";
4
+ export { runUpdate, createUpdateFallbackAbortedError, isUpdateFallbackAbortedError, type RunUpdateDeps, type UpdatePrompts, type FallbackMode, type SettingsSourceChoice, } from "./commands/update.js";
5
+ export { runSwitch, type RunSwitchDeps, type SwitchPrompts, } from "./commands/switch.js";
6
+ export { runAttach, type RunAttachDeps } from "./commands/attach.js";
7
+ export { runDetach, type RunDetachDeps, type DetachPrompts, type DetachResult, } from "./commands/detach.js";
8
+ export type { Logger, Spinner } from "./core/logger.js";
9
+ export { createClackLogger } from "./interactive/clack-logger.js";
10
+ export { deployAssets, ROOT_SECTION, type DeployOptions, type DeployResult, type ProgressCallbacks, type ExistingFileHandler, type OverwriteDecision, } from "./asset/deployer.js";
11
+ export type { UpdaterProgressCallbacks, UpdateOutcome } from "./asset/updater.js";
12
+ export type { AssetMessage } from "./asset/messages.js";
13
+ export { sanitizeDisplayText } from "./utils/sanitize-text.js";
14
+ export { createGitAssetProvider, type GitAssetProviderOptions, } from "./asset/git-provider.js";
15
+ export { createFileAssetProvider } from "./asset/file-provider.js";
16
+ export { createCancelledError, isCancelledError, isAbortError, normalizeAbort, markReported, isReportedError, } from "./core/errors.js";
17
+ export { isDeployError, makeDeployError } from "./deploy/api-client.js";
18
+ export { isGitAuthError, isGitObjectMissingError, isGitPackCorruptError, isGitServerUnsupportedError, } from "./git/errors.js";
19
+ export { createValidators, createReleaseValidators, createPresetNameValidator, type Validator, type Validators, type ReleaseValidators, } from "./core/validators.js";
20
+ export { validateNonInteractive, validateCliValues, validateCatalogValues, collectSettingsErrors, checkProjectDirAvailable, type PromptOptions, type ResolvedOptions, } from "./core/validation.js";
21
+ export { resolveJugglingProject, type JugglingResolved, } from "./juggling/resolve.js";
22
+ export { readCredentials, normalizeEndpoint, resolveCredentialInputs, } from "./utils/credentials.js";
23
+ export { persistCredentialsAndGenerateMcp } from "./utils/mcp-generate.js";
24
+ export { createApiClient, type ApiClient } from "./deploy/api-client.js";
25
+ export { verifyCredentialsLoop, type VerifyDeps } from "./interactive/credential-auth.js";
26
+ export { getReleases, findReleaseById, findReleaseBySemver, resolveAccelplatformVersion, resolveLabel, findModuleByCatalogId, toModuleContextItems, toFeatureContextItems, type Release, type ModuleEntry, type FunctionEntry, type Labels, } from "./core/catalog.js";
27
+ export { configurePaths, getPackageRoot, getCliVersion, } from "./core/paths.js";
28
+ export { readSettingsSafe, ACCEL_DIR } from "./utils/settings-io.js";
29
+ export { listPresetSummaries, formatPresetDisplayName, readPreset, loadAndValidatePreset, writePreset, deletePreset, presetExists, validatePresetSchema, collectPresetCatalogErrors, type PresetSummary, } from "./utils/preset-io.js";
30
+ export { resolveCacheRoot, cacheReposDir, listCacheRepos, directorySize, clearCacheRepos, type CacheRepoEntry, } from "./git/object-cache.js";
31
+ export { DATABASE_OPTIONS, AGENT_OPTIONS, LOCALE_OPTIONS, PACKAGE_MANAGER_OPTIONS, DEFAULT_SETTINGS, DEFAULT_ASSET_REPO_URL, DEFAULT_ASSET_REF, type DatabaseOption, type AgentOption, type LocaleOption, type PackageManagerOption, } from "./core/constants.js";
32
+ export { detectAgents, detectDefaultAgents, } from "./interactive/agent-detect.js";
33
+ export type { AccelSettings, AccelCredentials, AccelPreset, AssetProvider, AssetSourceInfo, HashsumEntry, DeployError, MessageLevel, StagingResponse, SetupConfigResponse, SampleSetupConfigResponse, } from "./core/types.js";
34
+ export type { DeployFile } from "./deploy/deploy-files.js";
package/dist/lib.js ADDED
@@ -0,0 +1,29 @@
1
+ export { runDeploy, } from "./commands/deploy.js";
2
+ export { runLogin } from "./commands/login.js";
3
+ export { runInit } from "./commands/init.js";
4
+ export { runUpdate, createUpdateFallbackAbortedError, isUpdateFallbackAbortedError, } from "./commands/update.js";
5
+ export { runSwitch, } from "./commands/switch.js";
6
+ export { runAttach } from "./commands/attach.js";
7
+ export { runDetach, } from "./commands/detach.js";
8
+ export { createClackLogger } from "./interactive/clack-logger.js";
9
+ export { deployAssets, ROOT_SECTION, } from "./asset/deployer.js";
10
+ export { sanitizeDisplayText } from "./utils/sanitize-text.js";
11
+ export { createGitAssetProvider, } from "./asset/git-provider.js";
12
+ export { createFileAssetProvider } from "./asset/file-provider.js";
13
+ export { createCancelledError, isCancelledError, isAbortError, normalizeAbort, markReported, isReportedError, } from "./core/errors.js";
14
+ export { isDeployError, makeDeployError } from "./deploy/api-client.js";
15
+ export { isGitAuthError, isGitObjectMissingError, isGitPackCorruptError, isGitServerUnsupportedError, } from "./git/errors.js";
16
+ export { createValidators, createReleaseValidators, createPresetNameValidator, } from "./core/validators.js";
17
+ export { validateNonInteractive, validateCliValues, validateCatalogValues, collectSettingsErrors, checkProjectDirAvailable, } from "./core/validation.js";
18
+ export { resolveJugglingProject, } from "./juggling/resolve.js";
19
+ export { readCredentials, normalizeEndpoint, resolveCredentialInputs, } from "./utils/credentials.js";
20
+ export { persistCredentialsAndGenerateMcp } from "./utils/mcp-generate.js";
21
+ export { createApiClient } from "./deploy/api-client.js";
22
+ export { verifyCredentialsLoop } from "./interactive/credential-auth.js";
23
+ export { getReleases, findReleaseById, findReleaseBySemver, resolveAccelplatformVersion, resolveLabel, findModuleByCatalogId, toModuleContextItems, toFeatureContextItems, } from "./core/catalog.js";
24
+ export { configurePaths, getPackageRoot, getCliVersion, } from "./core/paths.js";
25
+ export { readSettingsSafe, ACCEL_DIR } from "./utils/settings-io.js";
26
+ export { listPresetSummaries, formatPresetDisplayName, readPreset, loadAndValidatePreset, writePreset, deletePreset, presetExists, validatePresetSchema, collectPresetCatalogErrors, } from "./utils/preset-io.js";
27
+ export { resolveCacheRoot, cacheReposDir, listCacheRepos, directorySize, clearCacheRepos, } from "./git/object-cache.js";
28
+ export { DATABASE_OPTIONS, AGENT_OPTIONS, LOCALE_OPTIONS, PACKAGE_MANAGER_OPTIONS, DEFAULT_SETTINGS, DEFAULT_ASSET_REPO_URL, DEFAULT_ASSET_REF, } from "./core/constants.js";
29
+ export { detectAgents, detectDefaultAgents, } from "./interactive/agent-detect.js";
@@ -1,2 +1,5 @@
1
+ export declare const toCamelCase: (s: string) => string;
2
+ export declare const toKebabCase: (s: string) => string;
1
3
  export declare const lastFlagValue: (v: unknown) => string | undefined;
2
- export declare const allFlagValues: (v: unknown) => string[];
4
+ export declare const collectRepeatedFlag: (rawArgs: readonly string[], name: string) => string[];
5
+ export declare const splitList: (v: unknown) => string[] | undefined;
@@ -1,8 +1,31 @@
1
+ export const toCamelCase = (s) => s.replace(/-([a-z0-9])/g, (_, c) => c.toUpperCase());
2
+ export const toKebabCase = (s) => s.replace(/[A-Z]/g, (c) => `-${c.toLowerCase()}`);
1
3
  export const lastFlagValue = (v) => {
2
4
  const x = Array.isArray(v) ? v[v.length - 1] : v;
3
5
  return typeof x === "string" ? x : undefined;
4
6
  };
5
- export const allFlagValues = (v) => {
6
- const arr = Array.isArray(v) ? v : [v];
7
- return arr.filter((x) => typeof x === "string");
7
+ export const collectRepeatedFlag = (rawArgs, name) => {
8
+ const out = [];
9
+ const spellings = [...new Set([name, toCamelCase(name), toKebabCase(name)])];
10
+ const bare = new Set(spellings.map((s) => `--${s}`));
11
+ const inline = spellings.map((s) => `--${s}=`);
12
+ for (let i = 0; i < rawArgs.length; i++) {
13
+ const token = rawArgs[i];
14
+ if (token === "--")
15
+ break;
16
+ if (bare.has(token)) {
17
+ const value = rawArgs[i + 1];
18
+ if (typeof value === "string" && !value.startsWith("--")) {
19
+ out.push(value);
20
+ i++;
21
+ }
22
+ }
23
+ else {
24
+ const prefix = inline.find((p) => token.startsWith(p));
25
+ if (prefix)
26
+ out.push(token.slice(prefix.length));
27
+ }
28
+ }
29
+ return out;
8
30
  };
31
+ export const splitList = (v) => typeof v === "string" ? v.split(",").map((s) => s.trim()) : undefined;
@@ -1 +1,3 @@
1
- export declare const syncGitHooks: (projectDir: string) => Promise<void>;
1
+ export declare const syncGitHooks: (projectDir: string, opts: {
2
+ warn: (msg: string) => void;
3
+ }) => Promise<void>;
@@ -1,26 +1,23 @@
1
- import fs from "node:fs";
2
- import { access, chmod, mkdir, readdir, readFile, writeFile, } from "node:fs/promises";
3
- import { dirname, join } from "node:path";
4
- import { fileURLToPath } from "node:url";
5
- import git from "isomorphic-git";
6
- import * as p from "@clack/prompts";
1
+ import { chmod, lstat, mkdir, readdir, writeFile } from "node:fs/promises";
2
+ import { dirname, isAbsolute, join, relative } from "node:path";
3
+ import { readConfigValue, writeConfigValue } from "../git/config-file.js";
4
+ import { readTextFileCapped } from "../git/read-capped.js";
5
+ import { resolveRepoLayout } from "../git/repo-layout.js";
7
6
  import { createFsAssetTree } from "../asset/asset-tree.js";
8
7
  import { walkAssetDir } from "../asset/walker.js";
9
8
  import { emptyEvalContext } from "../core/eval-context.js";
9
+ import { getAssetsGithooksRoot } from "../core/paths.js";
10
10
  import { getMessage } from "../i18n/index.js";
11
11
  import { detectLocale } from "./locale-detect.js";
12
12
  import { readSettingsSafe } from "./settings-io.js";
13
13
  const MANAGED_MARKER = "@accel-cli-managed";
14
14
  const HOOKS_PATH = ".githooks";
15
15
  const HOOK_FILE_REL = ".githooks/pre-commit";
16
- const ASSETS_GITHOOKS_ROOT = fileURLToPath(new URL("../../assets/githooks", import.meta.url));
17
- const readFileSafe = async (filePath) => {
18
- try {
19
- return await readFile(filePath, "utf-8");
20
- }
21
- catch {
22
- return null;
23
- }
16
+ const MAX_HOOK_FILE_BYTES = 1024 * 1024;
17
+ const readFileSafe = (filePath) => readTextFileCapped(filePath, MAX_HOOK_FILE_BYTES);
18
+ const isInside = (parent, child) => {
19
+ const rel = relative(parent, child);
20
+ return rel === "" || (!rel.startsWith("..") && !isAbsolute(rel));
24
21
  };
25
22
  const listForeignFiles = async (hooksDir) => {
26
23
  const foreign = [];
@@ -36,24 +33,29 @@ const listForeignFiles = async (hooksDir) => {
36
33
  }
37
34
  return foreign;
38
35
  };
39
- export const syncGitHooks = async (projectDir) => {
36
+ export const syncGitHooks = async (projectDir, opts) => {
40
37
  const settings = await readSettingsSafe(projectDir);
41
38
  if (settings?.gitHooks === false)
42
39
  return;
43
- try {
44
- await access(join(projectDir, ".git"));
45
- }
46
- catch {
40
+ const layout = await resolveRepoLayout(projectDir);
41
+ if (layout === null)
47
42
  return;
48
- }
43
+ const configPath = join(layout.commonDir, "config");
49
44
  const locale = settings?.locale ?? detectLocale();
50
- const tree = createFsAssetTree(ASSETS_GITHOOKS_ROOT);
45
+ const tree = createFsAssetTree(getAssetsGithooksRoot());
51
46
  const entries = await walkAssetDir(tree, emptyEvalContext({ locale }));
52
47
  for (const entry of entries) {
53
48
  const destPath = join(projectDir, entry.relativePath);
54
- const existing = await readFileSafe(destPath);
49
+ const destStats = await lstat(destPath).catch(() => null);
50
+ if (destStats !== null && !destStats.isFile()) {
51
+ opts.warn(getMessage("warning.gitHooksUserFile", locale, {
52
+ path: entry.relativePath,
53
+ }));
54
+ continue;
55
+ }
56
+ const existing = destStats === null ? null : await readFileSafe(destPath);
55
57
  if (existing !== null && !existing.includes(MANAGED_MARKER)) {
56
- p.log.warning(getMessage("warning.gitHooksUserFile", locale, {
58
+ opts.warn(getMessage("warning.gitHooksUserFile", locale, {
57
59
  path: entry.relativePath,
58
60
  }));
59
61
  continue;
@@ -65,27 +67,25 @@ export const syncGitHooks = async (projectDir) => {
65
67
  await chmod(destPath, 0o755);
66
68
  }
67
69
  }
68
- const current = (await git.getConfig({
69
- fs,
70
- dir: projectDir,
71
- path: "core.hooksPath",
72
- }));
73
- if (current === undefined) {
70
+ const genuineWorktree = isInside(join(layout.commonDir, "worktrees"), layout.gitDir);
71
+ if (!isInside(projectDir, layout.commonDir) && !genuineWorktree) {
72
+ opts.warn(getMessage("warning.gitHooksLayoutSuspicious", locale, {
73
+ path: layout.commonDir,
74
+ }));
75
+ return;
76
+ }
77
+ const current = await readConfigValue(configPath, "core", "hooksPath");
78
+ if (current === undefined || current === "") {
74
79
  const foreign = await listForeignFiles(join(projectDir, HOOKS_PATH));
75
80
  if (foreign.length > 0) {
76
- p.log.warning(getMessage("warning.gitHooksForeignFiles", locale, {
81
+ opts.warn(getMessage("warning.gitHooksForeignFiles", locale, {
77
82
  files: foreign.join(", "),
78
83
  }));
79
84
  return;
80
85
  }
81
- await git.setConfig({
82
- fs,
83
- dir: projectDir,
84
- path: "core.hooksPath",
85
- value: HOOKS_PATH,
86
- });
86
+ await writeConfigValue(configPath, "core", "hooksPath", HOOKS_PATH);
87
87
  }
88
88
  else if (current !== HOOKS_PATH) {
89
- p.log.warning(getMessage("warning.gitHooksPathConflict", locale, { current }));
89
+ opts.warn(getMessage("warning.gitHooksPathConflict", locale, { current }));
90
90
  }
91
91
  };
@@ -0,0 +1,26 @@
1
+ import type { AccelCredentials } from "../core/types.js";
2
+ export type McpState = Record<string, string[]>;
3
+ type McpLogSink = {
4
+ info: (msg: string) => void;
5
+ warn: (msg: string) => void;
6
+ };
7
+ export type McpGenerateOpts = {
8
+ info?: (msg: string) => void;
9
+ warn?: (msg: string) => void;
10
+ credentialsConfirmed?: boolean;
11
+ };
12
+ export declare const readMcpState: (projectDir: string) => Promise<McpState>;
13
+ export declare const writeMcpState: (projectDir: string, state: McpState) => Promise<void>;
14
+ export declare const generateMcpConfigs: (projectDir: string, opts?: McpGenerateOpts) => Promise<void>;
15
+ export declare const removeManagedMcpEntries: (projectDir: string, opts?: {
16
+ info?: (msg: string) => void;
17
+ warn?: (msg: string) => void;
18
+ }) => Promise<void>;
19
+ export declare const persistCredentialsAndGenerateMcp: (projectDir: string, creds: AccelCredentials, opts?: {
20
+ info?: (msg: string) => void;
21
+ warn?: (msg: string) => void;
22
+ }) => Promise<void>;
23
+ export declare const generateMcpConfigsBestEffort: (projectDir: string, logger: McpLogSink, impl?: typeof generateMcpConfigs) => Promise<void>;
24
+ export declare const removeManagedMcpEntriesBestEffort: (projectDir: string, logger: McpLogSink, impl?: typeof removeManagedMcpEntries) => Promise<void>;
25
+ export declare const createPersistCredentialsWithMcp: (logger: McpLogSink) => (projectDir: string, creds: AccelCredentials) => Promise<void>;
26
+ export {};