@intra-mart/accel 0.5.0 → 0.6.0-dev.202609241904

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 (49) hide show
  1. package/README.md +22 -3
  2. package/assets/runtime/ensure.mjs +914 -0
  3. package/dist/asset/dependencies.d.ts +7 -0
  4. package/dist/asset/dependencies.js +23 -0
  5. package/dist/asset/deployer.d.ts +1 -0
  6. package/dist/asset/deployer.js +11 -3
  7. package/dist/asset/installer.js +3 -8
  8. package/dist/asset/updater.d.ts +2 -0
  9. package/dist/asset/updater.js +3 -0
  10. package/dist/asset/walker.d.ts +1 -0
  11. package/dist/asset/walker.js +65 -3
  12. package/dist/commands/attach.d.ts +4 -1
  13. package/dist/commands/attach.js +8 -1
  14. package/dist/commands/detach.d.ts +2 -0
  15. package/dist/commands/detach.js +4 -0
  16. package/dist/commands/init.d.ts +4 -1
  17. package/dist/commands/init.js +8 -1
  18. package/dist/commands/switch.d.ts +3 -0
  19. package/dist/commands/switch.js +12 -3
  20. package/dist/commands/update.d.ts +4 -0
  21. package/dist/commands/update.js +26 -5
  22. package/dist/core/constants.d.ts +10 -1
  23. package/dist/core/constants.js +22 -1
  24. package/dist/core/errors.d.ts +11 -0
  25. package/dist/core/errors.js +6 -0
  26. package/dist/core/gitignore-entries.d.ts +7 -0
  27. package/dist/core/gitignore-entries.js +16 -0
  28. package/dist/core/paths.d.ts +1 -0
  29. package/dist/core/paths.js +1 -0
  30. package/dist/core/types.d.ts +2 -1
  31. package/dist/core/variable-interpolator.js +4 -0
  32. package/dist/i18n/en.js +15 -0
  33. package/dist/i18n/ja.js +15 -0
  34. package/dist/i18n/zh_CN.js +15 -0
  35. package/dist/interactive/next-steps.d.ts +1 -0
  36. package/dist/interactive/next-steps.js +3 -0
  37. package/dist/utils/credentials.d.ts +2 -1
  38. package/dist/utils/credentials.js +3 -2
  39. package/dist/utils/gitignore.d.ts +1 -0
  40. package/dist/utils/gitignore.js +8 -6
  41. package/dist/utils/mcp-generate.d.ts +8 -1
  42. package/dist/utils/mcp-generate.js +261 -31
  43. package/dist/utils/runtime-ensure.d.ts +55 -0
  44. package/dist/utils/runtime-ensure.js +391 -0
  45. package/dist/utils/sanitize-text.d.ts +2 -0
  46. package/dist/utils/sanitize-text.js +7 -0
  47. package/dist/utils/settings-io.d.ts +2 -1
  48. package/dist/utils/settings-io.js +2 -1
  49. package/package.json +7 -2
@@ -0,0 +1,7 @@
1
+ import type { AccelSettings } from "../core/types.js";
2
+ export declare const collectDependencyDirs: (entries: ReadonlyArray<{
3
+ relativePath: string;
4
+ kind?: "dependencies";
5
+ }>) => string[];
6
+ export declare const withDependencies: <S extends AccelSettings>(settings: S, dirs: readonly string[]) => S;
7
+ export declare const isDependencyFile: (relativePath: string, dirs: readonly string[]) => boolean;
@@ -0,0 +1,23 @@
1
+ import { DEPENDENCY_FILE_NAMES } from "../core/constants.js";
2
+ const dirnamePosix = (p) => {
3
+ const idx = p.lastIndexOf("/");
4
+ return idx === -1 ? "." : p.slice(0, idx);
5
+ };
6
+ const basenamePosix = (p) => {
7
+ const idx = p.lastIndexOf("/");
8
+ return idx === -1 ? p : p.slice(idx + 1);
9
+ };
10
+ export const collectDependencyDirs = (entries) => {
11
+ const dirs = new Set();
12
+ for (const entry of entries) {
13
+ if (entry.kind === "dependencies")
14
+ dirs.add(dirnamePosix(entry.relativePath));
15
+ }
16
+ return [...dirs].sort();
17
+ };
18
+ export const withDependencies = (settings, dirs) => {
19
+ const { dependencies: _previous, ...rest } = settings;
20
+ return (dirs.length === 0 ? rest : { ...rest, dependencies: [...dirs] });
21
+ };
22
+ export const isDependencyFile = (relativePath, dirs) => dirs.includes(dirnamePosix(relativePath)) &&
23
+ DEPENDENCY_FILE_NAMES.has(basenamePosix(relativePath));
@@ -27,6 +27,7 @@ export type DeployResult = {
27
27
  hashEntries: HashsumEntry[];
28
28
  skippedFiles: string[];
29
29
  overwrittenFiles: string[];
30
+ dependencies: string[];
30
31
  };
31
32
  export declare const ROOT_SECTION = "(root)";
32
33
  export declare const deployAssets: (options: DeployOptions) => Promise<DeployResult>;
@@ -3,6 +3,7 @@ import { join, dirname, resolve, sep } from "node:path";
3
3
  import { buildEvalContext } from "../core/eval-context.js";
4
4
  import { normalizeAbort } from "../core/errors.js";
5
5
  import { walkAssetRepo, replacementsFor } from "./walker.js";
6
+ import { collectDependencyDirs, withDependencies } from "./dependencies.js";
6
7
  import { createMessageCollector } from "./messages.js";
7
8
  import { renderAssetContent } from "./renderer.js";
8
9
  import { runInstallBuild } from "./installer.js";
@@ -127,11 +128,12 @@ export const deployAssets = async (options) => {
127
128
  for (const h of hashEntries) {
128
129
  deployedAssets[h.filePath] = h.version;
129
130
  }
130
- const updatedSettings = {
131
+ const dependencies = collectDependencyDirs(entries);
132
+ const updatedSettings = withDependencies({
131
133
  ...settings,
132
134
  assetSource: provider.sourceInfo(),
133
135
  deployedAssets,
134
- };
136
+ }, dependencies);
135
137
  await writeSettings(projectDir, updatedSettings);
136
138
  await writeHashsum(projectDir, hashEntries);
137
139
  const assetMessages = messageCollector.drain();
@@ -141,7 +143,13 @@ export const deployAssets = async (options) => {
141
143
  if (!noInstall) {
142
144
  runInstallBuild(projectDir, settings.packageManager, progress);
143
145
  }
144
- return { deployedFiles, hashEntries, skippedFiles, overwrittenFiles };
146
+ return {
147
+ deployedFiles,
148
+ hashEntries,
149
+ skippedFiles,
150
+ overwrittenFiles,
151
+ dependencies,
152
+ };
145
153
  }
146
154
  catch (err) {
147
155
  throw normalizeAbort(err, signal);
@@ -1,13 +1,8 @@
1
1
  import { execSync } from "node:child_process";
2
2
  import { basename } from "node:path";
3
- const INSTALL_TRIGGER_BASENAMES = [
4
- "package.json",
5
- "bun.lock",
6
- "package-lock.json",
7
- "yarn.lock",
8
- "pnpm-lock.yaml",
9
- ];
10
- export const installTriggerChanged = (changedPaths) => changedPaths.some((path) => INSTALL_TRIGGER_BASENAMES.includes(basename(path)));
3
+ import { DEPENDENCY_FILE_NAMES } from "../core/constants.js";
4
+ const INSTALL_TRIGGER_BASENAMES = DEPENDENCY_FILE_NAMES;
5
+ export const installTriggerChanged = (changedPaths) => changedPaths.some((path) => INSTALL_TRIGGER_BASENAMES.has(basename(path)));
11
6
  export const getInstallCmds = (packageManager) => {
12
7
  switch (packageManager) {
13
8
  case "npm":
@@ -7,9 +7,11 @@ export type RenderedAsset = {
7
7
  content: string;
8
8
  version: string;
9
9
  sha1: string;
10
+ kind?: "dependencies";
10
11
  };
11
12
  export type RenderedPlan = Map<string, RenderedAsset>;
12
13
  export declare const buildRenderedPlan: (tree: AssetTree, settings: AccelSettings, materialize?: (files: string[]) => Promise<void>, collect?: MessageSink, onPathRejected?: (kind: "project" | "assetRepo", path: string) => void) => Promise<RenderedPlan>;
14
+ export declare const dependencyDirsOfPlan: (plan: RenderedPlan) => string[];
13
15
  export type FileState = {
14
16
  relativePath: string;
15
17
  base: RenderedAsset | null;
@@ -2,6 +2,7 @@ import { mkdir, readFile, unlink, writeFile } from "node:fs/promises";
2
2
  import { dirname, join } from "node:path";
3
3
  import { buildEvalContext } from "../core/eval-context.js";
4
4
  import { walkAssetRepo, replacementsFor } from "./walker.js";
5
+ import { collectDependencyDirs } from "./dependencies.js";
5
6
  import { renderAssetContent } from "./renderer.js";
6
7
  import { computeSha1 } from "../utils/hash.js";
7
8
  import { FS_CONCURRENCY, mapWithConcurrency } from "../utils/concurrency.js";
@@ -33,10 +34,12 @@ export const buildRenderedPlan = async (tree, settings, materialize, collect, on
33
34
  content,
34
35
  version: entry.meta?.version ?? "0.0.0",
35
36
  sha1: computeSha1(content),
37
+ ...(entry.kind === undefined ? {} : { kind: entry.kind }),
36
38
  };
37
39
  });
38
40
  return new Map(rendered.map((asset) => [asset.relativePath, asset]));
39
41
  };
42
+ export const dependencyDirsOfPlan = (plan) => collectDependencyDirs([...plan.values()]);
40
43
  export const collectFileStates = async (projectDir, basePlan, theirsPlan, recorded) => {
41
44
  const recordedMap = new Map(recorded.map((e) => [e.filePath, e]));
42
45
  const keys = new Set([
@@ -5,6 +5,7 @@ export type AssetEntry = {
5
5
  sourceRelPath: string;
6
6
  relativePath: string;
7
7
  meta: MetaJson | null;
8
+ kind?: "dependencies";
8
9
  };
9
10
  export declare const replacementsFor: (entry: AssetEntry) => Replacement[];
10
11
  export declare const walkAssetDir: (tree: AssetTree, context: EvalContext) => Promise<AssetEntry[]>;
@@ -1,7 +1,13 @@
1
1
  import { evaluateCondition } from "../core/condition-evaluator.js";
2
2
  import { emptyEvalContext } from "../core/eval-context.js";
3
+ import { DEPENDENCY_FILE_NAMES, PACKAGE_JSON_NAME, lockfileFor, } from "../core/constants.js";
4
+ import { createAssetDependencyError, } from "../core/errors.js";
5
+ import { getMessage } from "../i18n/index.js";
6
+ import { sanitizeDisplayText } from "../utils/sanitize-text.js";
3
7
  const META_FILE = "_meta.json";
4
- export const replacementsFor = (entry) => entry.meta?.type === "mcp" ? [] : (entry.meta?.replacements ?? []);
8
+ export const replacementsFor = (entry) => entry.meta?.type === "mcp" || entry.meta?.type === "dependencies"
9
+ ? []
10
+ : (entry.meta?.replacements ?? []);
5
11
  const joinPosix = (...parts) => parts.filter((p) => p !== "").join("/");
6
12
  const dirnamePosix = (p) => {
7
13
  const idx = p.lastIndexOf("/");
@@ -58,6 +64,43 @@ const resolveRenameRule = (rules, context, dir) => {
58
64
  return null;
59
65
  };
60
66
  const MCP_HOLD_DIR = ".accel/mcp";
67
+ const selectDependencyFiles = (meta, context, dir, available) => {
68
+ const fail = (kind, params) => {
69
+ throw createAssetDependencyError(getMessage(`error.dependencies.${kind}`, context.locale, {
70
+ dir: sanitizeDisplayText(dir),
71
+ ...params,
72
+ }), { dir, kind });
73
+ };
74
+ const lockName = lockfileFor(context.packageManager);
75
+ const targets = [PACKAGE_JSON_NAME, lockName];
76
+ const chosen = new Map();
77
+ const rules = Array.isArray(meta.rename) ? meta.rename : [];
78
+ for (const rule of rules) {
79
+ if (!rule || typeof rule !== "object")
80
+ continue;
81
+ if (typeof rule.from !== "string" || typeof rule.to !== "string")
82
+ continue;
83
+ if (!DEPENDENCY_FILE_NAMES.has(rule.to)) {
84
+ fail("invalidRenameTarget", { to: sanitizeDisplayText(rule.to) });
85
+ }
86
+ if (!targets.includes(rule.to) || chosen.has(rule.to))
87
+ continue;
88
+ if (rule.condition != null && !evaluateCondition(rule.condition, context)) {
89
+ continue;
90
+ }
91
+ chosen.set(rule.to, rule.from);
92
+ }
93
+ return targets.map((to) => {
94
+ const from = chosen.get(to) ?? to;
95
+ if (!available.has(from)) {
96
+ fail(to === PACKAGE_JSON_NAME ? "packageJsonMissing" : "lockMissing", {
97
+ lock: lockName,
98
+ packageManager: context.packageManager,
99
+ });
100
+ }
101
+ return { from, to };
102
+ });
103
+ };
61
104
  const selectMcpFiles = (rules, context, available) => {
62
105
  if (rules === undefined) {
63
106
  return [...available].filter((n) => n !== META_FILE).sort();
@@ -129,6 +172,24 @@ const walkDirectory = async (tree, vtree, dir, baseDir, parentMeta, context, col
129
172
  }
130
173
  return entries;
131
174
  }
175
+ if (ownMeta?.type === "dependencies") {
176
+ const parentRelative = relativeOf(dirnamePosix(dir));
177
+ const head = parentRelative.split("/")[0];
178
+ if (parentRelative === "" || head === ".accel" || head === ".git") {
179
+ throw createAssetDependencyError(getMessage("error.dependencies.rootNotAllowed", context.locale, {
180
+ dir: sanitizeDisplayText(dir),
181
+ }), { dir, kind: "rootNotAllowed" });
182
+ }
183
+ for (const { from, to } of selectDependencyFiles(ownMeta, context, dir, node.files)) {
184
+ entries.push({
185
+ sourceRelPath: joinPosix(dir, from),
186
+ relativePath: joinPosix(parentRelative, to),
187
+ meta: effectiveMeta,
188
+ kind: "dependencies",
189
+ });
190
+ }
191
+ return entries;
192
+ }
132
193
  if (ownMeta?.type === "file") {
133
194
  const parentRelative = relativeOf(dirnamePosix(dir));
134
195
  if (ownMeta.rename && ownMeta.rename.length > 0) {
@@ -182,8 +243,9 @@ const deduplicateByPath = (entries) => {
182
243
  byPath.set(entry.relativePath, entry);
183
244
  continue;
184
245
  }
185
- const existingIsFileType = existing.meta?.type === "file";
186
- const currentIsFileType = entry.meta?.type === "file";
246
+ const isExplicit = (e) => e.meta?.type === "file" || e.meta?.type === "dependencies";
247
+ const existingIsFileType = isExplicit(existing);
248
+ const currentIsFileType = isExplicit(entry);
187
249
  if (currentIsFileType && !existingIsFileType) {
188
250
  byPath.set(entry.relativePath, entry);
189
251
  }
@@ -2,6 +2,7 @@ import type { Logger } from "../core/logger.js";
2
2
  import type { PromptOptions, ResolvedOptions } from "../core/validation.js";
3
3
  import { type DeployResult, type ExistingFileHandler, type ProgressCallbacks } from "../asset/deployer.js";
4
4
  import { type generateMcpConfigs } from "../utils/mcp-generate.js";
5
+ import { type runEnsure, type syncDependencyArtifacts } from "../utils/runtime-ensure.js";
5
6
  export type RunAttachDeps = {
6
7
  projectDir: string;
7
8
  locale?: string;
@@ -30,6 +31,8 @@ export type RunAttachDeps = {
30
31
  resolveOptions?: (opts: PromptOptions) => Promise<ResolvedOptions>;
31
32
  onExistingFile?: ExistingFileHandler;
32
33
  generateMcpConfigs?: typeof generateMcpConfigs;
34
+ syncDependencyArtifacts?: typeof syncDependencyArtifacts;
35
+ runEnsure?: typeof runEnsure;
33
36
  };
34
37
  export declare const runAttach: (deps: RunAttachDeps) => Promise<DeployResult>;
35
38
  export declare const attachCommand: import("citty").CommandDef<{
@@ -110,7 +113,7 @@ export declare const attachCommand: import("citty").CommandDef<{
110
113
  };
111
114
  readonly "asset-ref": {
112
115
  readonly type: "string";
113
- readonly description: "Git branch/tag to fetch from the asset repository. Default: 2026-09-01-release";
116
+ readonly description: "Git branch/tag to fetch from the asset repository. Default: experiment";
114
117
  };
115
118
  readonly "asset-source": {
116
119
  readonly type: "string";
@@ -11,6 +11,7 @@ import { withExitCode } from "./run-wrapper.js";
11
11
  import { getMessage } from "../i18n/index.js";
12
12
  import { detectLocale } from "../utils/locale-detect.js";
13
13
  import { generateMcpConfigsBestEffort, } from "../utils/mcp-generate.js";
14
+ import { syncDependencyArtifactsAndEnsureBestEffort, } from "../utils/runtime-ensure.js";
14
15
  import { splitList } from "../utils/args.js";
15
16
  import { createClackLogger } from "../interactive/clack-logger.js";
16
17
  import { printSummary } from "../interactive/summary.js";
@@ -163,6 +164,11 @@ const runAttachInner = async (deps) => {
163
164
  count: String(result.skippedFiles.length),
164
165
  }));
165
166
  }
167
+ const { hasDeps } = await syncDependencyArtifactsAndEnsureBestEffort(projectDir, logger, {
168
+ skipInstall: deps.skipInstall ?? false,
169
+ syncImpl: deps.syncDependencyArtifacts,
170
+ runImpl: deps.runEnsure,
171
+ });
166
172
  await generateMcpConfigsBestEffort(projectDir, logger, deps.generateMcpConfigs);
167
173
  logger.success(getMessage("progress.complete", locale));
168
174
  printNextSteps({
@@ -170,6 +176,7 @@ const runAttachInner = async (deps) => {
170
176
  agents: resolved.agents,
171
177
  isInit: false,
172
178
  locale,
179
+ codexHookApproval: hasDeps && resolved.agents.includes("codex"),
173
180
  }, logger);
174
181
  return result;
175
182
  };
@@ -256,7 +263,7 @@ export const attachCommand = defineCommand({
256
263
  },
257
264
  "asset-ref": {
258
265
  type: "string",
259
- description: "Git branch/tag to fetch from the asset repository. Default: 2026-09-01-release",
266
+ description: "Git branch/tag to fetch from the asset repository. Default: experiment",
260
267
  },
261
268
  "asset-source": {
262
269
  type: "string",
@@ -1,6 +1,7 @@
1
1
  import type { HashsumEntry } from "../core/types.js";
2
2
  import type { Logger } from "../core/logger.js";
3
3
  import { type removeManagedMcpEntries } from "../utils/mcp-generate.js";
4
+ import { type removeDependencyArtifacts } from "../utils/runtime-ensure.js";
4
5
  export type DetachPrompts = {
5
6
  confirm: (entries: HashsumEntry[]) => Promise<boolean>;
6
7
  };
@@ -14,6 +15,7 @@ export type RunDetachDeps = {
14
15
  logger?: Logger;
15
16
  prompts?: DetachPrompts;
16
17
  removeManagedMcpEntries?: typeof removeManagedMcpEntries;
18
+ removeDependencyArtifacts?: typeof removeDependencyArtifacts;
17
19
  };
18
20
  export declare const runDetach: (deps: RunDetachDeps) => Promise<DetachResult>;
19
21
  export declare const detachCommand: import("citty").CommandDef<{}>;
@@ -10,6 +10,7 @@ import { getMessage } from "../i18n/index.js";
10
10
  import { detectLocale } from "../utils/locale-detect.js";
11
11
  import { removeManagedMcpEntriesBestEffort, } from "../utils/mcp-generate.js";
12
12
  import { withExitCode } from "./run-wrapper.js";
13
+ import { removeDependencyArtifactsBestEffort, } from "../utils/runtime-ensure.js";
13
14
  import { sanitizeDisplayText } from "../utils/sanitize-text.js";
14
15
  const createDefaultPrompts = (locale) => ({
15
16
  confirm: async () => {
@@ -63,6 +64,9 @@ export const runDetach = async (deps) => {
63
64
  }
64
65
  }
65
66
  await removeManagedMcpEntriesBestEffort(projectDir, logger, deps.removeManagedMcpEntries);
67
+ if ((settings.dependencies ?? []).length > 0) {
68
+ await removeDependencyArtifactsBestEffort(projectDir, logger, deps.removeDependencyArtifacts);
69
+ }
66
70
  await rm(join(projectDir, ".accel"), { recursive: true, force: true });
67
71
  if (skippedFiles.length > 0) {
68
72
  logger.outro(getMessage("detach.complete", locale, {
@@ -2,6 +2,7 @@ import type { Logger } from "../core/logger.js";
2
2
  import { type PromptOptions, type ResolvedOptions } from "../core/validation.js";
3
3
  import { type ProgressCallbacks } from "../asset/deployer.js";
4
4
  import { type generateMcpConfigs } from "../utils/mcp-generate.js";
5
+ import { type runEnsure, type syncDependencyArtifacts } from "../utils/runtime-ensure.js";
5
6
  export type RunInitDeps = {
6
7
  baseDir: string;
7
8
  locale?: string;
@@ -30,6 +31,8 @@ export type RunInitDeps = {
30
31
  resolveOptions?: (opts: PromptOptions) => Promise<ResolvedOptions>;
31
32
  initGitRepo?: (projectDir: string) => void;
32
33
  generateMcpConfigs?: typeof generateMcpConfigs;
34
+ syncDependencyArtifacts?: typeof syncDependencyArtifacts;
35
+ runEnsure?: typeof runEnsure;
33
36
  };
34
37
  export declare const runInit: (deps: RunInitDeps) => Promise<void>;
35
38
  export declare const initCommand: import("citty").CommandDef<{
@@ -111,7 +114,7 @@ export declare const initCommand: import("citty").CommandDef<{
111
114
  };
112
115
  readonly "asset-ref": {
113
116
  readonly type: "string";
114
- readonly description: "Git branch/tag to fetch from the asset repository. Default: 2026-09-01-release";
117
+ readonly description: "Git branch/tag to fetch from the asset repository. Default: experiment";
115
118
  };
116
119
  readonly "asset-source": {
117
120
  readonly type: "string";
@@ -12,6 +12,7 @@ import { withExitCode } from "./run-wrapper.js";
12
12
  import { getMessage } from "../i18n/index.js";
13
13
  import { detectLocale } from "../utils/locale-detect.js";
14
14
  import { generateMcpConfigsBestEffort, } from "../utils/mcp-generate.js";
15
+ import { syncDependencyArtifactsAndEnsureBestEffort, } from "../utils/runtime-ensure.js";
15
16
  import { commandExists } from "../utils/command-exists.js";
16
17
  import { splitList } from "../utils/args.js";
17
18
  import { createClackLogger } from "../interactive/clack-logger.js";
@@ -93,6 +94,11 @@ const runInitInner = async (deps) => {
93
94
  progress: deps.progress ?? buildProgressCallbacks(locale, logger),
94
95
  signal: deps.signal,
95
96
  });
97
+ const { hasDeps } = await syncDependencyArtifactsAndEnsureBestEffort(projectDir, logger, {
98
+ skipInstall: deps.skipInstall ?? false,
99
+ syncImpl: deps.syncDependencyArtifacts,
100
+ runImpl: deps.runEnsure,
101
+ });
96
102
  await generateMcpConfigsBestEffort(projectDir, logger, deps.generateMcpConfigs);
97
103
  if (resolved.withGit) {
98
104
  if (commandExists("git")) {
@@ -114,6 +120,7 @@ const runInitInner = async (deps) => {
114
120
  agents: resolved.agents,
115
121
  isInit: true,
116
122
  locale,
123
+ codexHookApproval: hasDeps && resolved.agents.includes("codex"),
117
124
  }, logger);
118
125
  };
119
126
  export const initCommand = defineCommand({
@@ -200,7 +207,7 @@ export const initCommand = defineCommand({
200
207
  },
201
208
  "asset-ref": {
202
209
  type: "string",
203
- description: "Git branch/tag to fetch from the asset repository. Default: 2026-09-01-release",
210
+ description: "Git branch/tag to fetch from the asset repository. Default: experiment",
204
211
  },
205
212
  "asset-source": {
206
213
  type: "string",
@@ -3,6 +3,7 @@ import { type Release } from "../core/catalog.js";
3
3
  import { type UpdaterProgressCallbacks } from "../asset/updater.js";
4
4
  import { type PresetSummary } from "../utils/preset-io.js";
5
5
  import { type generateMcpConfigs } from "../utils/mcp-generate.js";
6
+ import { type runEnsure, type syncDependencyArtifacts } from "../utils/runtime-ensure.js";
6
7
  export type SwitchPrompts = {
7
8
  selectPreset: (presets: PresetSummary[], locale: string) => Promise<string | undefined>;
8
9
  selectModules: (release: Release, initial: string[], locale: string) => Promise<string[]>;
@@ -24,6 +25,8 @@ export type RunSwitchDeps = {
24
25
  progress?: UpdaterProgressCallbacks;
25
26
  signal?: AbortSignal;
26
27
  generateMcpConfigs?: typeof generateMcpConfigs;
28
+ syncDependencyArtifacts?: typeof syncDependencyArtifacts;
29
+ runEnsure?: typeof runEnsure;
27
30
  };
28
31
  export declare const runSwitch: (deps: RunSwitchDeps) => Promise<void>;
29
32
  export declare const switchCommand: import("citty").CommandDef<{
@@ -8,7 +8,7 @@ import { collectSettingsErrors, } from "../core/validation.js";
8
8
  import { createClackLogger } from "../interactive/clack-logger.js";
9
9
  import { withExitCode } from "./run-wrapper.js";
10
10
  import { createGitAssetProvider } from "../asset/git-provider.js";
11
- import { applyUpdateActions, buildRenderedPlan, buildUpdatedRecords, classifySwitch, collectFileStates, } from "../asset/updater.js";
11
+ import { applyUpdateActions, buildRenderedPlan, dependencyDirsOfPlan, buildUpdatedRecords, classifySwitch, collectFileStates, } from "../asset/updater.js";
12
12
  import { createMessageCollector } from "../asset/messages.js";
13
13
  import { printAssetMessages } from "../interactive/asset-messages.js";
14
14
  import { installTriggerChanged, runInstallBuild } from "../asset/installer.js";
@@ -17,6 +17,8 @@ import { loadAndValidatePreset, listPresetSummaries, buildPresetSelectOptions, p
17
17
  import { getMessage } from "../i18n/index.js";
18
18
  import { detectLocale } from "../utils/locale-detect.js";
19
19
  import { generateMcpConfigsBestEffort, } from "../utils/mcp-generate.js";
20
+ import { runEnsureBestEffort, syncDependencyArtifactsBestEffort, } from "../utils/runtime-ensure.js";
21
+ import { isDependencyFile, withDependencies, } from "../asset/dependencies.js";
20
22
  import { splitList } from "../utils/args.js";
21
23
  import { printSummary } from "../interactive/summary.js";
22
24
  import { buildProgressCallbacks, resolvePathRejected, } from "../interactive/progress.js";
@@ -218,13 +220,17 @@ const runSwitchInner = async (deps) => {
218
220
  const actions = classifySwitch(states);
219
221
  const summary = await applyUpdateActions(projectDir, actions, deps.progress);
220
222
  const { hashEntries, deployedAssets } = buildUpdatedRecords(oldHashsum, actions);
221
- await writeSettings(projectDir, { ...newSettings, deployedAssets });
223
+ const dependencies = dependencyDirsOfPlan(theirsPlan);
224
+ await writeSettings(projectDir, withDependencies({ ...newSettings, deployedAssets }, dependencies));
222
225
  await writeHashsum(projectDir, hashEntries);
223
226
  await generateMcpConfigsBestEffort(projectDir, logger, deps.generateMcpConfigs);
227
+ const { ensureReady } = await syncDependencyArtifactsBestEffort(projectDir, logger, deps.syncDependencyArtifacts);
224
228
  printAssetMessages(messageCollector.drain(), logger);
229
+ const dependencyDirs = [...(settings.dependencies ?? []), ...dependencies];
225
230
  const changedPaths = actions
226
231
  .filter((a) => a.op !== "none")
227
- .map((a) => a.relativePath);
232
+ .map((a) => a.relativePath)
233
+ .filter((path) => !isDependencyFile(path, dependencyDirs));
228
234
  if (!deps.skipInstall && installTriggerChanged(changedPaths)) {
229
235
  const { success } = runInstallBuild(projectDir, newSettings.packageManager, buildProgressCallbacks(locale, logger));
230
236
  if (!success && summary.skippedSwitch.length > 0) {
@@ -234,6 +240,9 @@ const runSwitchInner = async (deps) => {
234
240
  logger.warn(`${getMessage("switch.installFailedHint", locale)}\n${list}`);
235
241
  }
236
242
  }
243
+ if (ensureReady && !deps.skipInstall) {
244
+ await runEnsureBestEffort(projectDir, logger, deps.runEnsure);
245
+ }
237
246
  printSwitchResult(summary, actions, locale, logger);
238
247
  }
239
248
  finally {
@@ -3,6 +3,7 @@ import type { Logger } from "../core/logger.js";
3
3
  import { type UpdaterProgressCallbacks } from "../asset/updater.js";
4
4
  import { type PresetSummary } from "../utils/preset-io.js";
5
5
  import { type generateMcpConfigs } from "../utils/mcp-generate.js";
6
+ import { type pruneRuntimeIds, type runEnsure, type syncDependencyArtifacts } from "../utils/runtime-ensure.js";
6
7
  export declare const createUpdateFallbackAbortedError: () => Error;
7
8
  export declare const isUpdateFallbackAbortedError: (err: unknown) => err is Error;
8
9
  export type FallbackMode = "abort" | "conflict" | "keep";
@@ -51,6 +52,9 @@ export type RunUpdateDeps = {
51
52
  progress?: UpdaterProgressCallbacks;
52
53
  signal?: AbortSignal;
53
54
  generateMcpConfigs?: typeof generateMcpConfigs;
55
+ syncDependencyArtifacts?: typeof syncDependencyArtifacts;
56
+ runEnsure?: typeof runEnsure;
57
+ pruneRuntimeIds?: typeof pruneRuntimeIds;
54
58
  };
55
59
  export declare const runUpdate: (deps: RunUpdateDeps) => Promise<void>;
56
60
  export declare const updateCommand: import("citty").CommandDef<{
@@ -9,7 +9,7 @@ import { createClackLogger } from "../interactive/clack-logger.js";
9
9
  import { withExitCode } from "./run-wrapper.js";
10
10
  import { createGitAssetProvider } from "../asset/git-provider.js";
11
11
  import { isWorktreeDirty } from "../git/worktree-status.js";
12
- import { buildRenderedPlan, collectFileStates, classifyAll, applyUpdateActions, buildUpdatedRecords, } from "../asset/updater.js";
12
+ import { buildRenderedPlan, dependencyDirsOfPlan, collectFileStates, classifyAll, applyUpdateActions, buildUpdatedRecords, } from "../asset/updater.js";
13
13
  import { createMessageCollector } from "../asset/messages.js";
14
14
  import { printAssetMessages } from "../interactive/asset-messages.js";
15
15
  import { mergeFile } from "../utils/merge-file.js";
@@ -19,6 +19,9 @@ import { loadAndValidatePreset, listPresetSummaries, buildPresetSelectOptions, p
19
19
  import { getMessage } from "../i18n/index.js";
20
20
  import { detectLocale } from "../utils/locale-detect.js";
21
21
  import { generateMcpConfigsBestEffort, } from "../utils/mcp-generate.js";
22
+ import { computeDependencyIds, pruneRuntimeIdsBestEffort, runEnsureBestEffort, syncDependencyArtifactsBestEffort, } from "../utils/runtime-ensure.js";
23
+ import { isDependencyFile, withDependencies, } from "../asset/dependencies.js";
24
+ import { ensureCommandFor } from "../core/constants.js";
22
25
  import { splitList } from "../utils/args.js";
23
26
  import { printSummary } from "../interactive/summary.js";
24
27
  import { buildProgressCallbacks, resolvePathRejected, } from "../interactive/progress.js";
@@ -156,7 +159,7 @@ const resolveInteractiveSettings = async (promptOpts, cliOnlyOpts, releaseIdFall
156
159
  agent: preset.agents,
157
160
  });
158
161
  };
159
- const printResult = (summary, locale, logger, installGuide) => {
162
+ const printResult = (summary, locale, logger, installGuide, dependencyConflictCommand) => {
160
163
  const lines = [
161
164
  [summary.updated, "update.result.updated"],
162
165
  [summary.merged, "update.result.merged"],
@@ -207,6 +210,11 @@ const printResult = (summary, locale, logger, installGuide) => {
207
210
  if (installGuide) {
208
211
  logger.warn(getMessage("update.installSkippedConflict", locale, installGuide));
209
212
  }
213
+ if (dependencyConflictCommand !== undefined) {
214
+ logger.warn(getMessage("update.dependencyConflictHint", locale, {
215
+ command: dependencyConflictCommand,
216
+ }));
217
+ }
210
218
  }
211
219
  if (summary.skippedEdited.length > 0) {
212
220
  const list = summary.skippedEdited
@@ -368,6 +376,8 @@ const runUpdateInner = async (deps) => {
368
376
  baseError = err;
369
377
  }
370
378
  const oldHashsum = await readHashsum(projectDir);
379
+ const previousDependencyDirs = settings.dependencies ?? [];
380
+ const previousIds = await computeDependencyIds(projectDir, previousDependencyDirs, settings.packageManager);
371
381
  let actions;
372
382
  if (baseTree) {
373
383
  deps.progress?.onRenderStart?.("base");
@@ -400,27 +410,38 @@ const runUpdateInner = async (deps) => {
400
410
  }
401
411
  const summary = await applyUpdateActions(projectDir, actions, deps.progress);
402
412
  const { hashEntries, deployedAssets } = buildUpdatedRecords(oldHashsum, actions);
403
- const updatedSettings = {
413
+ const dependencies = dependencyDirsOfPlan(theirsPlan);
414
+ const updatedSettings = withDependencies({
404
415
  ...newSettings,
405
416
  createdAt: settings.createdAt,
406
417
  assetSource: { ...source, url: targetUrl, ref: targetRef, commit: newCommit },
407
418
  deployedAssets,
408
- };
419
+ }, dependencies);
409
420
  await writeSettings(projectDir, updatedSettings);
410
421
  await writeHashsum(projectDir, hashEntries);
411
422
  await generateMcpConfigsBestEffort(projectDir, logger, deps.generateMcpConfigs);
423
+ const { ensureReady } = await syncDependencyArtifactsBestEffort(projectDir, logger, deps.syncDependencyArtifacts);
412
424
  printAssetMessages(messageCollector.drain(), logger);
413
425
  const skipInstall = deps.skipInstall ?? false;
414
426
  const hasConflicts = summary.conflicts.length > 0;
415
427
  if (summary.changedFileCount > 0 && !hasConflicts && !skipInstall) {
416
428
  runInstallBuild(projectDir, newSettings.packageManager, buildProgressCallbacks(locale, logger));
417
429
  }
430
+ if (ensureReady && !skipInstall) {
431
+ await runEnsureBestEffort(projectDir, logger, deps.runEnsure);
432
+ }
433
+ const nextIds = await computeDependencyIds(projectDir, dependencies, newSettings.packageManager);
434
+ const supersededIds = [...previousIds].filter((id) => !nextIds.has(id));
435
+ if (supersededIds.length > 0) {
436
+ await pruneRuntimeIdsBestEffort(projectDir, supersededIds, deps.pruneRuntimeIds);
437
+ }
418
438
  let installGuide;
419
439
  if (hasConflicts && !skipInstall) {
420
440
  const [installCommand, buildCommand] = getInstallCmds(newSettings.packageManager);
421
441
  installGuide = { installCommand, buildCommand };
422
442
  }
423
- printResult(summary, locale, logger, installGuide);
443
+ const dependencyConflict = summary.conflicts.some((path) => isDependencyFile(path, [...previousDependencyDirs, ...dependencies]));
444
+ printResult(summary, locale, logger, installGuide, dependencyConflict ? ensureCommandFor(newSettings.packageManager) : undefined);
424
445
  }
425
446
  finally {
426
447
  await provider.cleanup().catch(() => { });
@@ -7,6 +7,15 @@ export declare const LOCALE_OPTIONS: readonly ["ja", "en", "zh_CN"];
7
7
  export type LocaleOption = (typeof LOCALE_OPTIONS)[number];
8
8
  export declare const PACKAGE_MANAGER_OPTIONS: readonly ["bun", "npm", "yarn", "pnpm"];
9
9
  export type PackageManagerOption = (typeof PACKAGE_MANAGER_OPTIONS)[number];
10
+ export declare const ACCEL_DIR = ".accel";
11
+ export declare const ENSURE_SCRIPT_REL = ".accel/ensure.mjs";
12
+ export declare const ensureCommandFor: (packageManager: string) => string;
13
+ export declare const ENSURE_COMMANDS: ReadonlySet<string>;
14
+ export declare const RUNTIME_DIR_REL = ".accel/runtime";
15
+ export declare const PACKAGE_JSON_NAME = "package.json";
16
+ export declare const LOCKFILE_BY_PACKAGE_MANAGER: ReadonlyMap<string, string>;
17
+ export declare const lockfileFor: (packageManager: string) => string;
18
+ export declare const DEPENDENCY_FILE_NAMES: ReadonlySet<string>;
10
19
  export declare const DEFAULT_ASSET_REPO_URL = "https://github.com/accelplatform/skills";
11
- export declare const DEFAULT_ASSET_REF = "2026-09-01-release";
20
+ export declare const DEFAULT_ASSET_REF = "experiment";
12
21
  export declare const DEFAULT_SETTINGS: Omit<AccelSettings, "cliVersion" | "createdAt" | "deployedAssets" | "assetSource">;
@@ -7,8 +7,29 @@ export const PACKAGE_MANAGER_OPTIONS = [
7
7
  "yarn",
8
8
  "pnpm",
9
9
  ];
10
+ export const ACCEL_DIR = ".accel";
11
+ export const ENSURE_SCRIPT_REL = `${ACCEL_DIR}/ensure.mjs`;
12
+ export const ensureCommandFor = (packageManager) => `${packageManager === "bun" ? "bun" : "node"} ${ENSURE_SCRIPT_REL}`;
13
+ export const ENSURE_COMMANDS = new Set([
14
+ `bun ${ENSURE_SCRIPT_REL}`,
15
+ `node ${ENSURE_SCRIPT_REL}`,
16
+ ]);
17
+ export const RUNTIME_DIR_REL = `${ACCEL_DIR}/runtime`;
18
+ export const PACKAGE_JSON_NAME = "package.json";
19
+ export const LOCKFILE_BY_PACKAGE_MANAGER = new Map([
20
+ ["bun", "bun.lock"],
21
+ ["npm", "package-lock.json"],
22
+ ["yarn", "yarn.lock"],
23
+ ["pnpm", "pnpm-lock.yaml"],
24
+ ]);
25
+ export const lockfileFor = (packageManager) => LOCKFILE_BY_PACKAGE_MANAGER.get(packageManager) ??
26
+ LOCKFILE_BY_PACKAGE_MANAGER.get("bun");
27
+ export const DEPENDENCY_FILE_NAMES = new Set([
28
+ PACKAGE_JSON_NAME,
29
+ ...LOCKFILE_BY_PACKAGE_MANAGER.values(),
30
+ ]);
10
31
  export const DEFAULT_ASSET_REPO_URL = "https://github.com/accelplatform/skills";
11
- export const DEFAULT_ASSET_REF = "2026-09-01-release";
32
+ export const DEFAULT_ASSET_REF = "experiment";
12
33
  export const DEFAULT_SETTINGS = {
13
34
  name: "my-accel-project",
14
35
  artifactId: "",
@@ -4,3 +4,14 @@ export declare const isAbortError: (err: unknown) => boolean;
4
4
  export declare const normalizeAbort: (err: unknown, signal?: AbortSignal) => unknown;
5
5
  export declare const markReported: <T>(err: T) => T;
6
6
  export declare const isReportedError: (err: unknown) => boolean;
7
+ export type AssetDependencyErrorKind = "lockMissing" | "packageJsonMissing" | "invalidRenameTarget" | "rootNotAllowed";
8
+ export type AssetDependencyErrorDetail = {
9
+ dir: string;
10
+ kind: AssetDependencyErrorKind;
11
+ };
12
+ export declare const createAssetDependencyError: (message: string, detail: AssetDependencyErrorDetail) => Error & {
13
+ detail: AssetDependencyErrorDetail;
14
+ };
15
+ export declare const isAssetDependencyError: (err: unknown) => err is Error & {
16
+ detail: AssetDependencyErrorDetail;
17
+ };