codehere 0.6.2 → 0.7.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 (73) hide show
  1. package/README.md +5 -3
  2. package/dist/application/use-cases/domain-trust.js +110 -0
  3. package/dist/application/use-cases/generate-final-report.js +87 -168
  4. package/dist/application/use-cases/generate-narration.js +11 -0
  5. package/dist/application/use-cases/generate-thread-title.js +4 -0
  6. package/dist/application/use-cases/thread-export.js +155 -0
  7. package/dist/application/use-cases/verify-claim.js +274 -0
  8. package/dist/application/use-cases/write-pass.js +277 -0
  9. package/dist/index.js +211 -16
  10. package/dist/infrastructure/completion/bash-completion.js +2 -2
  11. package/dist/infrastructure/config/config-manager.js +1 -1
  12. package/dist/infrastructure/context/adapters/drawio-source.js +157 -0
  13. package/dist/infrastructure/context/adapters/figma-source.js +163 -0
  14. package/dist/infrastructure/context/adapters/github-issue-source.js +159 -0
  15. package/dist/infrastructure/context/adapters/linear-source.js +190 -0
  16. package/dist/infrastructure/context/context-resolver.js +144 -0
  17. package/dist/infrastructure/context/context-source.js +114 -0
  18. package/dist/infrastructure/context/oauth-flow.js +207 -0
  19. package/dist/infrastructure/context/oauth-store.js +119 -0
  20. package/dist/infrastructure/context/registry-bootstrap.js +99 -0
  21. package/dist/infrastructure/context/write-pass-resolver.js +106 -0
  22. package/dist/infrastructure/hooks/claude-sdk-hook.js +73 -57
  23. package/dist/infrastructure/hooks/session-analyzer.js +65 -8
  24. package/dist/infrastructure/observability/execution-tracer.js +0 -5
  25. package/dist/infrastructure/orchestration/aider-adapter.js +49 -18
  26. package/dist/infrastructure/orchestration/artifacts-extractor.js +39 -5
  27. package/dist/infrastructure/orchestration/cassette-recorder.js +120 -0
  28. package/dist/infrastructure/orchestration/claude-code-adapter.js +38 -5
  29. package/dist/infrastructure/orchestration/codex-adapter.js +150 -22
  30. package/dist/infrastructure/orchestration/conductor-adapter.js +9 -3
  31. package/dist/infrastructure/orchestration/context-handoff.js +3 -2
  32. package/dist/infrastructure/orchestration/control/codex-control-surface.js +99 -0
  33. package/dist/infrastructure/orchestration/control/control-surface.js +15 -0
  34. package/dist/infrastructure/orchestration/gemini-adapter.js +12 -2
  35. package/dist/infrastructure/orchestration/graphify-context.js +18 -13
  36. package/dist/infrastructure/orchestration/memory-injector.js +46 -1
  37. package/dist/infrastructure/orchestration/mocks/mock-agent-repl.js +230 -0
  38. package/dist/infrastructure/orchestration/mocks/mock-codex-app-server.js +73 -0
  39. package/dist/infrastructure/orchestration/mocks/mock-synthesis.js +83 -0
  40. package/dist/infrastructure/orchestration/mocks/resolve-agent-spawn.js +37 -0
  41. package/dist/infrastructure/orchestration/opencode-adapter.js +22 -2
  42. package/dist/infrastructure/orchestration/progress-aggregator.js +177 -3
  43. package/dist/infrastructure/orchestration/session-manager.js +112 -6
  44. package/dist/infrastructure/orchestration/session-persistence.js +140 -31
  45. package/dist/infrastructure/orchestration/thread-key-store.js +127 -0
  46. package/dist/infrastructure/orchestration/write-pass-store.js +46 -0
  47. package/dist/infrastructure/protocols/cloud-sync.js +1 -6
  48. package/dist/infrastructure/protocols/mcp-server-impl.js +1283 -13
  49. package/dist/infrastructure/protocols/thread-phase.js +105 -0
  50. package/dist/infrastructure/protocols/ui-page-v2.js +3913 -88
  51. package/dist/infrastructure/protocols/ui-page.js +12 -3299
  52. package/dist/infrastructure/protocols/verify-page.js +941 -0
  53. package/dist/infrastructure/security/trust-scorer.js +76 -1
  54. package/dist/infrastructure/storage/cross-tool-agents.js +1 -1
  55. package/dist/infrastructure/storage/project-thread-migration.js +2 -2
  56. package/dist/infrastructure/storage/project-thread-title-backfill.js +1 -1
  57. package/dist/monitoring.js +1 -1
  58. package/dist/presentation/cli/commands/audit-command.js +126 -0
  59. package/dist/presentation/cli/commands/config-command.js +2 -2
  60. package/dist/presentation/cli/commands/context-source-command.js +198 -0
  61. package/dist/presentation/cli/commands/help-command.js +51 -1
  62. package/dist/presentation/cli/commands/report-command.js +6 -4
  63. package/dist/presentation/cli/commands/setup-command.js +71 -18
  64. package/dist/presentation/cli/commands/status-command.js +0 -4
  65. package/dist/presentation/cli/commands/thread-command.js +288 -0
  66. package/dist/presentation/cli/commands/verify-command.js +233 -0
  67. package/dist/presentation/cli/error-display.js +1 -1
  68. package/dist/presentation/cli/repl.js +32 -1
  69. package/dist/presentation/cli/task-deliverable.js +127 -0
  70. package/dist/testing/cassette.js +125 -0
  71. package/dist/testing/replay-adapter.js +166 -0
  72. package/dist/ui.js +18 -1
  73. package/package.json +5 -2
@@ -0,0 +1,105 @@
1
+ /**
2
+ * Thread phase classifier · the demo v12 lifecycle spine.
3
+ *
4
+ * A thread reads as a phased narrative (research → build → ship → audit → live).
5
+ * Steps don't carry phase labels, so classify by the dominant signal in the
6
+ * step LABEL (the output is noisy — agent names like "claude-code", file lists —
7
+ * and misfires the keywords).
8
+ *
9
+ * This logic used to live inline in the ui-page-v2 template string, where it was
10
+ * untestable — and a `\bcode\b` regex matched "claude-code" and mislabeled read
11
+ * steps as BUILD (caught by eye, not a test). Extracted here so it's unit-tested,
12
+ * and its SOURCE is injected back into the browser template via
13
+ * PHASE_CLASSIFIER_SRC — one source of truth, not a duplicated twin.
14
+ */
15
+ export const PHASE_ORDER = ['research', 'build', 'ship', 'audit', 'live'];
16
+ export const PHASE_META = {
17
+ research: { n: 1, label: 'research', done: 'research locked', verb: 'explored' },
18
+ build: { n: 2, label: 'build', done: 'build done', verb: 'built' },
19
+ ship: { n: 3, label: 'ship', done: 'shipped', verb: 'tested & shipped' },
20
+ audit: { n: 4, label: 'audit', done: 'audited', verb: 'reviewed' },
21
+ live: { n: 5, label: 'live', done: 'live', verb: 'recovered' },
22
+ };
23
+ // Classify on the LABEL only · keep keywords action-specific, NOT domain words.
24
+ // "rate-limit" is a FEATURE many tasks build — it must NOT signal LIVE, or every
25
+ // rate-limit task mislabels its build steps as live. "claude-code" must NOT
26
+ // match \bcode\b → that was the original bug.
27
+ export function stepPhase(step) {
28
+ const s = (step.label || '').toLowerCase();
29
+ if (/failover|crashed|recover|orphan|hydrat|checkpoint|fell back|failed over/.test(s))
30
+ return 'live';
31
+ if (/verif|audit|final report|trust grade|claim vs|w-?pass|write-pass|chain entry/.test(s))
32
+ return 'audit';
33
+ if (/\btest\b|\btests\b|\bpush\b|commit|deploy|benchmark|\bship\b|\bmerge\b/.test(s))
34
+ return 'ship';
35
+ if (/\bedit\b|\bwrite\b|writes |writing|implement|refactor|patch|\bbuild\b|dispatch/.test(s))
36
+ return 'build';
37
+ if (/pre-prompt|scan|\bread\b|grep|search|analyz|research|context|\broute|explor|\bmap\b/.test(s))
38
+ return 'research';
39
+ return null;
40
+ }
41
+ // Assign every step a phase · unknown steps inherit the running phase so the
42
+ // timeline never fragments. Phases only ADVANCE, never regress — once a task has
43
+ // shipped, a stray "read" stays in ship rather than yanking the narrative back.
44
+ // The regress check is against the OLD running phase, THEN advance.
45
+ export function classifySteps(steps) {
46
+ const out = [];
47
+ let cur = 'research';
48
+ for (let i = 0; i < steps.length; i++) {
49
+ let p = stepPhase(steps[i]);
50
+ if (!p)
51
+ p = cur;
52
+ if (PHASE_META[p].n < PHASE_META[cur].n)
53
+ p = cur;
54
+ cur = p;
55
+ out.push(p);
56
+ }
57
+ return out;
58
+ }
59
+ /**
60
+ * EMERGENT grouping for the unified thread timeline. A segment is a run of
61
+ * CONSECUTIVE steps that share a phase — so the sections are however many the
62
+ * actual activity produced, not a fixed pipeline. No monotonic advance, no
63
+ * "phase N of 5", no forced final stage: a one-read task yields one segment, a
64
+ * sprawling task yields several. Unknown steps inherit the running phase so a
65
+ * stray unclassified step doesn't fragment a run; leading unknowns (before any
66
+ * classified step) produce no segment.
67
+ *
68
+ * This replaces classifySteps' fixed-5 framing for the timeline. stepPhase (the
69
+ * per-step activity classifier) is reused unchanged.
70
+ */
71
+ export function segmentSteps(steps) {
72
+ const segs = [];
73
+ let cur = null;
74
+ for (let i = 0; i < steps.length; i++) {
75
+ let p = stepPhase(steps[i]);
76
+ if (!p)
77
+ p = cur;
78
+ if (!p)
79
+ continue;
80
+ if (p !== cur) {
81
+ segs.push({ phase: p, verb: PHASE_META[p].verb, from: i, count: 1 });
82
+ cur = p;
83
+ }
84
+ else {
85
+ segs[segs.length - 1].count++;
86
+ }
87
+ }
88
+ return segs;
89
+ }
90
+ /**
91
+ * Browser-JS source for injection into the ui-page-v2 template literal. Emits
92
+ * the same PHASE_META / stepPhase / segmentSteps the tests cover, so the
93
+ * rendered thread uses the EXACT logic that's unit-tested. PHASE_ORDER +
94
+ * classifySteps are still emitted during the timeline-restructure transition
95
+ * (renderD's old phase-position line uses them); they go once renderD switches
96
+ * to segmentSteps.
97
+ */
98
+ export const PHASE_CLASSIFIER_SRC = [
99
+ 'var PHASE_ORDER=' + JSON.stringify(PHASE_ORDER) + ';',
100
+ 'var PHASE_META=' + JSON.stringify(PHASE_META) + ';',
101
+ stepPhase.toString(),
102
+ classifySteps.toString(),
103
+ segmentSteps.toString(),
104
+ ].join('\n');
105
+ //# sourceMappingURL=thread-phase.js.map