orch-code 0.1.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.
- package/CHANGELOG.md +12 -0
- package/LICENSE +21 -0
- package/README.md +624 -0
- package/cmd/apply.go +111 -0
- package/cmd/auth.go +393 -0
- package/cmd/auth_test.go +100 -0
- package/cmd/diff.go +57 -0
- package/cmd/doctor.go +149 -0
- package/cmd/explain.go +192 -0
- package/cmd/explain_test.go +62 -0
- package/cmd/init.go +100 -0
- package/cmd/interactive.go +1372 -0
- package/cmd/interactive_input.go +45 -0
- package/cmd/interactive_input_test.go +55 -0
- package/cmd/logs.go +72 -0
- package/cmd/model.go +84 -0
- package/cmd/plan.go +149 -0
- package/cmd/provider.go +189 -0
- package/cmd/provider_model_doctor_test.go +91 -0
- package/cmd/root.go +67 -0
- package/cmd/run.go +123 -0
- package/cmd/run_engine.go +208 -0
- package/cmd/run_engine_test.go +30 -0
- package/cmd/session.go +589 -0
- package/cmd/session_helpers.go +54 -0
- package/cmd/session_integration_test.go +30 -0
- package/cmd/session_list_current_test.go +87 -0
- package/cmd/session_messages_test.go +163 -0
- package/cmd/session_runs_test.go +68 -0
- package/cmd/sprint1_integration_test.go +119 -0
- package/cmd/stats.go +173 -0
- package/cmd/stats_test.go +71 -0
- package/cmd/version.go +4 -0
- package/go.mod +45 -0
- package/go.sum +108 -0
- package/internal/agents/agent.go +31 -0
- package/internal/agents/coder.go +167 -0
- package/internal/agents/planner.go +155 -0
- package/internal/agents/reviewer.go +118 -0
- package/internal/agents/runtime.go +25 -0
- package/internal/agents/runtime_test.go +77 -0
- package/internal/auth/account.go +78 -0
- package/internal/auth/oauth.go +523 -0
- package/internal/auth/store.go +287 -0
- package/internal/confidence/policy.go +174 -0
- package/internal/confidence/policy_test.go +71 -0
- package/internal/confidence/scorer.go +253 -0
- package/internal/confidence/scorer_test.go +83 -0
- package/internal/config/config.go +331 -0
- package/internal/config/config_defaults_test.go +138 -0
- package/internal/execution/contract_builder.go +160 -0
- package/internal/execution/contract_builder_test.go +68 -0
- package/internal/execution/plan_compliance.go +161 -0
- package/internal/execution/plan_compliance_test.go +71 -0
- package/internal/execution/retry_directive.go +132 -0
- package/internal/execution/scope_guard.go +69 -0
- package/internal/logger/logger.go +120 -0
- package/internal/models/contracts_test.go +100 -0
- package/internal/models/models.go +269 -0
- package/internal/orchestrator/orchestrator.go +701 -0
- package/internal/orchestrator/orchestrator_retry_test.go +135 -0
- package/internal/orchestrator/review_engine_test.go +50 -0
- package/internal/orchestrator/state.go +42 -0
- package/internal/orchestrator/test_classifier_test.go +68 -0
- package/internal/patch/applier.go +131 -0
- package/internal/patch/applier_test.go +25 -0
- package/internal/patch/parser.go +89 -0
- package/internal/patch/patch.go +60 -0
- package/internal/patch/summary.go +30 -0
- package/internal/patch/validator.go +104 -0
- package/internal/planning/normalizer.go +416 -0
- package/internal/planning/normalizer_test.go +64 -0
- package/internal/providers/errors.go +35 -0
- package/internal/providers/openai/client.go +498 -0
- package/internal/providers/openai/client_test.go +187 -0
- package/internal/providers/provider.go +47 -0
- package/internal/providers/registry.go +32 -0
- package/internal/providers/registry_test.go +57 -0
- package/internal/providers/router.go +52 -0
- package/internal/providers/state.go +114 -0
- package/internal/providers/state_test.go +64 -0
- package/internal/repo/analyzer.go +188 -0
- package/internal/repo/context.go +83 -0
- package/internal/review/engine.go +267 -0
- package/internal/review/engine_test.go +103 -0
- package/internal/runstore/store.go +137 -0
- package/internal/runstore/store_test.go +59 -0
- package/internal/runtime/lock.go +150 -0
- package/internal/runtime/lock_test.go +57 -0
- package/internal/session/compaction.go +260 -0
- package/internal/session/compaction_test.go +36 -0
- package/internal/session/service.go +117 -0
- package/internal/session/service_test.go +113 -0
- package/internal/storage/storage.go +1498 -0
- package/internal/storage/storage_test.go +413 -0
- package/internal/testing/classifier.go +80 -0
- package/internal/testing/classifier_test.go +36 -0
- package/internal/tools/command.go +160 -0
- package/internal/tools/command_test.go +56 -0
- package/internal/tools/file.go +111 -0
- package/internal/tools/git.go +77 -0
- package/internal/tools/invalid_params_test.go +36 -0
- package/internal/tools/policy.go +98 -0
- package/internal/tools/policy_test.go +36 -0
- package/internal/tools/registry_test.go +52 -0
- package/internal/tools/result.go +30 -0
- package/internal/tools/search.go +86 -0
- package/internal/tools/tool.go +94 -0
- package/main.go +9 -0
- package/npm/orch.js +25 -0
- package/package.json +41 -0
- package/scripts/changelog.js +20 -0
- package/scripts/check-release-version.js +21 -0
- package/scripts/lib/release-utils.js +223 -0
- package/scripts/postinstall.js +157 -0
- package/scripts/release.js +52 -0
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
package session
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"strings"
|
|
5
|
+
"testing"
|
|
6
|
+
|
|
7
|
+
"github.com/furkanbeydemir/orch/internal/storage"
|
|
8
|
+
)
|
|
9
|
+
|
|
10
|
+
func TestAppendTextAndListMessagesWithParts(t *testing.T) {
|
|
11
|
+
repoRoot := t.TempDir()
|
|
12
|
+
store, err := storage.Open(repoRoot)
|
|
13
|
+
if err != nil {
|
|
14
|
+
t.Fatalf("open storage: %v", err)
|
|
15
|
+
}
|
|
16
|
+
defer store.Close()
|
|
17
|
+
|
|
18
|
+
projectID, err := store.GetOrCreateProject()
|
|
19
|
+
if err != nil {
|
|
20
|
+
t.Fatalf("get project: %v", err)
|
|
21
|
+
}
|
|
22
|
+
sess, err := store.EnsureDefaultSession(projectID)
|
|
23
|
+
if err != nil {
|
|
24
|
+
t.Fatalf("ensure default session: %v", err)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
svc := NewService(store)
|
|
28
|
+
created, err := svc.AppendText(MessageInput{
|
|
29
|
+
SessionID: sess.ID,
|
|
30
|
+
Role: "user",
|
|
31
|
+
ProviderID: "openai",
|
|
32
|
+
ModelID: "gpt-5.3-codex",
|
|
33
|
+
Text: "selam",
|
|
34
|
+
})
|
|
35
|
+
if err != nil {
|
|
36
|
+
t.Fatalf("append text: %v", err)
|
|
37
|
+
}
|
|
38
|
+
if created == nil {
|
|
39
|
+
t.Fatalf("expected created message")
|
|
40
|
+
}
|
|
41
|
+
if len(created.Parts) != 1 {
|
|
42
|
+
t.Fatalf("expected 1 part, got %d", len(created.Parts))
|
|
43
|
+
}
|
|
44
|
+
if text := ExtractTextPart(created.Parts[0]); text != "selam" {
|
|
45
|
+
t.Fatalf("unexpected text payload: %q", text)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
messages, err := svc.ListMessagesWithParts(sess.ID, 10)
|
|
49
|
+
if err != nil {
|
|
50
|
+
t.Fatalf("list messages with parts: %v", err)
|
|
51
|
+
}
|
|
52
|
+
if len(messages) != 1 {
|
|
53
|
+
t.Fatalf("expected one message, got %d", len(messages))
|
|
54
|
+
}
|
|
55
|
+
if messages[0].Message.Role != "user" {
|
|
56
|
+
t.Fatalf("unexpected role: %s", messages[0].Message.Role)
|
|
57
|
+
}
|
|
58
|
+
if got := ExtractTextPart(messages[0].Parts[0]); got != "selam" {
|
|
59
|
+
t.Fatalf("unexpected extracted text: %q", got)
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
func TestMaybeCompact(t *testing.T) {
|
|
64
|
+
repoRoot := t.TempDir()
|
|
65
|
+
store, err := storage.Open(repoRoot)
|
|
66
|
+
if err != nil {
|
|
67
|
+
t.Fatalf("open storage: %v", err)
|
|
68
|
+
}
|
|
69
|
+
defer store.Close()
|
|
70
|
+
|
|
71
|
+
projectID, err := store.GetOrCreateProject()
|
|
72
|
+
if err != nil {
|
|
73
|
+
t.Fatalf("get project: %v", err)
|
|
74
|
+
}
|
|
75
|
+
sess, err := store.EnsureDefaultSession(projectID)
|
|
76
|
+
if err != nil {
|
|
77
|
+
t.Fatalf("ensure default session: %v", err)
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
svc := NewService(store)
|
|
81
|
+
veryLong := strings.Repeat("a", 320000)
|
|
82
|
+
if _, err := svc.AppendText(MessageInput{SessionID: sess.ID, Role: "user", Text: veryLong}); err != nil {
|
|
83
|
+
t.Fatalf("append large text: %v", err)
|
|
84
|
+
}
|
|
85
|
+
if _, err := svc.AppendText(MessageInput{SessionID: sess.ID, Role: "assistant", Text: "Updated file internal/session/service.go and docs/SESSION_ONLY_FULLSTACK_PLAN.md"}); err != nil {
|
|
86
|
+
t.Fatalf("append path hint text: %v", err)
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
compacted, note, err := svc.MaybeCompact(sess.ID, "unknown-model")
|
|
90
|
+
if err != nil {
|
|
91
|
+
t.Fatalf("maybe compact: %v", err)
|
|
92
|
+
}
|
|
93
|
+
if !compacted {
|
|
94
|
+
t.Fatalf("expected compaction to trigger")
|
|
95
|
+
}
|
|
96
|
+
if note == "" {
|
|
97
|
+
t.Fatalf("expected compaction note")
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
summary, err := store.GetSessionSummary(sess.ID)
|
|
101
|
+
if err != nil {
|
|
102
|
+
t.Fatalf("get summary: %v", err)
|
|
103
|
+
}
|
|
104
|
+
if summary == nil || strings.TrimSpace(summary.SummaryText) == "" {
|
|
105
|
+
t.Fatalf("expected persisted summary")
|
|
106
|
+
}
|
|
107
|
+
if !strings.Contains(summary.SummaryText, "## Instructions") {
|
|
108
|
+
t.Fatalf("expected instructions section in summary")
|
|
109
|
+
}
|
|
110
|
+
if !strings.Contains(summary.SummaryText, "## Relevant files/directories") {
|
|
111
|
+
t.Fatalf("expected relevant files section in summary")
|
|
112
|
+
}
|
|
113
|
+
}
|