@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.
Files changed (119) hide show
  1. package/.github/workflows/release.yml +44 -0
  2. package/.goreleaser.yml +44 -0
  3. package/AGENTS.md +60 -0
  4. package/CLAUDE.md +192 -0
  5. package/README.md +2 -0
  6. package/docs/architecture/awiki-command-v2.md +955 -0
  7. package/docs/architecture/awiki-skill-architecture.md +475 -0
  8. package/docs/architecture/awiki-v2-architecture.md +1063 -0
  9. package/docs/architecture//345/217/202/350/200/203/346/226/207/346/241/243/cli-init.md +1008 -0
  10. package/docs/architecture//345/217/202/350/200/203/346/226/207/346/241/243/output-format.md +407 -0
  11. package/docs/architecture//345/217/202/350/200/203/346/226/207/346/241/243/overall-init.md +741 -0
  12. package/docs/harness/review-spec.md +474 -0
  13. package/docs/installation.md +372 -0
  14. package/docs/plan/awiki-v2-implementation-plan.md +903 -0
  15. package/docs/plan/phase-0/adr-index.md +56 -0
  16. package/docs/plan/phase-0/audit-findings.md +251 -0
  17. package/docs/plan/phase-0/capability-mapping.md +108 -0
  18. package/docs/plan/phase-0/implementation-constraints.md +363 -0
  19. package/docs/publish.md +169 -0
  20. package/go.mod +29 -0
  21. package/go.sum +73 -0
  22. package/internal/anpsdk/registry.go +63 -0
  23. package/internal/authsdk/session.go +351 -0
  24. package/internal/buildinfo/buildinfo.go +34 -0
  25. package/internal/cli/app.go +136 -0
  26. package/internal/cli/app_test.go +88 -0
  27. package/internal/cli/debug.go +104 -0
  28. package/internal/cli/group.go +263 -0
  29. package/internal/cli/id.go +473 -0
  30. package/internal/cli/init.go +134 -0
  31. package/internal/cli/msg.go +228 -0
  32. package/internal/cli/page.go +267 -0
  33. package/internal/cli/root.go +499 -0
  34. package/internal/cli/runtime.go +232 -0
  35. package/internal/cli/upgrade.go +60 -0
  36. package/internal/cmdmeta/catalog.go +203 -0
  37. package/internal/cmdmeta/catalog_test.go +21 -0
  38. package/internal/config/config.go +399 -0
  39. package/internal/config/config_test.go +104 -0
  40. package/internal/config/write.go +37 -0
  41. package/internal/content/service.go +314 -0
  42. package/internal/content/service_test.go +165 -0
  43. package/internal/content/types.go +44 -0
  44. package/internal/docs/topics.go +110 -0
  45. package/internal/doctor/doctor.go +306 -0
  46. package/internal/identity/client.go +267 -0
  47. package/internal/identity/did.go +85 -0
  48. package/internal/identity/did_test.go +50 -0
  49. package/internal/identity/layout.go +206 -0
  50. package/internal/identity/legacy.go +378 -0
  51. package/internal/identity/public.go +70 -0
  52. package/internal/identity/public_test.go +73 -0
  53. package/internal/identity/readiness.go +74 -0
  54. package/internal/identity/service.go +826 -0
  55. package/internal/identity/store.go +385 -0
  56. package/internal/identity/store_test.go +180 -0
  57. package/internal/identity/types.go +204 -0
  58. package/internal/message/auth.go +167 -0
  59. package/internal/message/group_service.go +838 -0
  60. package/internal/message/group_wire.go +350 -0
  61. package/internal/message/group_wire_test.go +67 -0
  62. package/internal/message/helpers.go +61 -0
  63. package/internal/message/http_client.go +334 -0
  64. package/internal/message/proof.go +156 -0
  65. package/internal/message/proof_test.go +61 -0
  66. package/internal/message/service.go +696 -0
  67. package/internal/message/service_test.go +97 -0
  68. package/internal/message/types.go +155 -0
  69. package/internal/message/wire.go +100 -0
  70. package/internal/message/wire_test.go +49 -0
  71. package/internal/message/ws_proxy_client.go +151 -0
  72. package/internal/output/output.go +350 -0
  73. package/internal/output/output_test.go +48 -0
  74. package/internal/runtime/config.go +117 -0
  75. package/internal/runtime/config_test.go +46 -0
  76. package/internal/runtime/listener/files.go +65 -0
  77. package/internal/runtime/listener/manager.go +142 -0
  78. package/internal/runtime/listener/server.go +983 -0
  79. package/internal/runtime/listener/server_test.go +319 -0
  80. package/internal/runtime/listener/sysproc_unix.go +17 -0
  81. package/internal/runtime/listener/sysproc_windows.go +13 -0
  82. package/internal/runtime/listener/types.go +21 -0
  83. package/internal/runtime/listener/wsclient.go +299 -0
  84. package/internal/runtime/listener/wsclient_test.go +41 -0
  85. package/internal/store/dao.go +632 -0
  86. package/internal/store/dao_test.go +87 -0
  87. package/internal/store/helpers.go +197 -0
  88. package/internal/store/import.go +499 -0
  89. package/internal/store/import_test.go +103 -0
  90. package/internal/store/open.go +71 -0
  91. package/internal/store/query.go +151 -0
  92. package/internal/store/schema.go +277 -0
  93. package/internal/store/schema_test.go +56 -0
  94. package/internal/store/types.go +177 -0
  95. package/internal/update/update.go +368 -0
  96. package/package.json +17 -0
  97. package/scripts/install.js +171 -0
  98. package/scripts/release/release-prerelease.sh +86 -0
  99. package/scripts/release/tag-release.sh +66 -0
  100. package/scripts/release/withdraw-release.sh +78 -0
  101. package/scripts/run.js +69 -0
  102. package/skills/README.md +32 -0
  103. package/skills/awiki-bundle/SKILL.md +76 -0
  104. package/skills/awiki-debug/SKILL.md +80 -0
  105. package/skills/awiki-group/SKILL.md +111 -0
  106. package/skills/awiki-id/SKILL.md +123 -0
  107. package/skills/awiki-msg/SKILL.md +131 -0
  108. package/skills/awiki-page/SKILL.md +93 -0
  109. package/skills/awiki-people/SKILL.md +66 -0
  110. package/skills/awiki-runtime/SKILL.md +137 -0
  111. package/skills/awiki-shared/SKILL.md +124 -0
  112. package/skills/awiki-workflow-discovery/SKILL.md +93 -0
  113. package/skills/awiki-workflow-onboarding/SKILL.md +119 -0
  114. package/skills/manifests/skills.yaml +260 -0
  115. package/skills/templates/bundle-skill-template.md +42 -0
  116. package/skills/templates/debug-skill-template.md +44 -0
  117. package/skills/templates/domain-skill-template.md +56 -0
  118. package/skills/templates/shared-skill-template.md +46 -0
  119. 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
+ }