dsh-harness-kit 0.0.0-stage → 0.1.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.
Files changed (87) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +321 -2
  3. package/README.zh-CN.md +278 -0
  4. package/client.js +1272 -0
  5. package/cordis.patch.yml +4 -0
  6. package/docs/DETAIL.en.md +97 -0
  7. package/docs/DETAIL.md +73 -0
  8. package/docs/assets/ui-new-task.png +0 -0
  9. package/docs/assets/ui-onboarding.png +0 -0
  10. package/docs/assets/ui-war-room.png +0 -0
  11. package/icon.svg +7 -0
  12. package/index.js +49 -0
  13. package/kernel/advance.js +96 -0
  14. package/kernel/bindings.js +24 -0
  15. package/kernel/commands.js +927 -0
  16. package/kernel/env.js +64 -0
  17. package/kernel/exec.js +41 -0
  18. package/kernel/flows.js +89 -0
  19. package/kernel/guards.js +79 -0
  20. package/kernel/miniyaml.js +133 -0
  21. package/kernel/models.js +104 -0
  22. package/kernel/panel.js +1103 -0
  23. package/kernel/paths.js +53 -0
  24. package/kernel/roles.js +67 -0
  25. package/kernel/setup.js +644 -0
  26. package/kernel/state.js +59 -0
  27. package/kernel/steer.js +27 -0
  28. package/kernel/sync.js +140 -0
  29. package/kernel/te.js +122 -0
  30. package/kernel/worktree.js +868 -0
  31. package/locale/en.json +14 -0
  32. package/locale/zh.json +14 -0
  33. package/package.json +63 -4
  34. package/packs/ai-coding/agents/business-analyst.md +90 -0
  35. package/packs/ai-coding/agents/code-reviewer.md +156 -0
  36. package/packs/ai-coding/agents/developer.md +147 -0
  37. package/packs/ai-coding/agents/project-manager.md +190 -0
  38. package/packs/ai-coding/agents/readiness-reviewer.md +123 -0
  39. package/packs/ai-coding/agents/solution-architect.md +122 -0
  40. package/packs/ai-coding/agents/test-engineer.md +230 -0
  41. package/packs/ai-coding/assets/scripts/check_codegraph.py +215 -0
  42. package/packs/ai-coding/assets/scripts/codebase_guide_init.py +330 -0
  43. package/packs/ai-coding/assets/scripts/env_auto.py +612 -0
  44. package/packs/ai-coding/assets/scripts/harness.py +38 -0
  45. package/packs/ai-coding/assets/scripts/harness_init.py +193 -0
  46. package/packs/ai-coding/assets/scripts/lib.py +1011 -0
  47. package/packs/ai-coding/assets/scripts/run_field.py +295 -0
  48. package/packs/ai-coding/assets/scripts/spec_lint.py +247 -0
  49. package/packs/ai-coding/assets/scripts/update_board.py +524 -0
  50. package/packs/ai-coding/assets/scripts/verify.py +184 -0
  51. package/packs/ai-coding/assets/templates/dotnet/dotnet-multimodule/CODE_STANDARDS.tmpl +44 -0
  52. package/packs/ai-coding/assets/templates/dotnet/dotnet-multimodule/app-CLAUDE.tmpl +34 -0
  53. package/packs/ai-coding/assets/templates/dotnet/dotnet-multimodule/build.tmpl +8 -0
  54. package/packs/ai-coding/assets/templates/dotnet/dotnet-multimodule/module-CLAUDE.tmpl +42 -0
  55. package/packs/ai-coding/assets/templates/dotnet/dotnet-multimodule/root-CLAUDE.tmpl +41 -0
  56. package/packs/ai-coding/assets/templates/java/maven/CODE_STANDARDS.tmpl +44 -0
  57. package/packs/ai-coding/assets/templates/java/maven/build.tmpl +9 -0
  58. package/packs/ai-coding/assets/templates/java/maven/root-CLAUDE.tmpl +38 -0
  59. package/packs/ai-coding/assets/templates/java/maven-multimodule/CODE_STANDARDS.tmpl +44 -0
  60. package/packs/ai-coding/assets/templates/java/maven-multimodule/build.tmpl +9 -0
  61. package/packs/ai-coding/assets/templates/java/maven-multimodule/module-CLAUDE.tmpl +40 -0
  62. package/packs/ai-coding/assets/templates/java/maven-multimodule/root-CLAUDE.tmpl +38 -0
  63. package/packs/ai-coding/assets/templates/javascript/mobile-app/CODE_STANDARDS.tmpl +51 -0
  64. package/packs/ai-coding/assets/templates/javascript/mobile-app/build.tmpl +8 -0
  65. package/packs/ai-coding/assets/templates/javascript/mobile-app/root-CLAUDE.tmpl +36 -0
  66. package/packs/ai-coding/assets/templates/javascript/uniapp/CODE_STANDARDS.tmpl +69 -0
  67. package/packs/ai-coding/assets/templates/javascript/uniapp/build.tmpl +8 -0
  68. package/packs/ai-coding/assets/templates/javascript/uniapp/root-CLAUDE.tmpl +56 -0
  69. package/packs/ai-coding/assets/templates/javascript/vue-multimodule/CODE_STANDARDS.tmpl +51 -0
  70. package/packs/ai-coding/assets/templates/javascript/vue-multimodule/app-CLAUDE.tmpl +36 -0
  71. package/packs/ai-coding/assets/templates/javascript/vue-multimodule/build.tmpl +8 -0
  72. package/packs/ai-coding/assets/templates/javascript/vue-multimodule/root-CLAUDE.tmpl +34 -0
  73. package/packs/ai-coding/flows/_router.yml +14 -0
  74. package/packs/ai-coding/flows/bugfix.yml +37 -0
  75. package/packs/ai-coding/flows/fix.yml +44 -0
  76. package/packs/ai-coding/flows/init.yml +83 -0
  77. package/packs/ai-coding/flows/new.yml +29 -0
  78. package/packs/ai-coding/flows/quick.yml +40 -0
  79. package/packs/ai-coding/flows/refactor.yml +50 -0
  80. package/packs/ai-coding/flows/standard.yml +49 -0
  81. package/packs/ai-coding/rules/code-standards.md +30 -0
  82. package/packs/ai-coding/rules/core.md +83 -0
  83. package/packs/ai-coding/templates/bugfix.md +29 -0
  84. package/packs/ai-coding/templates/memory-entry.md +46 -0
  85. package/packs/ai-coding/templates/proposal.md +47 -0
  86. package/packs/ai-coding/templates/spec-template.md +34 -0
  87. package/screenshots.json +5 -0
@@ -0,0 +1,53 @@
1
+ // Workspace/kit.json path resolution and manifest IO.
2
+ // The workspace root is read per command from the receiving agent's session
3
+ // header (`agent.session.header.cwd`), never from process.cwd().
4
+ import fs from 'node:fs';
5
+ import path from 'node:path';
6
+ import { fileURLToPath } from 'node:url';
7
+
8
+ export const PACK_ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
9
+ export const DEFAULT_PACK = 'ai-coding';
10
+
11
+ export function packDir(kit) {
12
+ return path.join(PACK_ROOT, 'packs', kit?.pack ?? DEFAULT_PACK);
13
+ }
14
+
15
+ export function wsRoot(agent) {
16
+ const cwd = agent?.session?.header?.cwd;
17
+ if (typeof cwd !== 'string' || cwd === '') throw new Error('无法确定会话工作区路径(session cwd 缺失)');
18
+ return cwd;
19
+ }
20
+
21
+ export function harnessDir(ws) {
22
+ return path.join(ws, '.harness');
23
+ }
24
+
25
+ export function kitPath(ws) {
26
+ return path.join(harnessDir(ws), 'kit.json');
27
+ }
28
+
29
+ export function readKit(ws) {
30
+ const p = kitPath(ws);
31
+ if (!fs.existsSync(p)) return null;
32
+ try {
33
+ return JSON.parse(fs.readFileSync(p, 'utf8'));
34
+ } catch (cause) {
35
+ throw new Error(`kit.json 解析失败:${cause.message}`);
36
+ }
37
+ }
38
+
39
+ export function writeKit(ws, kit) {
40
+ const p = kitPath(ws);
41
+ fs.mkdirSync(path.dirname(p), { recursive: true });
42
+ fs.writeFileSync(p, JSON.stringify(kit, null, 2) + '\n', 'utf8');
43
+ }
44
+
45
+ export function defaultKit() {
46
+ return { version: 1, pack: DEFAULT_PACK, hosts: ['dsh'], sources: [], models: {} };
47
+ }
48
+
49
+ /** kit.json sources plus the always-protected e2e/ zone. */
50
+ export function protectedSourcePaths(kit) {
51
+ const fromKit = (kit?.sources ?? []).map((s) => s.path).filter(Boolean);
52
+ return [...fromKit, 'e2e/'];
53
+ }
@@ -0,0 +1,67 @@
1
+ // Role registry: resolve role definitions with workspace override precedence
2
+ // (.harness/agents/<role>.md beats the pack copy). M1 embeds resolved role
3
+ // bodies into Lead orchestration prompts; preset registration arrives in M2.
4
+ import fs from 'node:fs';
5
+ import path from 'node:path';
6
+ import { packDir, harnessDir } from './paths.js';
7
+ import { parseYaml } from './miniyaml.js';
8
+
9
+ const FRONTMATTER = /^---\r?\n([\s\S]*?)\r?\n---\r?\n?/;
10
+
11
+ export function parseRoleFile(text, fallbackRole) {
12
+ const m = FRONTMATTER.exec(text);
13
+ if (!m) return { meta: { role: fallbackRole }, body: text.trim() };
14
+ let meta;
15
+ try {
16
+ meta = parseYaml(m[1]) ?? {};
17
+ } catch (cause) {
18
+ throw new Error(`角色文件 frontmatter 解析失败:${cause.message}`);
19
+ }
20
+ return { meta: { role: fallbackRole, ...meta }, body: text.slice(m[0].length).trim() };
21
+ }
22
+
23
+ function roleCandidates(ws, kit, role) {
24
+ return [
25
+ { file: path.join(harnessDir(ws), 'agents', `${role}.md`), origin: 'workspace' },
26
+ { file: path.join(packDir(kit), 'agents', `${role}.md`), origin: 'pack' },
27
+ ];
28
+ }
29
+
30
+ /** Resolve one role; returns { role, meta, body, file, origin } or null. */
31
+ export function resolveRole(ws, kit, role) {
32
+ for (const c of roleCandidates(ws, kit, role)) {
33
+ if (fs.existsSync(c.file)) {
34
+ const { meta, body } = parseRoleFile(fs.readFileSync(c.file, 'utf8'), role);
35
+ return { role, meta, body, file: c.file, origin: c.origin };
36
+ }
37
+ }
38
+ return null;
39
+ }
40
+
41
+ /** List roles from both layers; workspace entries shadow pack entries. */
42
+ export function listRoles(ws, kit) {
43
+ const seen = new Map();
44
+ const scan = (dir, origin) => {
45
+ if (!fs.existsSync(dir)) return;
46
+ for (const name of fs.readdirSync(dir)) {
47
+ if (!name.endsWith('.md')) continue;
48
+ const role = name.slice(0, -3);
49
+ if (seen.has(role)) continue; // workspace scanned first wins
50
+ try {
51
+ const { meta } = parseRoleFile(fs.readFileSync(path.join(dir, name), 'utf8'), role);
52
+ seen.set(role, { role, meta, origin, file: path.join(dir, name) });
53
+ } catch (cause) {
54
+ seen.set(role, { role, meta: { role }, origin, file: path.join(dir, name), error: cause.message });
55
+ }
56
+ }
57
+ };
58
+ scan(path.join(harnessDir(ws), 'agents'), 'workspace');
59
+ scan(path.join(packDir(kit), 'agents'), 'pack');
60
+ return [...seen.values()];
61
+ }
62
+
63
+ /** Read the pack's domain-neutral rules document, when present. */
64
+ export function readCoreRules(kit) {
65
+ const file = path.join(packDir(kit), 'rules', 'core.md');
66
+ return fs.existsSync(file) ? fs.readFileSync(file, 'utf8').trim() : '';
67
+ }