@morlay/dsh-agent-instruction 0.0.0-stage → 0.2.0-alpha.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 morlay
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,21 @@
1
- # Temporary Holding Version
1
+ # @morlay/dsh-agent-instruction
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ 把仓库里的 agent 指令按字节上限注入系统提示词。
4
+
5
+ ## 用法
6
+
7
+ ```ts
8
+ import { provideAgentInstruction } from "@morlay/dsh-agent-instruction";
9
+
10
+ ...provideAgentInstruction(),
11
+ ```
12
+
13
+ ## 事实
14
+
15
+ - 这是**行**不是模块:`AgentInstruction` 把上游 `@deepseek-ai/dsh-agent-instructions` 的插件接管进本行作用域,`deps` 是 `SessionProjectionStore` 与 `WorkingDirectory`。
16
+ - `maxBytes` 是上游必填项,本行固定给 64 KiB。
17
+ - 没有自有契约面:消费方是上游 `systemPrompt` 一侧,本仓没有按令牌注入它的地方。
18
+
19
+ ## 设计
20
+
21
+ 包内子域怎么分、契约与行各放哪,见[包内子域拆分与注册抽象](../.agents/designs/20261028-包内子域拆分与注册抽象.md)。
@@ -0,0 +1,13 @@
1
+ import * as AgentInstructionsPlugin from "@deepseek-ai/dsh-agent-instructions";
2
+ import { Context } from "@morlay/zephyr";
3
+ import { AgentDirectory, WorkingDirectory } from "@morlay/dsh-agent";
4
+ declare const AgentInstruction_base: import("@morlay/zephyr/compat").AdaptedClass<import("@morlay/zephyr").TokenClass<unknown>, typeof AgentInstructionsPlugin>;
5
+ export declare class AgentInstruction extends AgentInstruction_base {
6
+ agents: AgentDirectory & import("@morlay/zephyr").Required<AgentDirectory>;
7
+ workingDirectory: WorkingDirectory & import("@morlay/zephyr").Required<WorkingDirectory>;
8
+ /** 部署的数据根:用户级指令从 `<dataDir>` 下的候选文件读。 */
9
+ private readonly appEnv;
10
+ onInit(ctx: Context): Promise<void>;
11
+ }
12
+ export declare const provideAgentInstruction: (...features: import("@morlay/zephyr").ProviderFeature[]) => readonly [typeof AgentInstruction];
13
+ export {};
package/dist/index.mjs ADDED
@@ -0,0 +1,37 @@
1
+ import * as AgentInstructionsPlugin from "@deepseek-ai/dsh-agent-instructions";
2
+ import { Injectable, inject, provide } from "@morlay/zephyr";
3
+ import { fromCordis } from "@morlay/zephyr/compat";
4
+ import { AppEnv } from "@morlay/zephyr-app";
5
+ import { AgentDirectory, WorkingDirectory } from "@morlay/dsh-agent";
6
+ // \0@oxc-project+runtime@0.160.0/helpers/esm/decorate.js
7
+ function __decorate(decorators, target, key, desc) {
8
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
9
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
10
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
11
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
12
+ }
13
+ // src/agent-instruction.service.ts
14
+ /** 指令链每段的 UTF-8 字节上限(上游 `maxBytes` 必填,schema 没有默认值)。 */
15
+ const MAX_BYTES = 65536;
16
+ let AgentInstruction = class AgentInstruction extends fromCordis(AgentInstructionsPlugin) {
17
+ agents = inject(AgentDirectory);
18
+ workingDirectory = inject(WorkingDirectory);
19
+ /** 部署的数据根:用户级指令从 `<dataDir>` 下的候选文件读。 */
20
+ appEnv = inject.optional(AppEnv);
21
+ async onInit(ctx) {
22
+ const rowConfig = this.rowConfig ?? {};
23
+ const dshHome = rowConfig.dshHome ?? this.appEnv?.values.dataDir;
24
+ const config = {
25
+ maxBytes: rowConfig.maxBytes ?? MAX_BYTES,
26
+ ...dshHome === void 0 ? {} : { dshHome }
27
+ };
28
+ await this.mount(ctx, config, {
29
+ agents: this.agents,
30
+ workingDirectory: this.workingDirectory
31
+ });
32
+ }
33
+ };
34
+ AgentInstruction = __decorate([Injectable()], AgentInstruction);
35
+ // src/agent-instruction.provide.ts
36
+ const provideAgentInstruction = provide([AgentInstruction]);
37
+ export { AgentInstruction, provideAgentInstruction };
package/package.json CHANGED
@@ -1,6 +1,41 @@
1
1
  {
2
2
  "name": "@morlay/dsh-agent-instruction",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.2.0-alpha.0",
4
+ "private": false,
5
+ "description": "把仓库里的 agent 指令按字节上限注入系统提示词。",
6
+ "files": [
7
+ "dist",
8
+ "src",
9
+ "!**/__tests__"
10
+ ],
11
+ "type": "module",
12
+ "exports": {
13
+ ".": {
14
+ "types": "./dist/index.d.mts",
15
+ "default": "./dist/index.mjs"
16
+ },
17
+ "./package.json": "./package.json"
18
+ },
19
+ "dependencies": {
20
+ "@morlay/zephyr": "^0.2.0-alpha.0",
21
+ "@morlay/zephyr-app": "^0.2.0-alpha.0"
22
+ },
23
+ "devDependencies": {
24
+ "@deepseek-ai/dsh-fs-local": "^0.2.3-alpha.3",
25
+ "@morlay/dsh-agent": "^0.2.0-alpha.0",
26
+ "@morlay/dsh-fs": "^0.2.0-alpha.0",
27
+ "@morlay/dsh-session": "^0.2.0-alpha.0"
28
+ },
29
+ "peerDependencies": {
30
+ "@deepseek-ai/dsh-agent-instructions": "^0.2.3-alpha.3"
31
+ },
32
+ "engines": {
33
+ "dsh": ">= 0.2.3-alpha.3 < 0.2.4"
34
+ },
35
+ "repository": {
36
+ "type": "git",
37
+ "url": "https://github.com/morlay/zephyr.git",
38
+ "directory": "packages/agent/dsh-agent-instruction"
39
+ },
40
+ "scripts": {}
6
41
  }
@@ -0,0 +1,4 @@
1
+ import { provide } from "@morlay/zephyr";
2
+ import { AgentInstruction } from "./agent-instruction.service.ts";
3
+
4
+ export const provideAgentInstruction = provide([AgentInstruction]);
@@ -0,0 +1,47 @@
1
+ // agent 指令(纯实现行,不声明契约)。
2
+ //
3
+ // 上游那一行读**两个** home(`resolveDiscoveryConfig` → `resolveDshHome` / `resolveAgentsHome`),
4
+ // 缺省都回落到进程环境。逐位判过,两者不是一回事:
5
+ //
6
+ // - `dshHome`(`$DSH_HOME`,再 `~/.dsh`):**本部署的数据根**下的用户级指令根。装配给了 `AppEnv.dataDir`
7
+ // 却让这里读 `~/.dsh` 就是两个 home(`apps/AGENTS.md` 红线③),所以从 `AppEnv` 钉。
8
+ // - `agentsHome`(`$DSH_AGENTS_HOME`,再 `~/.agents`):**跨 agent 共享的用户配置根**。它回答「这台机器上
9
+ // 所有 agent 共享什么」,不是「这个部署的数据放哪」——由 `DSH_AGENTS_HOME` 决定(bundle 层那一处授权
10
+ // 读点),本行**不接管**。把它钉到 `dataDir`,同一台机器上的两个部署就互相看不见对方写的 `AGENTS.md`。
11
+ import * as AgentInstructionsPlugin from "@deepseek-ai/dsh-agent-instructions";
12
+ import { Injectable, inject, type Context } from "@morlay/zephyr";
13
+ import { fromCordis } from "@morlay/zephyr/compat";
14
+ import { AppEnv } from "@morlay/zephyr-app";
15
+ import { WorkingDirectory, AgentDirectory } from "@morlay/dsh-agent";
16
+
17
+ /** 指令链每段的 UTF-8 字节上限(上游 `maxBytes` 必填,schema 没有默认值)。 */
18
+ const MAX_BYTES = 64 * 1024;
19
+
20
+ /** 交给上游的 config:`dshHome` 按部署数据根钉,其余取上游默认。 */
21
+ interface AgentInstructionConfig {
22
+ readonly maxBytes: number;
23
+ readonly dshHome?: string;
24
+ }
25
+
26
+ @Injectable()
27
+ export class AgentInstruction extends fromCordis(AgentInstructionsPlugin) {
28
+ agents = inject(AgentDirectory);
29
+
30
+ workingDirectory = inject(WorkingDirectory);
31
+
32
+ /** 部署的数据根:用户级指令从 `<dataDir>` 下的候选文件读。 */
33
+ private readonly appEnv = inject.optional(AppEnv);
34
+
35
+ override async onInit(ctx: Context): Promise<void> {
36
+ const rowConfig = (this.rowConfig ?? {}) as Partial<AgentInstructionConfig>;
37
+ const dshHome = rowConfig.dshHome ?? this.appEnv?.values.dataDir;
38
+ const config: AgentInstructionConfig = {
39
+ maxBytes: rowConfig.maxBytes ?? MAX_BYTES,
40
+ ...(dshHome === undefined ? {} : { dshHome }),
41
+ };
42
+ await this.mount(ctx, config, {
43
+ agents: this.agents,
44
+ workingDirectory: this.workingDirectory,
45
+ });
46
+ }
47
+ }
package/src/index.ts ADDED
@@ -0,0 +1,5 @@
1
+ // agent 指令的包根:一行实现 + 它的装配模块。
2
+ //
3
+ // 这一行没有自有契约面:它挂在系统提示装配与会话投影上,消费方是上游 `systemPrompt` 那一侧。
4
+ export * from "./agent-instruction.service.ts";
5
+ export * from "./agent-instruction.provide.ts";