@suifei/dsh-ai-team 0.0.0-stage → 0.3.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.
Files changed (84) hide show
  1. package/CHANGELOG.md +98 -0
  2. package/LICENSE +21 -0
  3. package/README.md +38 -2
  4. package/client.js +2901 -0
  5. package/cordis.patch.yml +31 -0
  6. package/icon.svg +27 -0
  7. package/index.js +893 -0
  8. package/lib/domain/errors.js +36 -0
  9. package/lib/domain/ids.js +26 -0
  10. package/lib/domain/inbox.js +87 -0
  11. package/lib/domain/member-config.js +168 -0
  12. package/lib/domain/member-profile.js +53 -0
  13. package/lib/domain/policy.js +102 -0
  14. package/lib/domain/task.js +309 -0
  15. package/lib/domain/thread.js +54 -0
  16. package/lib/host/fault-adapter.js +50 -0
  17. package/lib/host/member-tools.js +225 -0
  18. package/lib/host/permission-guard.js +28 -0
  19. package/lib/host/project-registry.js +68 -0
  20. package/lib/host/project-runtime.js +73 -0
  21. package/lib/host/service.js +810 -0
  22. package/lib/host/views.js +213 -0
  23. package/lib/host/waker.js +177 -0
  24. package/lib/ledger/checkpoint.js +395 -0
  25. package/lib/ledger/events.js +398 -0
  26. package/lib/ledger/fold.js +991 -0
  27. package/lib/ledger/writer.js +983 -0
  28. package/lib/runtime/failure-policy.js +113 -0
  29. package/lib/runtime/host-agent.js +101 -0
  30. package/lib/runtime/member-runtime.js +286 -0
  31. package/lib/runtime/skill-catalog.js +27 -0
  32. package/lib/runtime/skill-loader.js +26 -0
  33. package/lib/runtime/skill-provider.js +121 -0
  34. package/lib/vendor/skillopt/LICENSE +21 -0
  35. package/lib/vendor/skillopt/requirements.txt +31 -0
  36. package/lib/vendor/skillopt/scripts/sleep.py +119 -0
  37. package/lib/vendor/skillopt/skillopt_sleep/__init__.py +20 -0
  38. package/lib/vendor/skillopt/skillopt_sleep/__main__.py +942 -0
  39. package/lib/vendor/skillopt/skillopt_sleep/adapters/__init__.py +1 -0
  40. package/lib/vendor/skillopt/skillopt_sleep/adapters/superpowers.py +1379 -0
  41. package/lib/vendor/skillopt/skillopt_sleep/backend.py +2844 -0
  42. package/lib/vendor/skillopt/skillopt_sleep/budget.py +75 -0
  43. package/lib/vendor/skillopt/skillopt_sleep/config.py +257 -0
  44. package/lib/vendor/skillopt/skillopt_sleep/consolidate.py +558 -0
  45. package/lib/vendor/skillopt/skillopt_sleep/cycle.py +1270 -0
  46. package/lib/vendor/skillopt/skillopt_sleep/dream.py +173 -0
  47. package/lib/vendor/skillopt/skillopt_sleep/evalkit.py +718 -0
  48. package/lib/vendor/skillopt/skillopt_sleep/evidence.py +143 -0
  49. package/lib/vendor/skillopt/skillopt_sleep/experiments/__init__.py +1 -0
  50. package/lib/vendor/skillopt/skillopt_sleep/experiments/gbrain_bench.py +119 -0
  51. package/lib/vendor/skillopt/skillopt_sleep/experiments/personas.py +86 -0
  52. package/lib/vendor/skillopt/skillopt_sleep/experiments/report.py +132 -0
  53. package/lib/vendor/skillopt/skillopt_sleep/experiments/run_experiment.py +178 -0
  54. package/lib/vendor/skillopt/skillopt_sleep/experiments/run_gbrain.py +209 -0
  55. package/lib/vendor/skillopt/skillopt_sleep/experiments/run_transfer.py +155 -0
  56. package/lib/vendor/skillopt/skillopt_sleep/experiments/sweep.py +164 -0
  57. package/lib/vendor/skillopt/skillopt_sleep/gate.py +50 -0
  58. package/lib/vendor/skillopt/skillopt_sleep/handoff_backend.py +173 -0
  59. package/lib/vendor/skillopt/skillopt_sleep/harvest.py +691 -0
  60. package/lib/vendor/skillopt/skillopt_sleep/harvest_codex.py +260 -0
  61. package/lib/vendor/skillopt/skillopt_sleep/harvest_copilot.py +443 -0
  62. package/lib/vendor/skillopt/skillopt_sleep/harvest_copilot_cli.py +244 -0
  63. package/lib/vendor/skillopt/skillopt_sleep/harvest_cursor.py +316 -0
  64. package/lib/vendor/skillopt/skillopt_sleep/harvest_opencode.py +364 -0
  65. package/lib/vendor/skillopt/skillopt_sleep/harvest_pi.py +311 -0
  66. package/lib/vendor/skillopt/skillopt_sleep/harvest_sources.py +135 -0
  67. package/lib/vendor/skillopt/skillopt_sleep/judges.py +344 -0
  68. package/lib/vendor/skillopt/skillopt_sleep/llm_miner.py +187 -0
  69. package/lib/vendor/skillopt/skillopt_sleep/memory.py +166 -0
  70. package/lib/vendor/skillopt/skillopt_sleep/mine.py +427 -0
  71. package/lib/vendor/skillopt/skillopt_sleep/multi_skill.py +190 -0
  72. package/lib/vendor/skillopt/skillopt_sleep/prompts.py +250 -0
  73. package/lib/vendor/skillopt/skillopt_sleep/replay.py +211 -0
  74. package/lib/vendor/skillopt/skillopt_sleep/rollout.py +184 -0
  75. package/lib/vendor/skillopt/skillopt_sleep/scheduler.py +286 -0
  76. package/lib/vendor/skillopt/skillopt_sleep/skill_resolver.py +244 -0
  77. package/lib/vendor/skillopt/skillopt_sleep/slow_update.py +141 -0
  78. package/lib/vendor/skillopt/skillopt_sleep/staging.py +3285 -0
  79. package/lib/vendor/skillopt/skillopt_sleep/state.py +283 -0
  80. package/lib/vendor/skillopt/skillopt_sleep/tasks_file.py +100 -0
  81. package/lib/vendor/skillopt/skillopt_sleep/types.py +227 -0
  82. package/lib/vendor/skillopt/src/index.js +394 -0
  83. package/package.json +62 -4
  84. package/skills/skillopt-sleep/SKILL.md +121 -0
@@ -0,0 +1,68 @@
1
+ /** Lightweight Project index. The ledger remains the source of truth for Project state. */
2
+ import { existsSync, mkdirSync, readFileSync, renameSync, writeFileSync } from 'node:fs';
3
+ import { join } from 'node:path';
4
+ import { DEFAULT_PROJECT_ID } from './project-runtime.js';
5
+
6
+ export class ProjectRegistry {
7
+ constructor({ rootDir, projects, activeProjectId }) {
8
+ this.rootDir = rootDir;
9
+ this.projects = Array.isArray(projects) ? projects : [];
10
+ this.activeProjectId = activeProjectId ?? DEFAULT_PROJECT_ID;
11
+ }
12
+
13
+ static load(rootDir) {
14
+ mkdirSync(rootDir, { recursive: true });
15
+ const file = join(rootDir, 'projects.json');
16
+ let parsed;
17
+ try {
18
+ parsed = existsSync(file) ? JSON.parse(readFileSync(file, 'utf8')) : null;
19
+ } catch {
20
+ parsed = null;
21
+ }
22
+ const projects = Array.isArray(parsed?.projects) && parsed.projects.length > 0
23
+ ? parsed.projects.filter((project) => typeof project?.id === 'string' && project.id !== '')
24
+ : [{ id: DEFAULT_PROJECT_ID, name: '我的项目', createdAt: 0 }];
25
+ if (!projects.some((project) => project.id === DEFAULT_PROJECT_ID)) {
26
+ projects.unshift({ id: DEFAULT_PROJECT_ID, name: '我的项目', createdAt: 0 });
27
+ }
28
+ const active = projects.some((project) => project.id === parsed?.activeProjectId)
29
+ ? parsed.activeProjectId
30
+ : DEFAULT_PROJECT_ID;
31
+ const registry = new ProjectRegistry({ rootDir, projects, activeProjectId: active });
32
+ if (!existsSync(file)) registry.save();
33
+ return registry;
34
+ }
35
+
36
+ get activeProject() {
37
+ return this.projects.find((project) => project.id === this.activeProjectId) ?? this.projects[0];
38
+ }
39
+
40
+ list() {
41
+ return this.projects.map((project) => ({ ...project, active: project.id === this.activeProjectId }));
42
+ }
43
+
44
+ add({ id, name, createdAt, goal }) {
45
+ if (typeof id !== 'string' || id === '') throw new Error('project id is required');
46
+ if (!this.projects.some((project) => project.id === id)) {
47
+ this.projects.push({ id, name: name ?? id, goal: goal ?? '', createdAt: createdAt ?? Date.now() });
48
+ this.save();
49
+ }
50
+ return this.projects.find((project) => project.id === id);
51
+ }
52
+
53
+ setActive(id) {
54
+ if (!this.projects.some((project) => project.id === id)) throw new Error(`unknown project: ${id}`);
55
+ this.activeProjectId = id;
56
+ this.save();
57
+ }
58
+
59
+ save() {
60
+ const file = join(this.rootDir, 'projects.json');
61
+ const temp = `${file}.tmp`;
62
+ writeFileSync(temp, JSON.stringify({
63
+ activeProjectId: this.activeProjectId,
64
+ projects: this.projects,
65
+ }, null, 2), 'utf8');
66
+ renameSync(temp, file);
67
+ }
68
+ }
@@ -0,0 +1,73 @@
1
+ /**
2
+ * One Project runtime: its own ledger, TeamService and optional SSE/waker hooks.
3
+ *
4
+ * A Project is the isolation boundary required by the ledger writer: every
5
+ * ledger event must carry exactly this Project's id. ProjectRuntime wraps the
6
+ * default Project first, so multiple runtimes can be mounted later without
7
+ * changing the single-project behaviour.
8
+ */
9
+
10
+ import { mkdirSync } from 'node:fs';
11
+ import { join } from 'node:path';
12
+ import { openLedger } from '../ledger/writer.js';
13
+ import { TeamService } from './service.js';
14
+
15
+ export const DEFAULT_PROJECT_ID = 'prj_main';
16
+ export const HUMAN_ID = 'mem_human';
17
+
18
+ export class ProjectRuntime {
19
+ constructor({ id, rootDir, dir, ledger, service }) {
20
+ this.id = id;
21
+ this.rootDir = rootDir;
22
+ this.dir = dir;
23
+ this.ledger = ledger;
24
+ this.service = service;
25
+ }
26
+
27
+ static async open({ rootDir, projectId = DEFAULT_PROJECT_ID, now = undefined, seed = true, projectName = '我的项目', projectGoal = '把事交给团队' }) {
28
+ const dir = join(rootDir, 'projects', projectId);
29
+ mkdirSync(dir, { recursive: true });
30
+ const ledger = openLedger({ dir, projectId, fsync: true });
31
+ const service = new TeamService({ ledger, now });
32
+ const runtime = new ProjectRuntime({ id: projectId, rootDir, dir, ledger, service });
33
+
34
+ const repairs = ledger.opened?.repairs ?? (ledger.opened?.repair ? [ledger.opened.repair] : []);
35
+ if (repairs.length > 0) {
36
+ await ledger.append({
37
+ type: 'ledger/repaired',
38
+ payload: { repairs },
39
+ actor: { kind: 'system' },
40
+ projectId,
41
+ });
42
+ }
43
+
44
+ if (seed) {
45
+ const state = service.state;
46
+ if (state.members?.[HUMAN_ID] === undefined) {
47
+ await service.dispatch({
48
+ type: 'member.add',
49
+ actor: { kind: 'human', memberId: HUMAN_ID },
50
+ projectId,
51
+ payload: { id: HUMAN_ID, name: '你', kind: 'human', role: 'Human' },
52
+ });
53
+ }
54
+ if (state.projects?.[projectId] === undefined) {
55
+ await service.dispatch({
56
+ type: 'project.create',
57
+ actor: { kind: 'human', memberId: HUMAN_ID },
58
+ projectId,
59
+ payload: { id: projectId, name: projectName, goal: projectGoal },
60
+ });
61
+ }
62
+ }
63
+ return runtime;
64
+ }
65
+
66
+ close() {
67
+ try {
68
+ this.ledger?.close?.();
69
+ } catch {
70
+ /* already closed */
71
+ }
72
+ }
73
+ }