@worca/app 0.0.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.
Files changed (114) hide show
  1. package/README.md +403 -0
  2. package/agents/clarify.meta.json +19 -0
  3. package/agents/decomposer.meta.json +21 -0
  4. package/agents/implementer.meta.json +20 -0
  5. package/agents/manualTestsChecklist.meta.json +18 -0
  6. package/agents/manualWebUiTesting.meta.json +18 -0
  7. package/agents/planReviewer.meta.json +19 -0
  8. package/agents/planner.meta.json +20 -0
  9. package/agents/refiner.meta.json +19 -0
  10. package/agents/reviewer.meta.json +19 -0
  11. package/agents/worca-cc-clarify.md +67 -0
  12. package/agents/worca-cc-code-reviewer.md +66 -0
  13. package/agents/worca-cc-decomposer.md +84 -0
  14. package/agents/worca-cc-implementer.md +69 -0
  15. package/agents/worca-cc-manual-tests-checklist.md +63 -0
  16. package/agents/worca-cc-manual-web-ui-testing.md +64 -0
  17. package/agents/worca-cc-plan-refiner.md +69 -0
  18. package/agents/worca-cc-plan-reviewer.md +70 -0
  19. package/agents/worca-cc-planner.md +70 -0
  20. package/agents/worca-cc-workspace-reviewer.md +56 -0
  21. package/agents/worca-cc-workspace-scanner.md +55 -0
  22. package/agents/workspaceReviewer.meta.json +20 -0
  23. package/agents/workspaceScanner.meta.json +18 -0
  24. package/package.json +61 -0
  25. package/scripts/install.mjs +209 -0
  26. package/skills/worca/SKILL.md +66 -0
  27. package/src/cli/worca-cc.mjs +1520 -0
  28. package/src/core/agent-gen.mjs +206 -0
  29. package/src/core/agent-registry.mjs +417 -0
  30. package/src/core/agent-store.mjs +143 -0
  31. package/src/core/artifacts.mjs +2019 -0
  32. package/src/core/channels.mjs +302 -0
  33. package/src/core/chat/allowlist.mjs +27 -0
  34. package/src/core/chat/channel-host.mjs +562 -0
  35. package/src/core/chat/channel-protocol.mjs +117 -0
  36. package/src/core/chat/channel-worker-child.mjs +211 -0
  37. package/src/core/chat/chat-context.mjs +66 -0
  38. package/src/core/chat/command-router.mjs +343 -0
  39. package/src/core/chat/notifier.mjs +120 -0
  40. package/src/core/chat/parser.mjs +30 -0
  41. package/src/core/chat/rate-limiter.mjs +133 -0
  42. package/src/core/chat/redact.mjs +27 -0
  43. package/src/core/chat/renderers.mjs +136 -0
  44. package/src/core/claude-runner.mjs +1356 -0
  45. package/src/core/config.mjs +882 -0
  46. package/src/core/cost-budget.mjs +103 -0
  47. package/src/core/db.mjs +864 -0
  48. package/src/core/fanout.mjs +48 -0
  49. package/src/core/folder-dialog.mjs +138 -0
  50. package/src/core/fs-browse.mjs +49 -0
  51. package/src/core/git-info.mjs +200 -0
  52. package/src/core/guardrail-store.mjs +204 -0
  53. package/src/core/guardrails.mjs +302 -0
  54. package/src/core/marketplaces.mjs +267 -0
  55. package/src/core/migrate-fs-to-db.mjs +612 -0
  56. package/src/core/model-env.mjs +74 -0
  57. package/src/core/orchestrator.mjs +4279 -0
  58. package/src/core/overview-agent.mjs +124 -0
  59. package/src/core/phases.mjs +1279 -0
  60. package/src/core/pipeline-delete.mjs +428 -0
  61. package/src/core/plugin-api.mjs +13 -0
  62. package/src/core/plugin-config.mjs +100 -0
  63. package/src/core/plugin-inventory.mjs +50 -0
  64. package/src/core/plugin-manifest.mjs +447 -0
  65. package/src/core/plugin-models.mjs +130 -0
  66. package/src/core/plugin-repo.mjs +303 -0
  67. package/src/core/plugin-shim-child.mjs +76 -0
  68. package/src/core/plugin-shim.mjs +197 -0
  69. package/src/core/plugin-store.mjs +485 -0
  70. package/src/core/plugin-workflows.mjs +179 -0
  71. package/src/core/plugins-lock.mjs +49 -0
  72. package/src/core/preflight-node.mjs +122 -0
  73. package/src/core/preflight.mjs +341 -0
  74. package/src/core/projects.mjs +157 -0
  75. package/src/core/protocol.mjs +257 -0
  76. package/src/core/recoverable-error.mjs +51 -0
  77. package/src/core/results.mjs +188 -0
  78. package/src/core/run-context.mjs +1375 -0
  79. package/src/core/run-log.mjs +64 -0
  80. package/src/core/run-manifest.mjs +317 -0
  81. package/src/core/runners.mjs +167 -0
  82. package/src/core/settings.mjs +682 -0
  83. package/src/core/skills.mjs +210 -0
  84. package/src/core/sources.mjs +232 -0
  85. package/src/core/stats.mjs +182 -0
  86. package/src/core/store.mjs +67 -0
  87. package/src/core/title.mjs +64 -0
  88. package/src/core/workflow-validator.mjs +185 -0
  89. package/src/core/workflows.mjs +568 -0
  90. package/src/core/workspace-scan.mjs +420 -0
  91. package/src/core/workspaces.mjs +353 -0
  92. package/src/core/worktree.mjs +708 -0
  93. package/src/feature.mjs +9 -0
  94. package/ui/public/app.js +10647 -0
  95. package/ui/public/assets/worca-favicon.png +0 -0
  96. package/ui/public/assets/worca-logo.png +0 -0
  97. package/ui/public/chat-settings-view.mjs +89 -0
  98. package/ui/public/composer-core.mjs +211 -0
  99. package/ui/public/fonts/jetbrains-mono-latin-400-normal.woff2 +0 -0
  100. package/ui/public/fonts/poppins-latin-400-normal.woff2 +0 -0
  101. package/ui/public/fonts/poppins-latin-500-normal.woff2 +0 -0
  102. package/ui/public/fonts/poppins-latin-600-normal.woff2 +0 -0
  103. package/ui/public/fonts/poppins-latin-700-normal.woff2 +0 -0
  104. package/ui/public/guardrails-view.mjs +244 -0
  105. package/ui/public/index.html +1145 -0
  106. package/ui/public/log-filter.mjs +81 -0
  107. package/ui/public/log-line.mjs +86 -0
  108. package/ui/public/models-view.mjs +433 -0
  109. package/ui/public/plugins-view.mjs +430 -0
  110. package/ui/public/results-view.mjs +121 -0
  111. package/ui/public/source-pane.mjs +156 -0
  112. package/ui/public/stats-view.mjs +523 -0
  113. package/ui/public/style.css +1557 -0
  114. package/ui/server.mjs +3573 -0
@@ -0,0 +1,124 @@
1
+ // src/core/overview-agent.mjs
2
+ // Layer 2 (on-demand) overview agent: reads the persisted Layer-1 artifacts
3
+ // (diff patch + results + review issues) and runs a single-shot Claude agent that
4
+ // returns a narrative + a fresh diff read. Idempotent — caches overview.json and
5
+ // returns it without re-running unless force. Recorded in sub_agents for cost parity.
6
+ import { readFile, writeFile } from 'node:fs/promises';
7
+ import { join } from 'node:path';
8
+ import { runClaude } from './claude-runner.mjs';
9
+ import { resolveModelEnv } from './config.mjs';
10
+ import { safeParseJson } from './protocol.mjs';
11
+ import {
12
+ lookupPipelineRow, runDirForRow, upsertSubAgent, readPipelineExtras,
13
+ } from './artifacts.mjs';
14
+ import { RESULTS_FILE, DIFF_PATCH_FILE, OVERVIEW_FILE } from './results.mjs';
15
+
16
+ const PATCH_CAP = 60_000; // chars; above this, send hunk headers only
17
+
18
+ export const OVERVIEW_SYSTEM_PROMPT =
19
+ 'You summarize a finished code-change pipeline for a busy engineer. ' +
20
+ 'Be precise and terse. Only report diff findings that are NOT already in the ' +
21
+ 'provided review issues. Output ONLY the requested JSON object, nothing else.';
22
+
23
+ export function buildOverviewPrompt({ patch, results, reviews }) {
24
+ const known = (reviews || []).flatMap((r) => (r.issues || []).map(
25
+ (i) => `- [${i.severity}] ${i.title} (${i.location})`)).join('\n') || '(none)';
26
+ let body = patch || '';
27
+ let truncated = false;
28
+ if (body.length > PATCH_CAP) {
29
+ body = body.split('\n').filter((l) =>
30
+ l.startsWith('diff --git') || l.startsWith('@@') ||
31
+ l.startsWith('+++') || l.startsWith('---')).join('\n');
32
+ truncated = true;
33
+ }
34
+ return [
35
+ 'Summarize this pipeline run.',
36
+ '',
37
+ `## File summary\n${JSON.stringify(results?.summary || {}, null, 2)}`,
38
+ '',
39
+ `## Already-flagged review issues (do NOT repeat these)\n${known}`,
40
+ '',
41
+ `## Diff ${truncated ? '(TRUNCATED to hunk headers — set diffCheckTruncated:true)' : ''}\n\`\`\`diff\n${body}\n\`\`\``,
42
+ '',
43
+ '## Output contract',
44
+ 'Return ONLY this JSON object:',
45
+ '{',
46
+ ' "narrative": "2-4 sentences: what this run did and why it matters",',
47
+ ' "diffFindings": [ { "severity": "warn|note", "file": "path", "line": 0, "title": "...", "detail": "...", "newVsReview": true } ],',
48
+ ` "diffCheckTruncated": ${truncated}`,
49
+ '}',
50
+ ].join('\n');
51
+ }
52
+
53
+ const FINDING_SEV = new Set(['warn', 'note']);
54
+
55
+ export function normalizeOverview(parsed) {
56
+ if (!parsed || typeof parsed !== 'object') return { narrative: '', diffFindings: [], diffCheckTruncated: false };
57
+ const list = Array.isArray(parsed.diffFindings) ? parsed.diffFindings : [];
58
+ const diffFindings = [];
59
+ for (const f of list) {
60
+ if (!f || typeof f !== 'object' || !f.title) continue;
61
+ diffFindings.push({
62
+ severity: FINDING_SEV.has(f.severity) ? f.severity : 'note',
63
+ file: typeof f.file === 'string' ? f.file : '',
64
+ line: Number.isFinite(Number(f.line)) ? Number(f.line) : null,
65
+ title: String(f.title).trim(),
66
+ detail: typeof f.detail === 'string' ? f.detail.trim() : '',
67
+ newVsReview: f.newVsReview === true,
68
+ });
69
+ }
70
+ return {
71
+ narrative: typeof parsed.narrative === 'string' ? parsed.narrative.trim() : '',
72
+ diffFindings,
73
+ diffCheckTruncated: parsed.diffCheckTruncated === true,
74
+ };
75
+ }
76
+
77
+ /**
78
+ * On-demand: read persisted artifacts, run a one-shot agent, persist + return
79
+ * the overview. Idempotent — returns the cached overview.json unless force.
80
+ * `runClaudeImpl` is injectable for tests.
81
+ */
82
+ export async function generateOverview(key, id, { model, signal, force = false, runClaudeImpl = runClaude } = {}) {
83
+ const row = lookupPipelineRow(key, id);
84
+ if (!row) throw new Error('pipeline not found');
85
+ const dir = await runDirForRow(row);
86
+
87
+ if (!force) {
88
+ try { return JSON.parse(await readFile(join(dir, OVERVIEW_FILE), 'utf8')); } catch { /* none cached */ }
89
+ }
90
+
91
+ const patch = await readFile(join(dir, DIFF_PATCH_FILE), 'utf8').catch(() => '');
92
+ const results = await readFile(join(dir, RESULTS_FILE), 'utf8').then(JSON.parse).catch(() => null);
93
+ const reviews = readPipelineExtras(row.id).reviews || [];
94
+
95
+ const prompt = buildOverviewPrompt({ patch, results, reviews });
96
+ let costUsd = null;
97
+ const startedAt = new Date().toISOString();
98
+ const { text } = await runClaudeImpl({
99
+ cwd: dir,
100
+ systemPrompt: OVERVIEW_SYSTEM_PROMPT,
101
+ prompt,
102
+ allowedTools: [], // pure reasoning over the prompt; no tools needed
103
+ model,
104
+ modelEnv: resolveModelEnv(model), // catalog routing env travels with the id (design §4.8)
105
+ signal,
106
+ onEvent: (e) => { if (e.costUsd != null) costUsd = e.costUsd; },
107
+ });
108
+
109
+ const overview = normalizeOverview(safeParseJson(text));
110
+ await writeFile(join(dir, OVERVIEW_FILE), JSON.stringify(overview, null, 2));
111
+
112
+ // Record as a sub-agent for cost telemetry parity with pipeline nodes.
113
+ upsertSubAgent(row.id, {
114
+ id: `overview-${id}`,
115
+ label: 'overview',
116
+ status: 'finished',
117
+ startedAt,
118
+ finishedAt: new Date().toISOString(),
119
+ costUsd,
120
+ subagentType: 'overview',
121
+ });
122
+
123
+ return overview;
124
+ }