@awiki/cli 0.0.1-beta.2
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/.github/workflows/release.yml +44 -0
- package/.goreleaser.yml +44 -0
- package/AGENTS.md +60 -0
- package/CLAUDE.md +192 -0
- package/README.md +2 -0
- package/docs/architecture/awiki-command-v2.md +955 -0
- package/docs/architecture/awiki-skill-architecture.md +475 -0
- package/docs/architecture/awiki-v2-architecture.md +1063 -0
- package/docs/architecture//345/217/202/350/200/203/346/226/207/346/241/243/cli-init.md +1008 -0
- package/docs/architecture//345/217/202/350/200/203/346/226/207/346/241/243/output-format.md +407 -0
- package/docs/architecture//345/217/202/350/200/203/346/226/207/346/241/243/overall-init.md +741 -0
- package/docs/harness/review-spec.md +474 -0
- package/docs/installation.md +372 -0
- package/docs/plan/awiki-v2-implementation-plan.md +903 -0
- package/docs/plan/phase-0/adr-index.md +56 -0
- package/docs/plan/phase-0/audit-findings.md +251 -0
- package/docs/plan/phase-0/capability-mapping.md +108 -0
- package/docs/plan/phase-0/implementation-constraints.md +363 -0
- package/docs/publish.md +169 -0
- package/go.mod +29 -0
- package/go.sum +73 -0
- package/internal/anpsdk/registry.go +63 -0
- package/internal/authsdk/session.go +351 -0
- package/internal/buildinfo/buildinfo.go +34 -0
- package/internal/cli/app.go +136 -0
- package/internal/cli/app_test.go +88 -0
- package/internal/cli/debug.go +104 -0
- package/internal/cli/group.go +263 -0
- package/internal/cli/id.go +473 -0
- package/internal/cli/init.go +134 -0
- package/internal/cli/msg.go +228 -0
- package/internal/cli/page.go +267 -0
- package/internal/cli/root.go +499 -0
- package/internal/cli/runtime.go +232 -0
- package/internal/cli/upgrade.go +60 -0
- package/internal/cmdmeta/catalog.go +203 -0
- package/internal/cmdmeta/catalog_test.go +21 -0
- package/internal/config/config.go +399 -0
- package/internal/config/config_test.go +104 -0
- package/internal/config/write.go +37 -0
- package/internal/content/service.go +314 -0
- package/internal/content/service_test.go +165 -0
- package/internal/content/types.go +44 -0
- package/internal/docs/topics.go +110 -0
- package/internal/doctor/doctor.go +306 -0
- package/internal/identity/client.go +267 -0
- package/internal/identity/did.go +85 -0
- package/internal/identity/did_test.go +50 -0
- package/internal/identity/layout.go +206 -0
- package/internal/identity/legacy.go +378 -0
- package/internal/identity/public.go +70 -0
- package/internal/identity/public_test.go +73 -0
- package/internal/identity/readiness.go +74 -0
- package/internal/identity/service.go +826 -0
- package/internal/identity/store.go +385 -0
- package/internal/identity/store_test.go +180 -0
- package/internal/identity/types.go +204 -0
- package/internal/message/auth.go +167 -0
- package/internal/message/group_service.go +838 -0
- package/internal/message/group_wire.go +350 -0
- package/internal/message/group_wire_test.go +67 -0
- package/internal/message/helpers.go +61 -0
- package/internal/message/http_client.go +334 -0
- package/internal/message/proof.go +156 -0
- package/internal/message/proof_test.go +61 -0
- package/internal/message/service.go +696 -0
- package/internal/message/service_test.go +97 -0
- package/internal/message/types.go +155 -0
- package/internal/message/wire.go +100 -0
- package/internal/message/wire_test.go +49 -0
- package/internal/message/ws_proxy_client.go +151 -0
- package/internal/output/output.go +350 -0
- package/internal/output/output_test.go +48 -0
- package/internal/runtime/config.go +117 -0
- package/internal/runtime/config_test.go +46 -0
- package/internal/runtime/listener/files.go +65 -0
- package/internal/runtime/listener/manager.go +142 -0
- package/internal/runtime/listener/server.go +983 -0
- package/internal/runtime/listener/server_test.go +319 -0
- package/internal/runtime/listener/sysproc_unix.go +17 -0
- package/internal/runtime/listener/sysproc_windows.go +13 -0
- package/internal/runtime/listener/types.go +21 -0
- package/internal/runtime/listener/wsclient.go +299 -0
- package/internal/runtime/listener/wsclient_test.go +41 -0
- package/internal/store/dao.go +632 -0
- package/internal/store/dao_test.go +87 -0
- package/internal/store/helpers.go +197 -0
- package/internal/store/import.go +499 -0
- package/internal/store/import_test.go +103 -0
- package/internal/store/open.go +71 -0
- package/internal/store/query.go +151 -0
- package/internal/store/schema.go +277 -0
- package/internal/store/schema_test.go +56 -0
- package/internal/store/types.go +177 -0
- package/internal/update/update.go +368 -0
- package/package.json +17 -0
- package/scripts/install.js +171 -0
- package/scripts/release/release-prerelease.sh +86 -0
- package/scripts/release/tag-release.sh +66 -0
- package/scripts/release/withdraw-release.sh +78 -0
- package/scripts/run.js +69 -0
- package/skills/README.md +32 -0
- package/skills/awiki-bundle/SKILL.md +76 -0
- package/skills/awiki-debug/SKILL.md +80 -0
- package/skills/awiki-group/SKILL.md +111 -0
- package/skills/awiki-id/SKILL.md +123 -0
- package/skills/awiki-msg/SKILL.md +131 -0
- package/skills/awiki-page/SKILL.md +93 -0
- package/skills/awiki-people/SKILL.md +66 -0
- package/skills/awiki-runtime/SKILL.md +137 -0
- package/skills/awiki-shared/SKILL.md +124 -0
- package/skills/awiki-workflow-discovery/SKILL.md +93 -0
- package/skills/awiki-workflow-onboarding/SKILL.md +119 -0
- package/skills/manifests/skills.yaml +260 -0
- package/skills/templates/bundle-skill-template.md +42 -0
- package/skills/templates/debug-skill-template.md +44 -0
- package/skills/templates/domain-skill-template.md +56 -0
- package/skills/templates/shared-skill-template.md +46 -0
- package/skills/templates/workflow-skill-template.md +46 -0
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
package identity
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"encoding/json"
|
|
5
|
+
"strings"
|
|
6
|
+
"testing"
|
|
7
|
+
)
|
|
8
|
+
|
|
9
|
+
func TestPublicDataStripsInternalUserIDFields(t *testing.T) {
|
|
10
|
+
t.Parallel()
|
|
11
|
+
|
|
12
|
+
data := map[string]any{
|
|
13
|
+
"identity": IdentitySummary{
|
|
14
|
+
IdentityName: "alice",
|
|
15
|
+
DID: "did:wba:awiki.ai:user:alice",
|
|
16
|
+
UserID: "user-123",
|
|
17
|
+
Handle: "alice",
|
|
18
|
+
},
|
|
19
|
+
"legacy_scan": LegacyScan{
|
|
20
|
+
IndexedEntries: map[string]IndexEntry{
|
|
21
|
+
"alice": {
|
|
22
|
+
CredentialName: "alice",
|
|
23
|
+
DID: "did:wba:awiki.ai:user:alice",
|
|
24
|
+
UserID: "user-123",
|
|
25
|
+
Handle: "alice",
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
HasLegacy: true,
|
|
29
|
+
},
|
|
30
|
+
"result": map[string]any{
|
|
31
|
+
"user_id": "user-123",
|
|
32
|
+
"nested": map[string]any{
|
|
33
|
+
"userId": "user-456",
|
|
34
|
+
"handle": "alice",
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
sanitized := PublicData(data)
|
|
40
|
+
raw, err := json.Marshal(sanitized)
|
|
41
|
+
if err != nil {
|
|
42
|
+
t.Fatalf("json.Marshal() error = %v", err)
|
|
43
|
+
}
|
|
44
|
+
output := string(raw)
|
|
45
|
+
for _, forbidden := range []string{"user_id", "userId", "UserID", "user-123", "user-456"} {
|
|
46
|
+
if strings.Contains(output, forbidden) {
|
|
47
|
+
t.Fatalf("sanitized output %q still contains %q", output, forbidden)
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
if !strings.Contains(output, "alice") {
|
|
51
|
+
t.Fatalf("sanitized output %q lost public handle fields", output)
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
func TestEvaluateUserStateUsesPublicFriendlyMissingFields(t *testing.T) {
|
|
56
|
+
t.Parallel()
|
|
57
|
+
|
|
58
|
+
state := EvaluateUserState("", "")
|
|
59
|
+
for _, item := range state.Missing {
|
|
60
|
+
if item == "user_id" {
|
|
61
|
+
t.Fatalf("unexpected internal field in Missing: %#v", state.Missing)
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
expected := []string{"registration", "handle"}
|
|
65
|
+
if len(state.Missing) != len(expected) {
|
|
66
|
+
t.Fatalf("state.Missing = %#v, want %#v", state.Missing, expected)
|
|
67
|
+
}
|
|
68
|
+
for index, want := range expected {
|
|
69
|
+
if state.Missing[index] != want {
|
|
70
|
+
t.Fatalf("state.Missing[%d] = %q, want %q", index, state.Missing[index], want)
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
package identity
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"fmt"
|
|
5
|
+
"strings"
|
|
6
|
+
)
|
|
7
|
+
|
|
8
|
+
func EvaluateUserState(userID string, handle string) UserState {
|
|
9
|
+
missing := make([]string, 0, 2)
|
|
10
|
+
if strings.TrimSpace(userID) == "" {
|
|
11
|
+
missing = append(missing, "registration")
|
|
12
|
+
}
|
|
13
|
+
if strings.TrimSpace(handle) == "" {
|
|
14
|
+
missing = append(missing, "handle")
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
state := UserState{
|
|
18
|
+
RegistrationState: "registered_user",
|
|
19
|
+
ReadyForMessaging: len(missing) == 0,
|
|
20
|
+
}
|
|
21
|
+
if len(missing) > 0 {
|
|
22
|
+
state.Missing = missing
|
|
23
|
+
switch len(missing) {
|
|
24
|
+
case 2:
|
|
25
|
+
state.RegistrationState = "local_identity"
|
|
26
|
+
default:
|
|
27
|
+
state.RegistrationState = "partial_user"
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return state
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
func EvaluateStoredIdentityUserState(record *StoredIdentity) UserState {
|
|
34
|
+
if record == nil {
|
|
35
|
+
return UserState{
|
|
36
|
+
RegistrationState: "missing_identity",
|
|
37
|
+
ReadyForMessaging: false,
|
|
38
|
+
Missing: []string{"identity"},
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return EvaluateUserState(record.UserID, record.Handle)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
func EvaluateIdentitySummaryUserState(summary *IdentitySummary) UserState {
|
|
45
|
+
if summary == nil {
|
|
46
|
+
return UserState{
|
|
47
|
+
RegistrationState: "missing_identity",
|
|
48
|
+
ReadyForMessaging: false,
|
|
49
|
+
Missing: []string{"identity"},
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return EvaluateUserState(summary.UserID, summary.Handle)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
func UserRegistrationError(identityName string, state UserState) error {
|
|
56
|
+
if state.ReadyForMessaging {
|
|
57
|
+
return nil
|
|
58
|
+
}
|
|
59
|
+
name := strings.TrimSpace(identityName)
|
|
60
|
+
if name == "" {
|
|
61
|
+
name = "active identity"
|
|
62
|
+
}
|
|
63
|
+
missing := "user registration metadata"
|
|
64
|
+
if len(state.Missing) > 0 {
|
|
65
|
+
missing = strings.Join(state.Missing, ", ")
|
|
66
|
+
}
|
|
67
|
+
return fmt.Errorf(
|
|
68
|
+
"%w: identity %s is %s and missing %s; complete user setup with `awiki-cli id register --handle <handle> ...` or recover an existing handle first",
|
|
69
|
+
ErrUserRegistrationRequired,
|
|
70
|
+
name,
|
|
71
|
+
state.RegistrationState,
|
|
72
|
+
missing,
|
|
73
|
+
)
|
|
74
|
+
}
|