@spaceflow/core 0.4.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -227,6 +227,7 @@ __webpack_require__.d(__webpack_exports__, {
227
227
  ox: () => (/* reexport */ ConfigReader),
228
228
  mD: () => (/* reexport */ createStreamLoggerState),
229
229
  jl: () => (/* reexport */ defineMcpServer),
230
+ ss: () => (/* reexport */ findConfigFileWithField),
230
231
  PR: () => (/* reexport */ OUTPUT_MARKER_END),
231
232
  _k: () => (/* reexport */ mcp_McpServer),
232
233
  TM: () => (/* reexport */ ConfigReaderService),
@@ -5717,6 +5718,8 @@ const i18next = __rspack_external_i18next["default"] || __rspack_external_i18nex
5717
5718
  },
5718
5719
  returnNull: false,
5719
5720
  returnEmptyString: false,
5721
+ // 确保 init 同步完成(默认 initImmediate: true 会将加载推到 setTimeout)
5722
+ initImmediate: false,
5720
5723
  // i18next v25.8+ 会在 init 时输出 locize.com 推广日志
5721
5724
  showSupportNotice: false
5722
5725
  });
@@ -6243,14 +6246,46 @@ const NO_MERGE_FIELDS = [
6243
6246
  const config = readConfigSync(cwd);
6244
6247
  return config.dependencies || {};
6245
6248
  }
6249
+ /**
6250
+ * 找到包含指定字段的最高优先级配置文件路径
6251
+ * 如果没有找到,返回项目级 .spaceflowrc 路径(默认写入位置)
6252
+ * @param field 要查找的字段名
6253
+ * @param cwd 工作目录
6254
+ */ function findConfigFileWithField(field, cwd) {
6255
+ const workDir = cwd || process.cwd();
6256
+ // 按优先级从高到低查找,找到第一个包含该字段的文件
6257
+ const candidates = [
6258
+ (0,external_path_.join)(workDir, RC_FILE_NAME),
6259
+ (0,external_path_.join)(workDir, ".spaceflow", spaceflow_config_CONFIG_FILE_NAME),
6260
+ (0,external_path_.join)(homedir(), RC_FILE_NAME),
6261
+ (0,external_path_.join)(homedir(), ".spaceflow", spaceflow_config_CONFIG_FILE_NAME)
6262
+ ];
6263
+ for (const filePath of candidates){
6264
+ if ((0,external_fs_.existsSync)(filePath)) {
6265
+ try {
6266
+ const content = (0,external_fs_.readFileSync)(filePath, "utf-8");
6267
+ const config = JSON.parse(content);
6268
+ if (config[field] !== undefined) {
6269
+ return filePath;
6270
+ }
6271
+ } catch {
6272
+ // 解析失败,跳过
6273
+ }
6274
+ }
6275
+ }
6276
+ // 默认写入项目级 .spaceflowrc
6277
+ return (0,external_path_.join)(workDir, RC_FILE_NAME);
6278
+ }
6246
6279
  /**
6247
6280
  * 更新单个 dependency
6281
+ * 找到 dependencies 所在的配置文件并原地更新,默认写入 .spaceflowrc
6248
6282
  * @param name 依赖名称
6249
6283
  * @param source 依赖来源
6250
6284
  * @param cwd 工作目录,默认为 process.cwd()
6251
6285
  * @returns 是否有更新(false 表示已存在相同配置)
6252
6286
  */ function updateDependency(name, source, cwd) {
6253
- const config = readConfigSync(cwd);
6287
+ const targetFile = findConfigFileWithField("dependencies", cwd);
6288
+ const config = (0,external_fs_.existsSync)(targetFile) ? JSON.parse((0,external_fs_.readFileSync)(targetFile, "utf-8")) : {};
6254
6289
  if (!config.dependencies) {
6255
6290
  config.dependencies = {};
6256
6291
  }
@@ -6260,16 +6295,28 @@ const NO_MERGE_FIELDS = [
6260
6295
  return false;
6261
6296
  }
6262
6297
  dependencies[name] = source;
6263
- writeConfigSync(config, cwd);
6298
+ (0,external_fs_.writeFileSync)(targetFile, json_stringify_pretty_compact(config, {
6299
+ indent: 2
6300
+ }) + "\n");
6264
6301
  return true;
6265
6302
  }
6266
6303
  /**
6267
6304
  * 删除单个 dependency
6305
+ * 找到 dependencies 所在的配置文件并原地更新
6268
6306
  * @param name 依赖名称
6269
6307
  * @param cwd 工作目录,默认为 process.cwd()
6270
6308
  * @returns 是否有删除(false 表示不存在)
6271
6309
  */ function removeDependency(name, cwd) {
6272
- const config = readConfigSync(cwd);
6310
+ const targetFile = findConfigFileWithField("dependencies", cwd);
6311
+ if (!(0,external_fs_.existsSync)(targetFile)) {
6312
+ return false;
6313
+ }
6314
+ let config;
6315
+ try {
6316
+ config = JSON.parse((0,external_fs_.readFileSync)(targetFile, "utf-8"));
6317
+ } catch {
6318
+ return false;
6319
+ }
6273
6320
  if (!config.dependencies) {
6274
6321
  return false;
6275
6322
  }
@@ -6278,7 +6325,9 @@ const NO_MERGE_FIELDS = [
6278
6325
  return false;
6279
6326
  }
6280
6327
  delete dependencies[name];
6281
- writeConfigSync(config, cwd);
6328
+ (0,external_fs_.writeFileSync)(targetFile, json_stringify_pretty_compact(config, {
6329
+ indent: 2
6330
+ }) + "\n");
6282
6331
  return true;
6283
6332
  }
6284
6333
  /**
@@ -6802,6 +6851,7 @@ var __webpack_exports__ensureSpaceflowPackageJson = __webpack_exports__.rK;
6802
6851
  var __webpack_exports__extractName = __webpack_exports__.T$;
6803
6852
  var __webpack_exports__extractNpmPackageName = __webpack_exports__.oc;
6804
6853
  var __webpack_exports__feishuConfig = __webpack_exports__.rx;
6854
+ var __webpack_exports__findConfigFileWithField = __webpack_exports__.ss;
6805
6855
  var __webpack_exports__getConfigPath = __webpack_exports__.IG;
6806
6856
  var __webpack_exports__getConfigPaths = __webpack_exports__.VT;
6807
6857
  var __webpack_exports__getDependencies = __webpack_exports__.so;
@@ -6849,6 +6899,6 @@ var __webpack_exports__toLogLevel = __webpack_exports__.AZ;
6849
6899
  var __webpack_exports__updateDependency = __webpack_exports__.hq;
6850
6900
  var __webpack_exports__writeConfigSync = __webpack_exports__.$v;
6851
6901
  var __webpack_exports__z = __webpack_exports__.z;
6852
- export { __webpack_exports__CONFIG_FILE_NAME as CONFIG_FILE_NAME, __webpack_exports__ClaudeCodeAdapter as ClaudeCodeAdapter, __webpack_exports__ClaudeSetupService as ClaudeSetupService, __webpack_exports__ConfigReader as ConfigReader, __webpack_exports__ConfigReaderService as ConfigReaderService, __webpack_exports__DEFAULT_EDITOR as DEFAULT_EDITOR, __webpack_exports__DEFAULT_EXTERNALS as DEFAULT_EXTERNALS, __webpack_exports__DEFAULT_SUPPORT_EDITOR as DEFAULT_SUPPORT_EDITOR, __webpack_exports__DEFAULT_TS_RULE as DEFAULT_TS_RULE, __webpack_exports__DIFF_SIDE as DIFF_SIDE, __webpack_exports__EDITOR_DIR_MAPPING as EDITOR_DIR_MAPPING, __webpack_exports__FEISHU_CARD_ACTION_TRIGGER as FEISHU_CARD_ACTION_TRIGGER, __webpack_exports__FEISHU_MODULE_OPTIONS as FEISHU_MODULE_OPTIONS, __webpack_exports__FeishuCardService as FeishuCardService, __webpack_exports__FeishuSdkService as FeishuSdkService, __webpack_exports__FileAdapter as FileAdapter, __webpack_exports__GIT_PROVIDER_MODULE_OPTIONS as GIT_PROVIDER_MODULE_OPTIONS, __webpack_exports__GitProviderService as GitProviderService, __webpack_exports__GitSdkService as GitSdkService, __webpack_exports__GiteaAdapter as GiteaAdapter, __webpack_exports__GithubAdapter as GithubAdapter, __webpack_exports__GitlabAdapter as GitlabAdapter, __webpack_exports__LLM_ADAPTER as LLM_ADAPTER, __webpack_exports__LLM_PROXY_CONFIG as LLM_PROXY_CONFIG, __webpack_exports__LOG_LEVEL_PRIORITY as LOG_LEVEL_PRIORITY, __webpack_exports__LlmJsonPut as LlmJsonPut, __webpack_exports__LlmProxyService as LlmProxyService, __webpack_exports__LlmSessionImpl as LlmSessionImpl, __webpack_exports__Logger as Logger, __webpack_exports__MCP_SERVER_METADATA as MCP_SERVER_METADATA, __webpack_exports__MCP_TOOL_METADATA as MCP_TOOL_METADATA, __webpack_exports__McpServer as McpServer, __webpack_exports__McpTool as McpTool, __webpack_exports__MemoryAdapter as MemoryAdapter, __webpack_exports__OUTPUT_MARKER_END as OUTPUT_MARKER_END, __webpack_exports__OUTPUT_MARKER_START as OUTPUT_MARKER_START, __webpack_exports__OpenAIAdapter as OpenAIAdapter, __webpack_exports__OpenCodeAdapter as OpenCodeAdapter, __webpack_exports__OutputService as OutputService, __webpack_exports__PACKAGE_JSON as PACKAGE_JSON, __webpack_exports__ParallelExecutor as ParallelExecutor, __webpack_exports__RC_FILE_NAME as RC_FILE_NAME, __webpack_exports__REVIEW_STATE as REVIEW_STATE, __webpack_exports__SPACEFLOW_DIR as SPACEFLOW_DIR, __webpack_exports__SchemaGeneratorService as SchemaGeneratorService, __webpack_exports__StorageService as StorageService, __webpack_exports__addLocaleResources as addLocaleResources, __webpack_exports__addSpaceflowToDevDependencies as addSpaceflowToDevDependencies, __webpack_exports__buildGitPackageSpec as buildGitPackageSpec, __webpack_exports__calculateLineOffsets as calculateLineOffsets, __webpack_exports__calculateNewLineNumber as calculateNewLineNumber, __webpack_exports__ciConfig as ciConfig, __webpack_exports__configLoaders as configLoaders, __webpack_exports__createConfigLoader as createConfigLoader, __webpack_exports__createEnvConfigLoader as createEnvConfigLoader, __webpack_exports__createMultiEntryPluginConfig as createMultiEntryPluginConfig, __webpack_exports__createPluginConfig as createPluginConfig, __webpack_exports__createStreamLoggerState as createStreamLoggerState, __webpack_exports__defineExtension as defineExtension, __webpack_exports__defineMcpServer as defineMcpServer, __webpack_exports__detectPackageManager as detectPackageManager, __webpack_exports__detectProvider as detectProvider, __webpack_exports__dtoToJsonSchema as dtoToJsonSchema, __webpack_exports__ensureEditorGitignore as ensureEditorGitignore, __webpack_exports__ensureSpaceflowDir as ensureSpaceflowDir, __webpack_exports__ensureSpaceflowPackageJson as ensureSpaceflowPackageJson, __webpack_exports__extractName as extractName, __webpack_exports__extractNpmPackageName as extractNpmPackageName, __webpack_exports__feishuConfig as feishuConfig, __webpack_exports__getConfigPath as getConfigPath, __webpack_exports__getConfigPaths as getConfigPaths, __webpack_exports__getDependencies as getDependencies, __webpack_exports__getEditorDirName as getEditorDirName, __webpack_exports__getEnvFilePaths as getEnvFilePaths, __webpack_exports__getMcpServerMetadata as getMcpServerMetadata, __webpack_exports__getMcpTools as getMcpTools, __webpack_exports__getPackageManager as getPackageManager, __webpack_exports__getRegisteredPluginConfig as getRegisteredPluginConfig, __webpack_exports__getRegisteredSchemas as getRegisteredSchemas, __webpack_exports__getSourceType as getSourceType, __webpack_exports__getSpaceflowCoreVersion as getSpaceflowCoreVersion, __webpack_exports__getSpaceflowDir as getSpaceflowDir, __webpack_exports__getSupportedEditors as getSupportedEditors, __webpack_exports__gitProviderConfig as gitProviderConfig, __webpack_exports__initI18n as initI18n, __webpack_exports__isGitUrl as isGitUrl, __webpack_exports__isLocalPath as isLocalPath, __webpack_exports__isMcpServer as isMcpServer, __webpack_exports__isPnpmWorkspace as isPnpmWorkspace, __webpack_exports__llmConfig as llmConfig, __webpack_exports__loadEnvFiles as loadEnvFiles, __webpack_exports__loadSpaceflowConfig as loadSpaceflowConfig, __webpack_exports__logStreamEvent as logStreamEvent, __webpack_exports__mapGitStatus as mapGitStatus, __webpack_exports__normalizeSource as normalizeSource, __webpack_exports__normalizeVerbose as normalizeVerbose, __webpack_exports__parallel as parallel, __webpack_exports__parseChangedLinesFromPatch as parseChangedLinesFromPatch, __webpack_exports__parseDiffText as parseDiffText, __webpack_exports__parseHunksFromPatch as parseHunksFromPatch, __webpack_exports__parseRepoUrl as parseRepoUrl, __webpack_exports__parseVerbose as parseVerbose, __webpack_exports__readConfigSync as readConfigSync, __webpack_exports__registerPluginConfig as registerPluginConfig, __webpack_exports__registerPluginSchema as registerPluginSchema, __webpack_exports__removeDependency as removeDependency, __webpack_exports__resolveSpaceflowConfig as resolveSpaceflowConfig, __webpack_exports__runMcpServer as runMcpServer, __webpack_exports__shouldLog as shouldLog, __webpack_exports__spaceflowConfig as spaceflowConfig, __webpack_exports__storageConfig as storageConfig, __webpack_exports__t as t, __webpack_exports__toLogLevel as toLogLevel, __webpack_exports__updateDependency as updateDependency, __webpack_exports__writeConfigSync as writeConfigSync, __webpack_exports__z as z };
6902
+ export { __webpack_exports__CONFIG_FILE_NAME as CONFIG_FILE_NAME, __webpack_exports__ClaudeCodeAdapter as ClaudeCodeAdapter, __webpack_exports__ClaudeSetupService as ClaudeSetupService, __webpack_exports__ConfigReader as ConfigReader, __webpack_exports__ConfigReaderService as ConfigReaderService, __webpack_exports__DEFAULT_EDITOR as DEFAULT_EDITOR, __webpack_exports__DEFAULT_EXTERNALS as DEFAULT_EXTERNALS, __webpack_exports__DEFAULT_SUPPORT_EDITOR as DEFAULT_SUPPORT_EDITOR, __webpack_exports__DEFAULT_TS_RULE as DEFAULT_TS_RULE, __webpack_exports__DIFF_SIDE as DIFF_SIDE, __webpack_exports__EDITOR_DIR_MAPPING as EDITOR_DIR_MAPPING, __webpack_exports__FEISHU_CARD_ACTION_TRIGGER as FEISHU_CARD_ACTION_TRIGGER, __webpack_exports__FEISHU_MODULE_OPTIONS as FEISHU_MODULE_OPTIONS, __webpack_exports__FeishuCardService as FeishuCardService, __webpack_exports__FeishuSdkService as FeishuSdkService, __webpack_exports__FileAdapter as FileAdapter, __webpack_exports__GIT_PROVIDER_MODULE_OPTIONS as GIT_PROVIDER_MODULE_OPTIONS, __webpack_exports__GitProviderService as GitProviderService, __webpack_exports__GitSdkService as GitSdkService, __webpack_exports__GiteaAdapter as GiteaAdapter, __webpack_exports__GithubAdapter as GithubAdapter, __webpack_exports__GitlabAdapter as GitlabAdapter, __webpack_exports__LLM_ADAPTER as LLM_ADAPTER, __webpack_exports__LLM_PROXY_CONFIG as LLM_PROXY_CONFIG, __webpack_exports__LOG_LEVEL_PRIORITY as LOG_LEVEL_PRIORITY, __webpack_exports__LlmJsonPut as LlmJsonPut, __webpack_exports__LlmProxyService as LlmProxyService, __webpack_exports__LlmSessionImpl as LlmSessionImpl, __webpack_exports__Logger as Logger, __webpack_exports__MCP_SERVER_METADATA as MCP_SERVER_METADATA, __webpack_exports__MCP_TOOL_METADATA as MCP_TOOL_METADATA, __webpack_exports__McpServer as McpServer, __webpack_exports__McpTool as McpTool, __webpack_exports__MemoryAdapter as MemoryAdapter, __webpack_exports__OUTPUT_MARKER_END as OUTPUT_MARKER_END, __webpack_exports__OUTPUT_MARKER_START as OUTPUT_MARKER_START, __webpack_exports__OpenAIAdapter as OpenAIAdapter, __webpack_exports__OpenCodeAdapter as OpenCodeAdapter, __webpack_exports__OutputService as OutputService, __webpack_exports__PACKAGE_JSON as PACKAGE_JSON, __webpack_exports__ParallelExecutor as ParallelExecutor, __webpack_exports__RC_FILE_NAME as RC_FILE_NAME, __webpack_exports__REVIEW_STATE as REVIEW_STATE, __webpack_exports__SPACEFLOW_DIR as SPACEFLOW_DIR, __webpack_exports__SchemaGeneratorService as SchemaGeneratorService, __webpack_exports__StorageService as StorageService, __webpack_exports__addLocaleResources as addLocaleResources, __webpack_exports__addSpaceflowToDevDependencies as addSpaceflowToDevDependencies, __webpack_exports__buildGitPackageSpec as buildGitPackageSpec, __webpack_exports__calculateLineOffsets as calculateLineOffsets, __webpack_exports__calculateNewLineNumber as calculateNewLineNumber, __webpack_exports__ciConfig as ciConfig, __webpack_exports__configLoaders as configLoaders, __webpack_exports__createConfigLoader as createConfigLoader, __webpack_exports__createEnvConfigLoader as createEnvConfigLoader, __webpack_exports__createMultiEntryPluginConfig as createMultiEntryPluginConfig, __webpack_exports__createPluginConfig as createPluginConfig, __webpack_exports__createStreamLoggerState as createStreamLoggerState, __webpack_exports__defineExtension as defineExtension, __webpack_exports__defineMcpServer as defineMcpServer, __webpack_exports__detectPackageManager as detectPackageManager, __webpack_exports__detectProvider as detectProvider, __webpack_exports__dtoToJsonSchema as dtoToJsonSchema, __webpack_exports__ensureEditorGitignore as ensureEditorGitignore, __webpack_exports__ensureSpaceflowDir as ensureSpaceflowDir, __webpack_exports__ensureSpaceflowPackageJson as ensureSpaceflowPackageJson, __webpack_exports__extractName as extractName, __webpack_exports__extractNpmPackageName as extractNpmPackageName, __webpack_exports__feishuConfig as feishuConfig, __webpack_exports__findConfigFileWithField as findConfigFileWithField, __webpack_exports__getConfigPath as getConfigPath, __webpack_exports__getConfigPaths as getConfigPaths, __webpack_exports__getDependencies as getDependencies, __webpack_exports__getEditorDirName as getEditorDirName, __webpack_exports__getEnvFilePaths as getEnvFilePaths, __webpack_exports__getMcpServerMetadata as getMcpServerMetadata, __webpack_exports__getMcpTools as getMcpTools, __webpack_exports__getPackageManager as getPackageManager, __webpack_exports__getRegisteredPluginConfig as getRegisteredPluginConfig, __webpack_exports__getRegisteredSchemas as getRegisteredSchemas, __webpack_exports__getSourceType as getSourceType, __webpack_exports__getSpaceflowCoreVersion as getSpaceflowCoreVersion, __webpack_exports__getSpaceflowDir as getSpaceflowDir, __webpack_exports__getSupportedEditors as getSupportedEditors, __webpack_exports__gitProviderConfig as gitProviderConfig, __webpack_exports__initI18n as initI18n, __webpack_exports__isGitUrl as isGitUrl, __webpack_exports__isLocalPath as isLocalPath, __webpack_exports__isMcpServer as isMcpServer, __webpack_exports__isPnpmWorkspace as isPnpmWorkspace, __webpack_exports__llmConfig as llmConfig, __webpack_exports__loadEnvFiles as loadEnvFiles, __webpack_exports__loadSpaceflowConfig as loadSpaceflowConfig, __webpack_exports__logStreamEvent as logStreamEvent, __webpack_exports__mapGitStatus as mapGitStatus, __webpack_exports__normalizeSource as normalizeSource, __webpack_exports__normalizeVerbose as normalizeVerbose, __webpack_exports__parallel as parallel, __webpack_exports__parseChangedLinesFromPatch as parseChangedLinesFromPatch, __webpack_exports__parseDiffText as parseDiffText, __webpack_exports__parseHunksFromPatch as parseHunksFromPatch, __webpack_exports__parseRepoUrl as parseRepoUrl, __webpack_exports__parseVerbose as parseVerbose, __webpack_exports__readConfigSync as readConfigSync, __webpack_exports__registerPluginConfig as registerPluginConfig, __webpack_exports__registerPluginSchema as registerPluginSchema, __webpack_exports__removeDependency as removeDependency, __webpack_exports__resolveSpaceflowConfig as resolveSpaceflowConfig, __webpack_exports__runMcpServer as runMcpServer, __webpack_exports__shouldLog as shouldLog, __webpack_exports__spaceflowConfig as spaceflowConfig, __webpack_exports__storageConfig as storageConfig, __webpack_exports__t as t, __webpack_exports__toLogLevel as toLogLevel, __webpack_exports__updateDependency as updateDependency, __webpack_exports__writeConfigSync as writeConfigSync, __webpack_exports__z as z };
6853
6903
 
6854
6904
  //# sourceMappingURL=index.js.map