advisers 0.1.0-preview.1 → 0.1.0-preview.3

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-zh.md CHANGED
@@ -5,9 +5,11 @@
5
5
  ## 安装
6
6
 
7
7
  ```sh
8
- npm i -g advisers@next
8
+ npm i -g advisers@next advisers-office@next
9
9
  advisers soul init
10
+ advisers brief "做一份 Q4 预算 Excel,周五前给老板"
10
11
  advisers chat "周五前把报价发给王工"
12
+ advisers office xlsx spec.json out.xlsx
11
13
  advisers ls
12
14
  advisers export
13
15
  ```
@@ -16,11 +18,13 @@ CLI 目前是**context 预览**,不是聊天 UI:它记录消息、生成 Foc
16
18
 
17
19
  ## 状态
18
20
 
19
- `0.1.0-preview.1` 是预览版:
21
+ `0.1.0-preview.2` 是预览版:
20
22
 
21
23
  - 内存/JSON 账本,位于 `~/.advisers/state.json`;
22
24
  - soul 位于 `~/.advisers/soul.md`,人类独占;
23
- - 命令:`soul`、`chat`、`ls`、`why`、`forget`、`export`;
25
+ - 命令:`soul`、`brief`、`chat`、`office`、`ls`、`why`、`forget`、`export`;
26
+ - IntentBrief + 澄清策略 + readback;
27
+ - `advisers-office` 提供 DOCX/XLSX/PPTX/Mermaid/draw.io builder;
24
28
  - 不调模型、不用 SQLite、不接真实 IM、不含 DSH bundle。
25
29
 
26
30
  核心与架构:
package/README.md CHANGED
@@ -7,9 +7,11 @@ routines.
7
7
  ## Install
8
8
 
9
9
  ```sh
10
- npm i -g advisers@next
10
+ npm i -g advisers@next advisers-office@next
11
11
  advisers soul init
12
+ advisers brief "做一份 Q4 预算 Excel,周五前给老板"
12
13
  advisers chat "周五前把报价发给王工"
14
+ advisers office xlsx spec.json out.xlsx
13
15
  advisers ls
14
16
  advisers export
15
17
  ```
@@ -20,11 +22,13 @@ next milestone.
20
22
 
21
23
  ## Status
22
24
 
23
- `0.1.0-preview.1` is a preview:
25
+ `0.1.0-preview.2` is a preview:
24
26
 
25
27
  - in-memory/JSON ledger at `~/.advisers/state.json`;
26
28
  - soul at `~/.advisers/soul.md`, human-owned;
27
- - `soul`, `chat`, `ls`, `why`, `forget`, `export` commands;
29
+ - `soul`, `brief`, `chat`, `office`, `ls`, `why`, `forget`, `export` commands;
30
+ - IntentBrief + clarification policy + readback;
31
+ - DOCX/XLSX/PPTX/Mermaid/draw.io builders in `advisers-office`;
28
32
  - no LLM call, no SQLite, no real IM Link, no DSH bundle.
29
33
 
30
34
  Shared core and architecture:
package/bin/advisers.js CHANGED
@@ -76,6 +76,15 @@ Usage:
76
76
  advisers why <pref-id> explain a preference
77
77
  advisers forget <pref-id> forget a preference (tombstone)
78
78
  advisers export export the ledger as JSON
79
+ advisers brief <text> print the IntentBrief for a request
80
+ advisers office <kind> <spec.json> <out>
81
+ build docx/xlsx/pptx/xmind/mermaid/drawio
82
+ advisers routine ls list routines
83
+ advisers routine add <spec.json>
84
+ add a draft routine
85
+ advisers routine approve <id>
86
+ activate a routine (human action)
87
+ advisers routine archive <id>
79
88
  advisers soul show print soul.md
80
89
  advisers soul set <file> set soul.md from a file (human action)
81
90
  advisers soul init write a minimal starter soul.md
@@ -158,6 +167,104 @@ function exportLedger() {
158
167
  console.log(JSON.stringify(loadLedger().toJSON(), null, 2))
159
168
  }
160
169
 
170
+ function brief(text) {
171
+ if (!text) {
172
+ console.error('usage: advisers brief <text>')
173
+ process.exitCode = 1
174
+ return
175
+ }
176
+ const stage = process.env.ADVISERS_STAGE === 'trusted' ? 'trusted' : 'probation'
177
+ const brief = core.buildIntentBrief(text, { stage })
178
+ console.log(core.renderIntentBrief(brief))
179
+ console.log('\n' + core.renderReadback(brief))
180
+ }
181
+
182
+ function routine(sub, arg) {
183
+ const ledger = loadLedger()
184
+ if (sub === 'ls' || !sub) {
185
+ const rows = ledger.listRoutines()
186
+ if (!rows.length) {
187
+ console.log('no routines yet')
188
+ return
189
+ }
190
+ for (const r of rows) console.log(`${r.id}\t${r.status}\tv${r.version}\t${r.name}`)
191
+ return
192
+ }
193
+ if (sub === 'add') {
194
+ if (!arg) {
195
+ console.error('usage: advisers routine add <spec.json>')
196
+ process.exitCode = 1
197
+ return
198
+ }
199
+ const spec = JSON.parse(readFileSync(arg, 'utf8'))
200
+ const routine = ledger.addRoutine({
201
+ name: spec.name,
202
+ description: spec.description ?? '',
203
+ trigger: spec.trigger ?? [],
204
+ steps: spec.steps ?? [],
205
+ preferences: spec.preferences ?? [],
206
+ pitfalls: spec.pitfalls ?? [],
207
+ verification: spec.verification ?? [],
208
+ scope: spec.scope,
209
+ createdBy: spec.createdBy ?? 'user',
210
+ })
211
+ saveLedger(ledger)
212
+ console.log(`draft routine ${routine.id}: ${routine.name}; approve with \`advisers routine approve ${routine.id}\``)
213
+ return
214
+ }
215
+ if (sub === 'approve' || sub === 'archive') {
216
+ if (!arg) {
217
+ console.error(`usage: advisers routine ${sub} <id>`)
218
+ process.exitCode = 1
219
+ return
220
+ }
221
+ const routine = sub === 'approve' ? ledger.approveRoutine(arg) : ledger.archiveRoutine(arg)
222
+ saveLedger(ledger)
223
+ console.log(`${routine.status}: ${routine.id}`)
224
+ return
225
+ }
226
+ console.error(`unknown routine subcommand: ${sub}`)
227
+ process.exitCode = 1
228
+ }
229
+
230
+ async function office(kind, specFile, outFile) {
231
+ const kinds = ['docx', 'xlsx', 'pptx', 'xmind', 'mermaid', 'drawio']
232
+ if (!kinds.includes(kind) || !specFile || !outFile) {
233
+ console.error('usage: advisers office <docx|xlsx|pptx|xmind|mermaid|drawio> <spec.json> <out>')
234
+ process.exitCode = 1
235
+ return
236
+ }
237
+ let mod
238
+ if (process.env.ADVISERS_OFFICE_LOCAL === '1') {
239
+ mod = await import('../../office/dist/index.js')
240
+ } else {
241
+ try {
242
+ mod = await import('advisers-office')
243
+ } catch {
244
+ console.error('advisers-office is not installed; run `npm i -g advisers-office@next`')
245
+ process.exitCode = 1
246
+ return
247
+ }
248
+ }
249
+ const spec = JSON.parse(readFileSync(specFile, 'utf8'))
250
+ if (kind === 'mermaid') {
251
+ writeFileSync(outFile, mod.buildMermaid(spec))
252
+ console.log(`wrote ${outFile}`)
253
+ return
254
+ }
255
+ if (kind === 'drawio') {
256
+ writeFileSync(outFile, mod.buildDrawio(spec))
257
+ console.log(`wrote ${outFile}`)
258
+ return
259
+ }
260
+ const builder = kind === 'docx' ? mod.buildDocx : kind === 'xlsx' ? mod.buildXlsx : kind === 'xmind' ? mod.buildXmind : mod.buildPptx
261
+ const buffer = await builder(spec)
262
+ writeFileSync(outFile, buffer)
263
+ const result = kind === 'xmind' ? await mod.validateXmind(buffer) : await mod.validateOffice(buffer, kind)
264
+ console.log(result.ok ? `wrote ${outFile} (${buffer.length} bytes)` : `wrote ${outFile}, missing: ${result.missing.join(', ')}`)
265
+ if (!result.ok) process.exitCode = 1
266
+ }
267
+
161
268
  function soul(sub, file) {
162
269
  if (sub === 'show') {
163
270
  const doc = loadSoul()
@@ -228,6 +335,13 @@ if (!command || command === 'help' || command === '--help') {
228
335
  forget(args[0])
229
336
  } else if (command === 'export') {
230
337
  exportLedger()
338
+ } else if (command === 'brief') {
339
+ brief(args.join(' ').trim())
340
+ } else if (command === 'office') {
341
+ await office(args[0], args[1], args[2])
342
+ process.exit(process.exitCode || 0)
343
+ } else if (command === 'routine') {
344
+ routine(args[0], args[1])
231
345
  } else if (command === 'soul') {
232
346
  soul(args[0], args[1])
233
347
  } else {
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  export * from 'advisers-core'
2
2
 
3
- export const version = '0.1.0-preview.1'
3
+ export const version = '0.1.0-preview.3'
4
4
  export const distribution = 'cordis'
5
5
  export const status = 'bootstrapping'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "advisers",
3
- "version": "0.1.0-preview.1",
3
+ "version": "0.1.0-preview.3",
4
4
  "description": "A staff of AI advisers: a cordis-native personal secretary runtime with scoped memory, commitments, and reviewable routines.",
5
5
  "keywords": [
6
6
  "cordis",
@@ -30,7 +30,7 @@
30
30
  "LICENSE"
31
31
  ],
32
32
  "dependencies": {
33
- "advisers-core": "0.1.0-preview.1"
33
+ "advisers-core": "0.1.0-preview.3"
34
34
  },
35
35
  "repository": {
36
36
  "type": "git",
@@ -43,5 +43,13 @@
43
43
  },
44
44
  "publishConfig": {
45
45
  "access": "public"
46
+ },
47
+ "peerDependencies": {
48
+ "advisers-office": "0.1.0-preview.2"
49
+ },
50
+ "peerDependenciesMeta": {
51
+ "advisers-office": {
52
+ "optional": true
53
+ }
46
54
  }
47
55
  }