@aipanel/provider-deepseek 1.3.13 → 1.3.14

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/es/provider.js CHANGED
@@ -152,7 +152,12 @@ Please upgrade:
152
152
  });
153
153
  const patchPath = writeDshOverlay(options.cwd, overlay);
154
154
  const inheritSource = inheritSourceOf(this.opts.profile, this.opts.settingsFrom);
155
- const settingsPatchPath = inheritSource === null ? null : writeInheritLayer({ cwd: options.cwd, home: this.opts.home, source: inheritSource });
155
+ const settingsPatchPath = inheritSource === null ? null : writeInheritLayer({
156
+ cwd: options.cwd,
157
+ home: this.opts.home,
158
+ source: inheritSource,
159
+ target: this.opts.profile
160
+ });
156
161
  const proc = startDeepSeekWeb({
157
162
  port: options.port,
158
163
  hostname: DSH_LOOPBACK_HOST,
@@ -1,19 +1,34 @@
1
- /** 不跟着来源走的那几行(每个界面自己的偏好);理由见文件头 */
1
+ /** 不跟着来源走的那几行(每个界面自己的偏好,目标没写也不继承);理由见文件头 */
2
2
  export declare const INHERIT_SKIP_IDS: readonly string[];
3
3
  /** 生成层落在项目缓存目录,与 AIPanel 自己的 overlay 同处 */
4
4
  export declare const INHERIT_LAYER_FILENAME = "dsh-inherit.cordis.yml";
5
+ /** 目标 profile 自己已经定义/插入的行 id:来源层里同 id 的条目不再继承 */
6
+ export interface TargetEntries {
7
+ /** 顶层 `- id:` 条目 */
8
+ ids: ReadonlySet<string>;
9
+ /** 顶层 `- insert:` 里插入的条目 id */
10
+ insertIds: ReadonlySet<string>;
11
+ }
5
12
  /**
6
13
  * 该从哪个 profile 继承。
7
14
  * @param settingsFrom 解析后的选项:profile 名 / `false`(不叠)
8
15
  * @returns 源 profile 名;`null` = 不叠(关掉了,或目标就是它自己)
9
16
  */
10
17
  export declare function inheritSourceOf(profile: string, settingsFrom: string | false): string | null;
18
+ /**
19
+ * 读目标 profile 自己的 patch,收集它已经写过 / 插入过的行 id。
20
+ * 这些行由目标作主:来源层里同 id 的条目不能再叠上去(`--patch` 会整段覆盖目标的 config)。
21
+ */
22
+ export declare function collectTargetEntries(text: string): TargetEntries;
11
23
  /**
12
24
  * 按**顶层条目**剥掉若干 `- id:` 块(与 dsh-workbench 启动器里那段 awk 同口径:从命中的 `- ` 行
13
- * 一路丢到下一个顶层 `- ` 为止)。手写而不是上 YAML 库:这一层只是转交一份文本,没必要为它引入依赖,
25
+ * 一路丢到下一个顶层 `- ` 为止);给了 `skipInsertIds` 时,再把 `- insert:` 里命中 id 的嵌套条目
26
+ * 连同它的续行一起剥掉(整块剥空则连 `- insert:` 头一起丢,避免留下空的 insert 条目)。
27
+ * insert 的嵌套条目按 dsh 示例的 4 空格缩进识别;缩进不认识时整块原样保留,不误删。
28
+ * 手写而不是上 YAML 库:这一层只是转交一份文本,没必要为它引入依赖,
14
29
  * 也不能因为来源文件里有 `!!js` 之类的 dsh 扩展标签就解析失败。
15
30
  */
16
- export declare function stripEntries(text: string, skipIds: readonly string[]): string;
31
+ export declare function stripEntries(text: string, skipIds: readonly string[], skipInsertIds?: readonly string[]): string;
17
32
  /**
18
33
  * 写出继承层并返回它的路径;来源不存在/读不动时返回 `null`(**不阻断启动**:少了它只是回到老行为)。
19
34
  */
@@ -21,4 +36,5 @@ export declare function writeInheritLayer(input: {
21
36
  cwd: string;
22
37
  home?: string | undefined;
23
38
  source: string;
39
+ target: string;
24
40
  }): string | null;
@@ -9,19 +9,71 @@ function inheritSourceOf(profile, settingsFrom) {
9
9
  if (settingsFrom === false) return null;
10
10
  return settingsFrom === profile ? null : settingsFrom;
11
11
  }
12
- function stripEntries(text, skipIds) {
12
+ function collectTargetEntries(text) {
13
+ const ids = /* @__PURE__ */ new Set();
14
+ const insertIds = /* @__PURE__ */ new Set();
15
+ let inInsert = false;
16
+ for (const line of text.split("\n")) {
17
+ if (line.startsWith("- ")) {
18
+ inInsert = /^- insert:\s*$/.test(line);
19
+ const id2 = /^- id:\s*"?([^"\s]+)"?\s*$/.exec(line)?.[1];
20
+ if (id2 !== void 0) ids.add(id2);
21
+ continue;
22
+ }
23
+ if (!inInsert) continue;
24
+ const id = /^ {4}- id:\s*"?([^"\s]+)"?\s*$/.exec(line)?.[1];
25
+ if (id !== void 0) insertIds.add(id);
26
+ }
27
+ return { ids, insertIds };
28
+ }
29
+ function stripEntries(text, skipIds, skipInsertIds = []) {
13
30
  const skip = new Set(skipIds);
31
+ const skipInserts = new Set(skipInsertIds);
14
32
  const kept = [];
33
+ let block = null;
15
34
  let dropping = false;
35
+ const flush = () => {
36
+ if (block !== null) {
37
+ if (!dropping) kept.push(...filterInserted(block, skipInserts));
38
+ block = null;
39
+ dropping = false;
40
+ }
41
+ };
16
42
  for (const line of text.split("\n")) {
17
43
  if (line.startsWith("- ")) {
44
+ flush();
18
45
  const id = /^- id:\s*"?([^"\s]+)"?\s*$/.exec(line)?.[1];
19
46
  dropping = id !== void 0 && skip.has(id);
47
+ block = [line];
48
+ continue;
20
49
  }
21
- if (!dropping) kept.push(line);
50
+ if (block === null) kept.push(line);
51
+ else block.push(line);
22
52
  }
53
+ flush();
23
54
  return kept.join("\n");
24
55
  }
56
+ function filterInserted(block, skipInserts) {
57
+ if (skipInserts.size === 0 || !/^- insert:\s*$/.test(block[0])) return [...block];
58
+ if (!block.some((line) => /^ {4}- /.test(line))) return [...block];
59
+ const out = [block[0]];
60
+ let keeping = true;
61
+ for (const line of block.slice(1)) {
62
+ const id = /^ {4}- id:\s*"?([^"\s]+)"?\s*$/.exec(line)?.[1];
63
+ if (id !== void 0) {
64
+ keeping = !skipInserts.has(id);
65
+ if (keeping) out.push(line);
66
+ continue;
67
+ }
68
+ if (/^ {4}- /.test(line)) {
69
+ keeping = true;
70
+ out.push(line);
71
+ continue;
72
+ }
73
+ if (keeping) out.push(line);
74
+ }
75
+ return out.slice(1).some((line) => /^ {4}- /.test(line)) ? out : [];
76
+ }
25
77
  function writeInheritLayer(input) {
26
78
  const source = path.join(dshProfileDir(input.source, input.home), "cordis.patch.yml");
27
79
  let text;
@@ -31,16 +83,43 @@ function writeInheritLayer(input) {
31
83
  log.debug("\u6765\u6E90 profile \u6CA1\u6709\u53EF\u53E0\u7684\u914D\u7F6E\uFF0C\u8DF3\u8FC7", { source });
32
84
  return null;
33
85
  }
86
+ const owned = readTargetEntries(input.target, input.home);
87
+ const skipIds = inheritSkipIds(owned);
88
+ const skipInsertIds = [...owned.insertIds];
34
89
  const dir = path.join(input.cwd, AIPANEL_CACHE_DIR, "dsh");
35
90
  fs.mkdirSync(dir, { recursive: true });
36
91
  const file = path.join(dir, INHERIT_LAYER_FILENAME);
37
- fs.writeFileSync(file, stripEntries(text, INHERIT_SKIP_IDS), "utf8");
38
- log.debug("\u5DF2\u53E0\u4E0A\u6765\u6E90 profile \u7684\u914D\u7F6E", { source, file, skipIds: INHERIT_SKIP_IDS });
92
+ fs.writeFileSync(file, asPatchList(stripEntries(text, skipIds, skipInsertIds)), "utf8");
93
+ log.debug("\u5DF2\u53E0\u4E0A\u6765\u6E90 profile \u7684\u914D\u7F6E", {
94
+ source,
95
+ file,
96
+ skipIds,
97
+ skipInsertIds
98
+ });
39
99
  return file;
40
100
  }
101
+ function inheritSkipIds(owned) {
102
+ const skip = /* @__PURE__ */ new Set([...INHERIT_SKIP_IDS, ...owned.ids]);
103
+ if (owned.ids.has("llm-pi-ai")) skip.add("agent-default-model");
104
+ return [...skip];
105
+ }
106
+ function asPatchList(text) {
107
+ return text.split("\n").some((line) => line.startsWith("- ")) ? text : `${text.trimEnd()}
108
+ []
109
+ `;
110
+ }
111
+ function readTargetEntries(target, home) {
112
+ try {
113
+ const file = path.join(dshProfileDir(target, home), "cordis.patch.yml");
114
+ return collectTargetEntries(fs.readFileSync(file, "utf8"));
115
+ } catch {
116
+ return { ids: /* @__PURE__ */ new Set(), insertIds: /* @__PURE__ */ new Set() };
117
+ }
118
+ }
41
119
  export {
42
120
  INHERIT_LAYER_FILENAME,
43
121
  INHERIT_SKIP_IDS,
122
+ collectTargetEntries,
44
123
  inheritSourceOf,
45
124
  stripEntries,
46
125
  writeInheritLayer
package/lib/provider.cjs CHANGED
@@ -157,7 +157,12 @@ Please upgrade:
157
157
  });
158
158
  const patchPath = (0, import_profile.writeDshOverlay)(options.cwd, overlay);
159
159
  const inheritSource = (0, import_settings_layer.inheritSourceOf)(this.opts.profile, this.opts.settingsFrom);
160
- const settingsPatchPath = inheritSource === null ? null : (0, import_settings_layer.writeInheritLayer)({ cwd: options.cwd, home: this.opts.home, source: inheritSource });
160
+ const settingsPatchPath = inheritSource === null ? null : (0, import_settings_layer.writeInheritLayer)({
161
+ cwd: options.cwd,
162
+ home: this.opts.home,
163
+ source: inheritSource,
164
+ target: this.opts.profile
165
+ });
161
166
  const proc = (0, import_deepseek_web.startDeepSeekWeb)({
162
167
  port: options.port,
163
168
  hostname: import_constants.DSH_LOOPBACK_HOST,
@@ -29,6 +29,7 @@ var settings_layer_exports = {};
29
29
  __export(settings_layer_exports, {
30
30
  INHERIT_LAYER_FILENAME: () => INHERIT_LAYER_FILENAME,
31
31
  INHERIT_SKIP_IDS: () => INHERIT_SKIP_IDS,
32
+ collectTargetEntries: () => collectTargetEntries,
32
33
  inheritSourceOf: () => inheritSourceOf,
33
34
  stripEntries: () => stripEntries,
34
35
  writeInheritLayer: () => writeInheritLayer
@@ -45,19 +46,71 @@ function inheritSourceOf(profile, settingsFrom) {
45
46
  if (settingsFrom === false) return null;
46
47
  return settingsFrom === profile ? null : settingsFrom;
47
48
  }
48
- function stripEntries(text, skipIds) {
49
+ function collectTargetEntries(text) {
50
+ const ids = /* @__PURE__ */ new Set();
51
+ const insertIds = /* @__PURE__ */ new Set();
52
+ let inInsert = false;
53
+ for (const line of text.split("\n")) {
54
+ if (line.startsWith("- ")) {
55
+ inInsert = /^- insert:\s*$/.test(line);
56
+ const id2 = /^- id:\s*"?([^"\s]+)"?\s*$/.exec(line)?.[1];
57
+ if (id2 !== void 0) ids.add(id2);
58
+ continue;
59
+ }
60
+ if (!inInsert) continue;
61
+ const id = /^ {4}- id:\s*"?([^"\s]+)"?\s*$/.exec(line)?.[1];
62
+ if (id !== void 0) insertIds.add(id);
63
+ }
64
+ return { ids, insertIds };
65
+ }
66
+ function stripEntries(text, skipIds, skipInsertIds = []) {
49
67
  const skip = new Set(skipIds);
68
+ const skipInserts = new Set(skipInsertIds);
50
69
  const kept = [];
70
+ let block = null;
51
71
  let dropping = false;
72
+ const flush = () => {
73
+ if (block !== null) {
74
+ if (!dropping) kept.push(...filterInserted(block, skipInserts));
75
+ block = null;
76
+ dropping = false;
77
+ }
78
+ };
52
79
  for (const line of text.split("\n")) {
53
80
  if (line.startsWith("- ")) {
81
+ flush();
54
82
  const id = /^- id:\s*"?([^"\s]+)"?\s*$/.exec(line)?.[1];
55
83
  dropping = id !== void 0 && skip.has(id);
84
+ block = [line];
85
+ continue;
56
86
  }
57
- if (!dropping) kept.push(line);
87
+ if (block === null) kept.push(line);
88
+ else block.push(line);
58
89
  }
90
+ flush();
59
91
  return kept.join("\n");
60
92
  }
93
+ function filterInserted(block, skipInserts) {
94
+ if (skipInserts.size === 0 || !/^- insert:\s*$/.test(block[0])) return [...block];
95
+ if (!block.some((line) => /^ {4}- /.test(line))) return [...block];
96
+ const out = [block[0]];
97
+ let keeping = true;
98
+ for (const line of block.slice(1)) {
99
+ const id = /^ {4}- id:\s*"?([^"\s]+)"?\s*$/.exec(line)?.[1];
100
+ if (id !== void 0) {
101
+ keeping = !skipInserts.has(id);
102
+ if (keeping) out.push(line);
103
+ continue;
104
+ }
105
+ if (/^ {4}- /.test(line)) {
106
+ keeping = true;
107
+ out.push(line);
108
+ continue;
109
+ }
110
+ if (keeping) out.push(line);
111
+ }
112
+ return out.slice(1).some((line) => /^ {4}- /.test(line)) ? out : [];
113
+ }
61
114
  function writeInheritLayer(input) {
62
115
  const source = import_node_path.default.join((0, import_dsh_install.dshProfileDir)(input.source, input.home), "cordis.patch.yml");
63
116
  let text;
@@ -67,17 +120,44 @@ function writeInheritLayer(input) {
67
120
  log.debug("\u6765\u6E90 profile \u6CA1\u6709\u53EF\u53E0\u7684\u914D\u7F6E\uFF0C\u8DF3\u8FC7", { source });
68
121
  return null;
69
122
  }
123
+ const owned = readTargetEntries(input.target, input.home);
124
+ const skipIds = inheritSkipIds(owned);
125
+ const skipInsertIds = [...owned.insertIds];
70
126
  const dir = import_node_path.default.join(input.cwd, import_node.AIPANEL_CACHE_DIR, "dsh");
71
127
  import_node_fs.default.mkdirSync(dir, { recursive: true });
72
128
  const file = import_node_path.default.join(dir, INHERIT_LAYER_FILENAME);
73
- import_node_fs.default.writeFileSync(file, stripEntries(text, INHERIT_SKIP_IDS), "utf8");
74
- log.debug("\u5DF2\u53E0\u4E0A\u6765\u6E90 profile \u7684\u914D\u7F6E", { source, file, skipIds: INHERIT_SKIP_IDS });
129
+ import_node_fs.default.writeFileSync(file, asPatchList(stripEntries(text, skipIds, skipInsertIds)), "utf8");
130
+ log.debug("\u5DF2\u53E0\u4E0A\u6765\u6E90 profile \u7684\u914D\u7F6E", {
131
+ source,
132
+ file,
133
+ skipIds,
134
+ skipInsertIds
135
+ });
75
136
  return file;
76
137
  }
138
+ function inheritSkipIds(owned) {
139
+ const skip = /* @__PURE__ */ new Set([...INHERIT_SKIP_IDS, ...owned.ids]);
140
+ if (owned.ids.has("llm-pi-ai")) skip.add("agent-default-model");
141
+ return [...skip];
142
+ }
143
+ function asPatchList(text) {
144
+ return text.split("\n").some((line) => line.startsWith("- ")) ? text : `${text.trimEnd()}
145
+ []
146
+ `;
147
+ }
148
+ function readTargetEntries(target, home) {
149
+ try {
150
+ const file = import_node_path.default.join((0, import_dsh_install.dshProfileDir)(target, home), "cordis.patch.yml");
151
+ return collectTargetEntries(import_node_fs.default.readFileSync(file, "utf8"));
152
+ } catch {
153
+ return { ids: /* @__PURE__ */ new Set(), insertIds: /* @__PURE__ */ new Set() };
154
+ }
155
+ }
77
156
  // Annotate the CommonJS export names for ESM import in node:
78
157
  0 && (module.exports = {
79
158
  INHERIT_LAYER_FILENAME,
80
159
  INHERIT_SKIP_IDS,
160
+ collectTargetEntries,
81
161
  inheritSourceOf,
82
162
  stripEntries,
83
163
  writeInheritLayer
@@ -1,19 +1,34 @@
1
- /** 不跟着来源走的那几行(每个界面自己的偏好);理由见文件头 */
1
+ /** 不跟着来源走的那几行(每个界面自己的偏好,目标没写也不继承);理由见文件头 */
2
2
  export declare const INHERIT_SKIP_IDS: readonly string[];
3
3
  /** 生成层落在项目缓存目录,与 AIPanel 自己的 overlay 同处 */
4
4
  export declare const INHERIT_LAYER_FILENAME = "dsh-inherit.cordis.yml";
5
+ /** 目标 profile 自己已经定义/插入的行 id:来源层里同 id 的条目不再继承 */
6
+ export interface TargetEntries {
7
+ /** 顶层 `- id:` 条目 */
8
+ ids: ReadonlySet<string>;
9
+ /** 顶层 `- insert:` 里插入的条目 id */
10
+ insertIds: ReadonlySet<string>;
11
+ }
5
12
  /**
6
13
  * 该从哪个 profile 继承。
7
14
  * @param settingsFrom 解析后的选项:profile 名 / `false`(不叠)
8
15
  * @returns 源 profile 名;`null` = 不叠(关掉了,或目标就是它自己)
9
16
  */
10
17
  export declare function inheritSourceOf(profile: string, settingsFrom: string | false): string | null;
18
+ /**
19
+ * 读目标 profile 自己的 patch,收集它已经写过 / 插入过的行 id。
20
+ * 这些行由目标作主:来源层里同 id 的条目不能再叠上去(`--patch` 会整段覆盖目标的 config)。
21
+ */
22
+ export declare function collectTargetEntries(text: string): TargetEntries;
11
23
  /**
12
24
  * 按**顶层条目**剥掉若干 `- id:` 块(与 dsh-workbench 启动器里那段 awk 同口径:从命中的 `- ` 行
13
- * 一路丢到下一个顶层 `- ` 为止)。手写而不是上 YAML 库:这一层只是转交一份文本,没必要为它引入依赖,
25
+ * 一路丢到下一个顶层 `- ` 为止);给了 `skipInsertIds` 时,再把 `- insert:` 里命中 id 的嵌套条目
26
+ * 连同它的续行一起剥掉(整块剥空则连 `- insert:` 头一起丢,避免留下空的 insert 条目)。
27
+ * insert 的嵌套条目按 dsh 示例的 4 空格缩进识别;缩进不认识时整块原样保留,不误删。
28
+ * 手写而不是上 YAML 库:这一层只是转交一份文本,没必要为它引入依赖,
14
29
  * 也不能因为来源文件里有 `!!js` 之类的 dsh 扩展标签就解析失败。
15
30
  */
16
- export declare function stripEntries(text: string, skipIds: readonly string[]): string;
31
+ export declare function stripEntries(text: string, skipIds: readonly string[], skipInsertIds?: readonly string[]): string;
17
32
  /**
18
33
  * 写出继承层并返回它的路径;来源不存在/读不动时返回 `null`(**不阻断启动**:少了它只是回到老行为)。
19
34
  */
@@ -21,4 +36,5 @@ export declare function writeInheritLayer(input: {
21
36
  cwd: string;
22
37
  home?: string | undefined;
23
38
  source: string;
39
+ target: string;
24
40
  }): string | null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aipanel/provider-deepseek",
3
- "version": "1.3.13",
3
+ "version": "1.3.14",
4
4
  "type": "module",
5
5
  "main": "lib/index.cjs",
6
6
  "module": "es/index.js",
@@ -21,7 +21,7 @@
21
21
  "registry": "https://registry.npmjs.org/"
22
22
  },
23
23
  "dependencies": {
24
- "@aipanel/core": "1.3.13",
24
+ "@aipanel/core": "1.3.14",
25
25
  "execa": "^9.6.1"
26
26
  },
27
27
  "devDependencies": {