@recued/dsh-officeroutines 0.1.0 → 0.1.1

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/README.md CHANGED
@@ -29,9 +29,20 @@ server manager, such as `web`.
29
29
 
30
30
  ## Configure
31
31
 
32
- To choose the command or its arguments, override the plugin's row in the
33
- profile's `cordis.patch.yml`. Without `--allow-folder`, the agent can open any
34
- file your account can.
32
+ Without `allowFolders`, the agent can open any file your account can. To limit
33
+ saved files to chosen folders, override the plugin's row in the profile's
34
+ `cordis.patch.yml`, then restart DSH. Each folder must exist, and subfolders
35
+ are included. The plugin still passes the Office companion's connection file.
36
+
37
+ ```yaml
38
+ - id: officeroutines-plugin
39
+ config:
40
+ allowFolders: [~/OfficeJobs, ~/Reports]
41
+ ```
42
+
43
+ `command` sets the path of `ofrt`. `args` replaces every argument, including
44
+ the companion's connection file, so it cannot be combined with
45
+ `allowFolders`.
35
46
 
36
47
  ```yaml
37
48
  - id: officeroutines-plugin
@@ -62,9 +73,14 @@ OfficeRoutines 配套程序后,插件还会传入它的连接文件,让智
62
73
  中打开的文档。工具名称以 `mcp__officeroutines__` 开头。
63
74
 
64
75
  需要 DSH 0.2.2-rc.5 或更高的 0.2 版本,并使用带有 MCP 服务器管理器的配置(如
65
- `web`)。如需指定命令或参数,请按上面的示例在配置的 `cordis.patch.yml` 中覆盖
66
- `officeroutines-plugin` 这一行。除非参数包含 `--allow-folder`,否则智能体可以打开
67
- 当前账户能访问的任何文件。
76
+ `web`)。
77
+
78
+ 未设置 `allowFolders` 时,智能体可以打开当前账户能访问的任何文件。要只允许指定的
79
+ 文件夹,请按上面的示例在配置的 `cordis.patch.yml` 中覆盖 `officeroutines-plugin`
80
+ 这一行,例如 `allowFolders: [~/OfficeJobs, ~/Reports]`,然后重启 DSH。每个文件夹
81
+ 必须已存在,子文件夹也包括在内;插件仍会传入配套程序的连接文件。`command` 指定
82
+ `ofrt` 的路径;`args` 会替换全部参数(包括连接文件),因此不能与 `allowFolders`
83
+ 同时使用。
68
84
 
69
85
  `ofrt job mcp install dsh` 无需 npm 也能连接 DSH。两者只选其一:它们都把服务器
70
86
  命名为 `officeroutines`。
package/locale/en.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "meta": {
3
3
  "title": "OfficeRoutines",
4
- "description": "Lets the agent read and change Excel, Word, and PowerPoint files through OfficeRoutines on this computer, and documents open in Office once the OfficeRoutines companion is set up. Its tools are named mcp__officeroutines__…. Install OfficeRoutines first: the plugin finds ofrt on PATH or where its installers put it, and its configuration can set command and args instead. Unless args include --allow-folder, the agent can open any file your account can."
4
+ "description": "Lets the agent read and change Excel, Word, and PowerPoint files through OfficeRoutines on this computer, and documents open in Office once the OfficeRoutines companion is set up. Its tools are named mcp__officeroutines__…. Install OfficeRoutines first: the plugin finds ofrt on PATH or where its installers put it. Unless allowFolders is set in the plugin's configuration, the agent can open any file your account can."
5
5
  }
6
6
  }
package/locale/zh.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "meta": {
3
3
  "title": "OfficeRoutines",
4
- "description": "让智能体通过本机的 OfficeRoutines 读取和修改 Excel、Word 和 PowerPoint 文件;设置好 OfficeRoutines 配套程序后,还能修改在 Office 中打开的文档。工具名称以 mcp__officeroutines__ 开头。请先安装 OfficeRoutines:插件会在 PATH 和安装程序的默认位置查找 ofrt,也可以在插件配置中用 command 和 args 指定。除非 args 包含 --allow-folder,否则智能体可以打开当前账户能访问的任何文件。"
4
+ "description": "让智能体通过本机的 OfficeRoutines 读取和修改 Excel、Word 和 PowerPoint 文件;设置好 OfficeRoutines 配套程序后,还能修改在 Office 中打开的文档。工具名称以 mcp__officeroutines__ 开头。请先安装 OfficeRoutines:插件会在 PATH 和安装程序的默认位置查找 ofrt。除非在插件配置中设置 allowFolders,否则智能体可以打开当前账户能访问的任何文件。"
5
5
  }
6
6
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@recued/dsh-officeroutines",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "DeepSeek Harness (DSH) plugin that connects OfficeRoutines, so the agent can read and change Excel, Word, and PowerPoint documents.",
5
5
  "type": "module",
6
6
  "exports": {
package/server.js CHANGED
@@ -7,7 +7,8 @@ const releases = 'https://github.com/recued/office-routines/releases'
7
7
  // findServer works out how DSH starts OfficeRoutines on this computer: the
8
8
  // ofrt command, and the Office companion's connection file when the companion
9
9
  // has run, so the agent can also reach documents open in Office. ofrt finds
10
- // OfficeCLI itself. The row's config can name the command and arguments.
10
+ // OfficeCLI itself. The row's config can limit saved files to allowFolders,
11
+ // name the command, or replace the arguments entirely with args.
11
12
  export function findServer({
12
13
  config = {},
13
14
  env = process.env,
@@ -24,6 +25,9 @@ export function findServer({
24
25
  )
25
26
  }
26
27
  if (Array.isArray(config.args) && config.args.every((arg) => typeof arg === 'string')) {
28
+ if (config.allowFolders !== undefined && config.allowFolders !== null) {
29
+ throw new Error('Set allowFolders or args, not both: args replaces every argument, so add --allow-folder to it.')
30
+ }
27
31
  return { command, args: [...config.args] }
28
32
  }
29
33
  const args = ['job', 'mcp']
@@ -31,9 +35,37 @@ export function findServer({
31
35
  if (connection) {
32
36
  args.push('--excel', connection)
33
37
  }
38
+ for (const folder of allowedFolders(config.allowFolders, home, files, paths)) {
39
+ args.push('--allow-folder', folder)
40
+ }
34
41
  return { command, args }
35
42
  }
36
43
 
44
+ // allowedFolders reads allowFolders: one folder or a list, each absolute or
45
+ // starting with ~, and each an existing directory, as ofrt requires.
46
+ function allowedFolders(value, home, files, paths) {
47
+ if (value === undefined || value === null) {
48
+ return []
49
+ }
50
+ const folders = Array.isArray(value) ? value : [value]
51
+ return folders.map((folder) => {
52
+ if (typeof folder !== 'string' || folder.trim() === '') {
53
+ throw new Error('allowFolders holds folder paths, such as ~/OfficeJobs.')
54
+ }
55
+ let full = folder
56
+ if (folder === '~' || folder.startsWith('~/') || folder.startsWith('~\\')) {
57
+ full = paths.join(home, folder.slice(1))
58
+ }
59
+ if (!paths.isAbsolute(full)) {
60
+ throw new Error(`allowFolders needs a full path or one starting with ~, not ${JSON.stringify(folder)}.`)
61
+ }
62
+ if (!files.isDirectory(full)) {
63
+ throw new Error(`allowFolders names ${JSON.stringify(folder)}, which is not an existing folder.`)
64
+ }
65
+ return full
66
+ })
67
+ }
68
+
37
69
  const localFiles = {
38
70
  exists: (file) => existsSync(file),
39
71
  isProgram(file) {
@@ -54,6 +86,13 @@ const localFiles = {
54
86
  return false
55
87
  }
56
88
  },
89
+ isDirectory(file) {
90
+ try {
91
+ return statSync(file).isDirectory()
92
+ } catch {
93
+ return false
94
+ }
95
+ },
57
96
  }
58
97
 
59
98
  function text(value) {