bs-engineering-suite 2.9.0-rc.13 → 2.9.0-rc.15

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.
Files changed (29) hide show
  1. package/NOTICE.md +1 -1
  2. package/README.md +35 -25
  3. package/cordis.patch.yml +87 -1
  4. package/docs/content-packs/ONLINE_LIBRARY.md +1 -1
  5. package/docs/windows-install.md +5 -5
  6. package/docs/windows-usage.md +2 -2
  7. package/node_modules/@buildseek/diagnostics/lib/client.js +4 -4
  8. package/node_modules/@buildseek/diagnostics/lib/version.js +1 -1
  9. package/node_modules/@buildseek/harness-engineering-document-plugin/dist/client.js +2 -2
  10. package/node_modules/@buildseek/harness-engineering-document-plugin/lib/content-packs.js +15 -1
  11. package/node_modules/@buildseek/harness-engineering-document-plugin/lib/project-content-flow.js +1 -0
  12. package/node_modules/@buildseek/harness-engineering-document-plugin/lib/project-data/application.js +1 -1
  13. package/node_modules/@buildseek/harness-engineering-document-plugin/lib/project-data/project-setup.js +5 -1
  14. package/node_modules/@buildseek/harness-engineering-document-plugin/lib/service.js +13 -1
  15. package/node_modules/@buildseek/harness-engineering-document-plugin/lib/types/content-packs.d.ts +1 -1
  16. package/node_modules/@buildseek/harness-engineering-document-plugin/lib/types/host-adapter/optional-host.d.ts +9 -0
  17. package/node_modules/@buildseek/harness-engineering-document-plugin/lib/types/project-data/application.d.ts +1 -0
  18. package/node_modules/@buildseek/harness-engineering-document-plugin/lib/types/service.d.ts +2 -0
  19. package/node_modules/@buildseek/harness-engineering-document-plugin/lib/types/workbench/application.d.ts +2 -0
  20. package/node_modules/@buildseek/harness-engineering-document-plugin/lib/workbench/application.js +9 -1
  21. package/node_modules/@buildseek/harness-engineering-document-plugin/lib/workbench/native.js +30 -6
  22. package/node_modules/@buildseek/harness-engineering-document-plugin/presets/buildseek-engineering-documents/preset.yml +1 -1
  23. package/node_modules/@buildseek/harness-engineering-document-plugin/presets/buildseek-engineering-documents.patch.yml +1 -1
  24. package/node_modules/@buildseek/platform/project-setup.d.ts +1 -1
  25. package/node_modules/@buildseek/platform/project-setup.js +41 -1
  26. package/node_modules/@dsh-engineering/workbench/client/bundle.js +105 -39
  27. package/node_modules/bs-engineering-docs/lib/agent.js +64 -14
  28. package/node_modules/bs-engineering-docs/lib/project-tools.js +133 -1
  29. package/package.json +1 -1
@@ -58,7 +58,15 @@ const SnapshotSchema = z.object({ schema: z.literal('buildseek/engineering-workb
58
58
  const StoredSnapshotSchema = SnapshotSchema.extend({ artifacts: z.array(z.union([ArtifactSchema, LegacyArtifactSchema])).max(2000), mutations: z.array(MutationRecordSchema).max(1000).optional() }).strict();
59
59
  const StoredRecordSchema = z.object({ sequence: z.number().int().positive(), previous: sha.nullable(), state: StoredSnapshotSchema, digest: sha }).strict();
60
60
  const NativeMessageSchema = z.object({ id, text: z.string().max(1048576), timestamp: z.number().finite().nonnegative().optional(), attachments: z.array(z.object({ id, name: z.string().min(1).max(255), mime: z.string().max(128) }).strict()).max(20).optional() }).strict();
61
- const nativeIntent = (text) => /^(生成|生成候选|生成工程资料)[。!!]?$/u.test(text.trim());
61
+ /** Accept a direct imperative; questions, conditional or negative wording need clarification. */
62
+ export const nativeIntent = (text) => {
63
+ const value = text.trim();
64
+ if (!value || value.length > 160 || /[??]/u.test(value) ||
65
+ /(?:不要|不用|不必|不需|不想|不能|不可|不应|不允许|不生成|先不|暂不|并不|没有|没必要|尚未|无需|无须|别生成|先别|暂别|别再|避免|取消|停止|禁止|暂缓|推迟|稍后|待会|之后|能否|是否|可否|如何|怎么|为什么|如果|假如|除非)/u.test(value) ||
66
+ /(?:吗|么|嘛|呢)[。!!]*$/u.test(value))
67
+ return false;
68
+ return /^(?:(?:请帮我|麻烦你|请你|帮我|麻烦|请|现在|立即|立刻)\s*)?生成(?!(?:的|了|过|完|流程|过程|方法|原理|规则|说明|状态))[\s\S]*$/u.test(value);
69
+ };
62
70
  const hash = (value) => canonicalSha256(asJson(value));
63
71
  const same = (left, right) => canonicalJson(asJson(left)) === canonicalJson(asJson(right));
64
72
  const requestHash = (revision, draft, materials) => hash({ revision, draft, materials });
@@ -19,7 +19,7 @@ export const WORKBENCH_SCOPES = ['engineering-document:workspace', 'engineering-
19
19
  const packageRoot = fileURLToPath(new URL('../../', import.meta.url)).replace(/\/$/, '');
20
20
  const presetFiles = [
21
21
  { path: 'agent.cordis.yml', bytes: 97, sha256: '5249821a32ce89aa848300068159c5a652f7658725c032ba3dda525762d53594', mode: '0600' },
22
- { path: 'preset.yml', bytes: 159, sha256: '95a8a738457291c9266872c7ca9337898618cf9817f469f1813becf62fc2eda3', mode: '0600' },
22
+ { path: 'preset.yml', bytes: 153, sha256: '66a5f8a501168348992e4a157d9eb9d9a402c3ba6a5bc273fa7cbfc675b6d2e7', mode: '0600' },
23
23
  ];
24
24
  /**
25
25
  * 当前生效的 agent preset。
@@ -319,19 +319,43 @@ export class NativeWorkbench {
319
319
  }
320
320
  /** Current model-visible real user event, pinned to the official live surface and durable bytes. */
321
321
  async currentDialogueEvent(id) {
322
- if (!hasDialogueHost(optionalHost(this.ctx)))
322
+ const host = optionalHost(this.ctx);
323
+ if (!hasDialogueHost(host))
323
324
  workbenchError('EDP_DIALOGUE_HOST_UNAVAILABLE');
324
- const session = await this.session(id);
325
+ let session = await this.session(id);
325
326
  if (session.header.id !== id || session.header.parentSession || currentSessionPreset(session) !== ENGINEERING_PRESET)
326
327
  workbenchError('EDP_ENGINEERING_SESSION_REQUIRED');
327
328
  // NEXT-01D-CONNECT-INJECT-FIX-01:顶层 EDP fiber 只 inject `tools`;此处必须走 optional seam
328
329
  //(`ctx.get(name,false)`),否则 Cordis 先抛 `without inject`,屏蔽下面稳定的 EDP 码。
329
- const live = optionalHost(this.ctx).sessions?.get(SessionId(id));
330
- const nodes = new Set(live?.surface?.nodes ?? []);
330
+ const live = host.sessions.get(SessionId(id));
331
+ let nodes = live?.surface?.nodes ?? [];
332
+ // A live event may precede persistence. Flush the exact live session before
333
+ // reopening the log; false means no durability listener participated.
334
+ if (nodes.some(seq => seq > (session.events.at(-1)?.seq ?? -1))) {
335
+ try {
336
+ if (!live || !host.sessions.flush || await host.sessions.flush(live) !== true)
337
+ workbenchError('EDP_DIALOGUE_EVENT_UNAVAILABLE');
338
+ session = await this.session(id);
339
+ }
340
+ catch {
341
+ workbenchError('EDP_DIALOGUE_EVENT_UNAVAILABLE');
342
+ }
343
+ if (host.sessions.get(SessionId(id)) !== live)
344
+ workbenchError('EDP_DIALOGUE_EVENT_UNAVAILABLE');
345
+ nodes = live.surface?.nodes ?? [];
346
+ // Events can arrive during the barrier or the subsequent read. Never
347
+ // fall back to an older user event when the new surface is ahead.
348
+ if (nodes.some(seq => seq > (session.events.at(-1)?.seq ?? -1)))
349
+ workbenchError('EDP_DIALOGUE_EVENT_UNAVAILABLE');
350
+ }
351
+ if (session.header.id !== id || session.header.parentSession || currentSessionPreset(session) !== ENGINEERING_PRESET)
352
+ workbenchError('EDP_ENGINEERING_SESSION_REQUIRED');
331
353
  const users = session.events.filter(e => e.type === 'user/message' && e.data.source.kind === 'user');
332
354
  if (!live && users.length)
333
355
  workbenchError('EDP_DIALOGUE_EVENT_UNAVAILABLE');
334
- const event = users.filter(e => nodes.has(e.seq)).at(-1);
356
+ const usersBySeq = new Map(users.map(event => [event.seq, event]));
357
+ const seq = nodes.slice().reverse().find(node => usersBySeq.has(node));
358
+ const event = seq === undefined ? undefined : usersBySeq.get(seq);
335
359
  if (users.length && !event)
336
360
  workbenchError('EDP_DIALOGUE_EVENT_UNAVAILABLE');
337
361
  return event ? { seq: event.seq, data: event.data } : null;
@@ -1,2 +1,2 @@
1
- name: 工程资料生成
1
+ name: 工程资料
2
2
  description: 原生对话整理材料与事实,明确生成指令后生成可编辑候选资料;不自动批准或正式放行。
@@ -17,7 +17,7 @@
17
17
  name: '@deepseek-ai/dsh-agent-preset'
18
18
  config:
19
19
  id: buildseek-engineering-documents
20
- name: 工程资料生成
20
+ name: 工程资料
21
21
  description: 原生对话整理材料与事实,明确生成指令后生成可编辑候选资料;不自动批准或正式放行。
22
22
  plugins:
23
23
  - id: engineering-workbench-agent
@@ -13,7 +13,7 @@ export function commitProjectPackages(referenceRoot:string,projectRoot:string,pr
13
13
  export function packageReferences(root:string):Promise<Record<string,ProjectResources & {history?:ProjectResources[]}>>
14
14
  export function projectPackageReferenced(root:string,kind:string,ref:any):Promise<boolean>
15
15
  export const BASIC_CATEGORIES:[string,string[]][]
16
- export class ProjectBasicFiles{constructor(root:string,projectId:string,check?:()=>Promise<unknown>);state():Promise<any>;reapExpired(state:any):Promise<any>;status(state:any):Promise<any>;start(input:any):Promise<any>;append(input:any):Promise<any>;complete(id:string):Promise<any>;cancel(id:string):Promise<void>;category(id:string,category:string):Promise<void>;open(id:string):Promise<{row:any;handle:import('node:fs/promises').FileHandle}>}
16
+ export class ProjectBasicFiles{constructor(root:string,projectId:string,check?:()=>Promise<unknown>);state():Promise<any>;reapExpired(state:any):Promise<any>;status(state:any):Promise<any>;start(input:any):Promise<any>;append(input:any):Promise<any>;complete(id:string):Promise<any>;cancel(id:string):Promise<void>;category(id:string,category:string):Promise<void>;unbind(id:string):Promise<void>;open(id:string):Promise<{row:any;handle:import('node:fs/promises').FileHandle}>}
17
17
  export function registerProjectArtifactSource(provider:(root:string)=>Promise<any[]>):()=>void
18
18
  export function projectArtifactSources(root:string,onFailure?:()=>void):Promise<any[]>
19
19
  export function projectArtifactPreview(root:string,row:any,signal:AbortSignal,scope?:{sessionId:string;bindingRevision:number}):Promise<{relativePath:string;leaseId:string}>
@@ -6,7 +6,36 @@ import {join,basename,isAbsolute,resolve} from 'node:path'
6
6
  import {createHash,randomUUID} from 'node:crypto'
7
7
  const code=c=>{throw Error('BS_PROJECT_'+c)}
8
8
  const locks=new Map()
9
- export async function projectLock(key,fn){const before=locks.get(key)??Promise.resolve();let done;const held=new Promise(r=>done=r);locks.set(key,held);await before;try{return await fn()}finally{done();if(locks.get(key)===held)locks.delete(key)}}
9
+ export async function projectLock(key, fn, signal) {
10
+ signal?.throwIfAborted()
11
+ const before = locks.get(key) ?? Promise.resolve()
12
+ let release
13
+ const held = new Promise(resolve => { release = resolve })
14
+ // A canceled waiter may settle its own slot early. Its successors still
15
+ // depend on the preceding holder, and only a settled tail clears the key.
16
+ const tail = before.then(() => held)
17
+ locks.set(key, tail)
18
+ void tail.then(() => {
19
+ if (locks.get(key) === tail) locks.delete(key)
20
+ })
21
+ try {
22
+ if (signal) {
23
+ let abort
24
+ const canceled = new Promise((_, reject) => {
25
+ abort = () => reject(signal.reason)
26
+ signal.addEventListener('abort', abort, { once: true })
27
+ })
28
+ try { await Promise.race([before, canceled]) }
29
+ finally { signal.removeEventListener('abort', abort) }
30
+ signal.throwIfAborted()
31
+ } else {
32
+ await before
33
+ }
34
+ return await fn()
35
+ } finally {
36
+ release()
37
+ }
38
+ }
10
39
  export async function safeProjectDir(root,parts){
11
40
  let p=root;const privateMetadata=parts[0]==='.dsh-engineering'
12
41
  for(const part of parts){
@@ -680,6 +709,17 @@ export class ProjectBasicFiles {
680
709
  await saveProjectSetup(this.root, state)
681
710
  }
682
711
 
712
+ async unbind(id) {
713
+ if (typeof id !== 'string' || !id) code('INPUT_INVALID')
714
+ const state = await this.state()
715
+ if (!state.files.some(file => file.id === id)) return
716
+ state.files = state.files.filter(file => file.id !== id)
717
+ for (const [uploadId, fileId] of Object.entries(state.receipts ?? {})) {
718
+ if (fileId === id) delete state.receipts[uploadId]
719
+ }
720
+ await saveProjectSetup(this.root, state, this.check)
721
+ }
722
+
683
723
  async open(id) {
684
724
  const state = await this.state(), row = state.files.find(file => file.id === id)
685
725
  if (!row || !validBasicName(row.name) || row.relativePath !== '项目基础资料/' + row.name) code('FILE_NOT_FOUND')