ai-summon 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 (61) hide show
  1. package/.claude/commands/speckit.analyze.md +184 -0
  2. package/.claude/commands/speckit.checklist.md +294 -0
  3. package/.claude/commands/speckit.clarify.md +177 -0
  4. package/.claude/commands/speckit.constitution.md +78 -0
  5. package/.claude/commands/speckit.implement.md +121 -0
  6. package/.claude/commands/speckit.plan.md +81 -0
  7. package/.claude/commands/speckit.specify.md +204 -0
  8. package/.claude/commands/speckit.tasks.md +108 -0
  9. package/.claude/settings.local.json +23 -0
  10. package/.prettierignore +5 -0
  11. package/.prettierrc.json +10 -0
  12. package/.specify/memory/constitution.md +72 -0
  13. package/.specify/scripts/bash/check-prerequisites.sh +166 -0
  14. package/.specify/scripts/bash/common.sh +113 -0
  15. package/.specify/scripts/bash/create-new-feature.sh +97 -0
  16. package/.specify/scripts/bash/setup-plan.sh +60 -0
  17. package/.specify/scripts/bash/update-agent-context.sh +738 -0
  18. package/.specify/templates/agent-file-template.md +28 -0
  19. package/.specify/templates/checklist-template.md +40 -0
  20. package/.specify/templates/plan-template.md +111 -0
  21. package/.specify/templates/spec-template.md +115 -0
  22. package/.specify/templates/tasks-template.md +250 -0
  23. package/CLAUDE.md +199 -0
  24. package/PRD.md +268 -0
  25. package/README.md +171 -0
  26. package/dist/ai-summon.d.ts +2 -0
  27. package/dist/ai-summon.js +73 -0
  28. package/dist/commands/ide/index.d.ts +3 -0
  29. package/dist/commands/ide/index.js +253 -0
  30. package/dist/commands/init.d.ts +4 -0
  31. package/dist/commands/init.js +55 -0
  32. package/dist/commands/url.d.ts +4 -0
  33. package/dist/commands/url.js +223 -0
  34. package/dist/types/index.d.ts +40 -0
  35. package/dist/types/index.js +1 -0
  36. package/dist/util.d.ts +16 -0
  37. package/dist/util.js +109 -0
  38. package/eslint.config.js +47 -0
  39. package/package.json +47 -0
  40. package/specs/001-cloud-login-feature/contracts/cloud-command.ts +82 -0
  41. package/specs/001-cloud-login-feature/contracts/config-service.ts +170 -0
  42. package/specs/001-cloud-login-feature/data-model.md +269 -0
  43. package/specs/001-cloud-login-feature/plan.md +91 -0
  44. package/specs/001-cloud-login-feature/quickstart.md +366 -0
  45. package/specs/001-cloud-login-feature/research.md +290 -0
  46. package/specs/001-cloud-login-feature/spec.md +195 -0
  47. package/specs/001-cloud-login-feature/tasks.md +235 -0
  48. package/specs/001-cloud-scp-command/contracts/cloud-scp-api.ts +402 -0
  49. package/specs/001-cloud-scp-command/data-model.md +424 -0
  50. package/specs/001-cloud-scp-command/plan.md +124 -0
  51. package/specs/001-cloud-scp-command/quickstart.md +536 -0
  52. package/specs/001-cloud-scp-command/research.md +345 -0
  53. package/specs/001-cloud-scp-command/spec.md +248 -0
  54. package/specs/001-cloud-scp-command/tasks.md +434 -0
  55. package/src/ai-summon.ts +88 -0
  56. package/src/commands/ide/index.ts +322 -0
  57. package/src/commands/init.ts +64 -0
  58. package/src/commands/url.ts +262 -0
  59. package/src/types/index.ts +49 -0
  60. package/src/util.ts +146 -0
  61. package/tsconfig.json +21 -0
@@ -0,0 +1,195 @@
1
+ # Feature Specification: Cloud Login Command
2
+
3
+ **Feature ID**: 001-cloud-login-feature
4
+ **Created**: 2025-10-11
5
+ **Type**: CLI Enhancement
6
+
7
+ ## Overview
8
+
9
+ Add a new `hsh cloud login` command that enables users to SSH into cloud instances based on environment and service parameters. The command should read IP addresses from a restructured configuration file and handle SSH connections with proper key management.
10
+
11
+ ## Functional Requirements
12
+
13
+ ### FR-1: Cloud Command Structure
14
+
15
+ - **Main Command**: `hsh cloud` - Cloud infrastructure management
16
+ - **Subcommand**: `hsh cloud login --env <environment> --service <service-name>`
17
+ - **Parameters**:
18
+ - `--env`: Environment selection (dev/staging/prod)
19
+ - `--service`: Service name (todo-mini, wuhan-mall)
20
+ - **Action**: Execute SSH connection to the appropriate IP address using configured private key
21
+ - **Future Expansion**: Designed to support additional subcommands like `hsh cloud scp`, `hsh cloud status`, etc.
22
+
23
+ ### FR-2: Configuration Structure Update
24
+
25
+ - **File**: `~/.ai/config.json`
26
+ - **New Structure**:
27
+ ```json
28
+ {
29
+ "repos": {
30
+ "[group-name]": {
31
+ "[repo-name]": "repo absolute path"
32
+ }
33
+ },
34
+ "yiren": {
35
+ "[service-name]": {
36
+ "dev": {
37
+ "ip": "IP",
38
+ "privateKeyFile": "path/to/private-key-file"
39
+ },
40
+ "staging": {
41
+ "ip": "IP",
42
+ "privateKeyFile": "path/to/private-key-file"
43
+ },
44
+ "prod": {
45
+ "ip": "IP",
46
+ "privateKeyFile": "path/to/private-key-file"
47
+ }
48
+ }
49
+ }
50
+ }
51
+ ```
52
+
53
+ ### FR-3: SSH Connection
54
+
55
+ - **Command Pattern**: `ssh -i {privateKeyFile} root@{ip}`
56
+ - **IP Resolution**: Lookup based on `config.yiren[service][env].ip`
57
+ - **Key Resolution**: Lookup based on `config.yiren[service][env].privateKeyFile`
58
+ - **User**: Always connect as `root` user
59
+ - **Key Management**: Each environment can have its own private key file
60
+
61
+ ### FR-4: Backward Compatibility
62
+
63
+ - **Existing Commands**: Update IDE commands (cursor, surf) to use `config.repos` structure
64
+ - **Migration**: Handle transition from flat structure to nested `repos` structure
65
+
66
+ ## Technical Requirements
67
+
68
+ ### TR-1: Command Integration
69
+
70
+ - Add new command to existing CLI structure using Commander.js
71
+ - Follow existing patterns for parameter validation and error handling
72
+ - Use inquirer for interactive prompts if needed
73
+
74
+ ### TR-2: Configuration Management
75
+
76
+ - Read configuration from `~/.ai/config.json`
77
+ - Validate configuration structure and provide helpful error messages
78
+ - Support both old and new configuration formats during transition
79
+
80
+ ### TR-3: SSH Execution
81
+
82
+ - Use zx library for shell command execution (following constitution)
83
+ - Handle SSH connection errors gracefully
84
+ - Provide user feedback during connection process
85
+
86
+ ### TR-4: Error Handling
87
+
88
+ - Validate environment and service parameters
89
+ - Check for missing configuration entries
90
+ - Handle network connectivity issues
91
+ - Provide clear error messages for troubleshooting
92
+
93
+ ## User Stories
94
+
95
+ ### US-1: Quick Environment Access
96
+
97
+ **As a** developer
98
+ **I want to** quickly SSH into different environments
99
+ **So that** I can debug issues without manually typing SSH commands
100
+
101
+ **Acceptance Criteria**:
102
+
103
+ - Command executes SSH connection with single command
104
+ - Supports all three environments (dev/staging/prod)
105
+ - Uses correct IP address based on service and environment
106
+
107
+ ### US-2: Service-Specific Login
108
+
109
+ **As a** developer working on multiple services
110
+ **I want to** specify which service I'm connecting to
111
+ **So that** I connect to the correct instance
112
+
113
+ **Acceptance Criteria**:
114
+
115
+ - Command accepts service parameter
116
+ - Validates service exists in configuration
117
+ - Routes to correct service-specific IP address
118
+
119
+ ## Configuration Examples
120
+
121
+ ### Before (Current Structure)
122
+
123
+ ```json
124
+ {
125
+ "category1": {
126
+ "project1": "/path/to/project1",
127
+ "project2": "/path/to/project2"
128
+ }
129
+ }
130
+ ```
131
+
132
+ ### After (New Structure)
133
+
134
+ ```json
135
+ {
136
+ "repos": {
137
+ "category1": {
138
+ "project1": "/path/to/project1",
139
+ "project2": "/path/to/project2"
140
+ }
141
+ },
142
+ "yiren": {
143
+ "todo-mini": {
144
+ "dev": {
145
+ "ip": "192.168.1.10",
146
+ "privateKeyFile": "/path/to/todo-mini-dev.pem"
147
+ },
148
+ "staging": {
149
+ "ip": "192.168.1.20",
150
+ "privateKeyFile": "/path/to/todo-mini-staging.pem"
151
+ },
152
+ "prod": {
153
+ "ip": "192.168.1.30",
154
+ "privateKeyFile": "/path/to/todo-mini-prod.pem"
155
+ }
156
+ },
157
+ "wuhan-mall": {
158
+ "dev": {
159
+ "ip": "192.168.2.10",
160
+ "privateKeyFile": "/path/to/wuhan-mall-dev.pem"
161
+ },
162
+ "staging": {
163
+ "ip": "192.168.2.20",
164
+ "privateKeyFile": "/path/to/wuhan-mall-staging.pem"
165
+ },
166
+ "prod": {
167
+ "ip": "192.168.2.30",
168
+ "privateKeyFile": "/path/to/wuhan-mall-prod.pem"
169
+ }
170
+ }
171
+ }
172
+ }
173
+ ```
174
+
175
+ ## Dependencies
176
+
177
+ - **Existing**: commander, zx, chalk (already in project)
178
+ - **New**: None required
179
+ - **External**: SSH client (system dependency)
180
+ - **Configuration**: PEM file path (to be specified in config or hardcoded)
181
+
182
+ ## Success Criteria
183
+
184
+ 1. Command successfully connects to specified environment and service
185
+ 2. Configuration file structure updated without breaking existing commands
186
+ 3. Clear error messages for invalid parameters or missing configuration
187
+ 4. Follows project's TypeScript and CLI design principles
188
+ 5. Integration tests pass for all command variations
189
+
190
+ ## Non-Functional Requirements
191
+
192
+ - **Security**: SSH keys properly managed and not exposed in logs
193
+ - **Performance**: Command executes within 2 seconds (excluding SSH connection time)
194
+ - **Usability**: Clear error messages and parameter validation
195
+ - **Maintainability**: Code follows existing project patterns and constitution
@@ -0,0 +1,235 @@
1
+ ---
2
+ description: 'Task list for Cloud Login Command feature implementation'
3
+ ---
4
+
5
+ # Tasks: Cloud Login Command
6
+
7
+ **Input**: Design documents from `/specs/001-cloud-login-feature/`
8
+ **Prerequisites**: plan.md (required), spec.md (required for user stories), research.md, data-model.md, contracts/
9
+
10
+ **Tests**: Manual CLI testing will be performed as specified in the plan. No automated test tasks included as they were not explicitly requested in the feature specification.
11
+
12
+ **Organization**: Tasks are grouped by user story to enable independent implementation and testing of each story.
13
+
14
+ ## Format: `[ID] [P?] [Story] Description`
15
+
16
+ - **[P]**: Can run in parallel (different files, no dependencies)
17
+ - **[Story]**: Which user story this task belongs to (e.g., US1, US2)
18
+ - Include exact file paths in descriptions
19
+
20
+ ## Path Conventions
21
+
22
+ - **TypeScript CLI Project**: `src/`, `dist/` at repository root
23
+ - Paths reference existing structure with `src/commands/`, `src/types/`, `src/util.ts`, `src/hsh.ts`
24
+
25
+ ## Phase 1: Setup (Shared Infrastructure)
26
+
27
+ **Purpose**: Project initialization and basic configuration updates
28
+
29
+ - [x] T001 [P] Update TypeScript types in src/types/index.ts with cloud configuration interfaces (CloudConfig, ServiceConfig, YirenConfig, HshConfig, Environment)
30
+ - [x] T002 [P] Update configuration utility in src/util.ts to support new config structure with automatic migration from legacy format
31
+
32
+ ---
33
+
34
+ ## Phase 2: Foundational (Blocking Prerequisites)
35
+
36
+ **Purpose**: Core infrastructure that MUST be complete before ANY user story can be implemented
37
+
38
+ **⚠️ CRITICAL**: No user story work can begin until this phase is complete
39
+
40
+ - [x] T003 Create new cloud command module in src/commands/cloud.ts with basic structure and imports (zx, chalk, inquirer)
41
+ - [x] T004 Update main CLI entry point in src/hsh.ts to register cloud command with subcommand structure
42
+ - [x] T005 [P] Implement private key validation function in src/commands/cloud.ts (file existence, permissions check)
43
+ - [x] T006 [P] Implement SSH error handling function in src/commands/cloud.ts (connection timeout, auth failure, network errors)
44
+ - [x] T007 [P] Implement interactive prompt helpers in src/commands/cloud.ts (service selection, environment selection)
45
+
46
+ **Checkpoint**: Foundation ready - user story implementation can now begin in parallel
47
+
48
+ ---
49
+
50
+ ## Phase 3: User Story 1 - Quick Environment Access (Priority: P1) 🎯 MVP
51
+
52
+ **Goal**: Enable developers to quickly SSH into different environments with a single command
53
+
54
+ **Independent Test**: `hsh cloud login --env dev --service todo-mini` successfully connects to the specified environment
55
+
56
+ ### Implementation for User Story 1
57
+
58
+ - [x] T008 [US1] Implement core cloudLogin function in src/commands/cloud.ts with parameter validation and config lookup
59
+ - [x] T009 [US1] Add SSH execution logic in src/commands/cloud.ts using zx with proper timeout and connection options
60
+ - [x] T010 [US1] Add environment parameter validation (dev/staging/prod) in src/commands/cloud.ts
61
+ - [x] T011 [US1] Add configuration file reading with error handling for missing config file in src/commands/cloud.ts
62
+ - [x] T012 [US1] Add IP address resolution logic based on config.yiren[service][env].ip in src/commands/cloud.ts
63
+ - [x] T013 [US1] Add private key file resolution logic based on config.yiren[service][env].privateKeyFile in src/commands/cloud.ts
64
+ - [x] T014 [US1] Add colored output feedback using chalk for connection status and errors in src/commands/cloud.ts
65
+
66
+ **Checkpoint**: At this point, User Story 1 should be fully functional - users can SSH into environments with explicit parameters
67
+
68
+ ---
69
+
70
+ ## Phase 4: User Story 2 - Service-Specific Login (Priority: P2)
71
+
72
+ **Goal**: Enable developers to specify which service they're connecting to and validate service exists in configuration
73
+
74
+ **Independent Test**: `hsh cloud login --service wuhan-mall --env staging` successfully connects to the correct service-specific instance
75
+
76
+ ### Implementation for User Story 2
77
+
78
+ - [x] T015 [US2] Add service parameter validation and lookup in src/commands/cloud.ts
79
+ - [x] T016 [US2] Add service configuration existence check with helpful error messages in src/commands/cloud.ts
80
+ - [x] T017 [US2] Implement interactive service selection when service parameter is missing in src/commands/cloud.ts
81
+ - [x] T018 [US2] Implement interactive environment selection when environment parameter is missing in src/commands/cloud.ts
82
+ - [x] T019 [US2] Add service availability listing from config.yiren keys in src/commands/cloud.ts
83
+ - [x] T020 [US2] Add validation for service-environment combination existence in src/commands/cloud.ts
84
+
85
+ **Checkpoint**: All user stories should now be independently functional - full interactive and parameter-driven access
86
+
87
+ ---
88
+
89
+ ## Phase 5: Backward Compatibility & Migration
90
+
91
+ **Purpose**: Ensure existing commands continue to work with new configuration structure
92
+
93
+ - [x] T021 Update IDE cursor command in src/commands/ide.ts to use config.repos instead of direct config access
94
+ - [x] T022 Update IDE surf command in src/commands/ide.ts to use config.repos instead of direct config access
95
+ - [x] T023 [P] Test legacy configuration migration with existing IDE commands to ensure no breaking changes
96
+ - [x] T024 [P] Add warning messages for users when legacy configuration format is detected and migrated
97
+
98
+ **Checkpoint**: Existing functionality preserved with new configuration structure
99
+
100
+ ---
101
+
102
+ ## Phase 6: Polish & Cross-Cutting Concerns
103
+
104
+ **Purpose**: Improvements that enhance the overall feature quality
105
+
106
+ - [x] T025 [P] Add comprehensive error messages for all failure scenarios (config not found, invalid JSON, missing services)
107
+ - [x] T026 [P] Add user feedback improvements with chalk colors and connection progress indicators
108
+ - [x] T027 [P] Add configuration validation with helpful suggestions for fixing common issues
109
+ - [x] T028 [P] Implement production environment confirmation prompt for safety
110
+ - [x] T029 Build and test globally installed CLI with `yarn build:install`
111
+ - [x] T030 Run manual testing checklist from quickstart.md to validate all scenarios
112
+
113
+ ---
114
+
115
+ ## Dependencies & Execution Order
116
+
117
+ ### Phase Dependencies
118
+
119
+ - **Setup (Phase 1)**: No dependencies - can start immediately
120
+ - **Foundational (Phase 2)**: Depends on Setup completion - BLOCKS all user stories
121
+ - **User Stories (Phase 3+)**: All depend on Foundational phase completion
122
+ - User stories can then proceed in parallel (if staffed)
123
+ - Or sequentially in priority order (P1 → P2)
124
+ - **Backward Compatibility (Phase 5)**: Can start after User Story 1 is complete
125
+ - **Polish (Phase 6)**: Depends on all user stories and compatibility work being complete
126
+
127
+ ### User Story Dependencies
128
+
129
+ - **User Story 1 (P1)**: Can start after Foundational (Phase 2) - No dependencies on other stories
130
+ - **User Story 2 (P2)**: Can start after Foundational (Phase 2) - Builds on US1 but should be independently testable
131
+
132
+ ### Within Each User Story
133
+
134
+ - Configuration reading before parameter validation
135
+ - Parameter validation before SSH execution
136
+ - Error handling implemented alongside core functionality
137
+ - Interactive prompts added after parameter validation is working
138
+
139
+ ### Parallel Opportunities
140
+
141
+ - All Setup tasks marked [P] can run in parallel
142
+ - All Foundational tasks marked [P] can run in parallel (within Phase 2)
143
+ - Once Foundational phase completes, User Stories 1 and 2 can start in parallel (if team capacity allows)
144
+ - Backward compatibility tasks can run in parallel with User Story 2
145
+ - Polish tasks marked [P] can run in parallel
146
+
147
+ ---
148
+
149
+ ## Parallel Example: User Story 1
150
+
151
+ ```bash
152
+ # These foundational tasks can be launched together:
153
+ Task: "Implement private key validation function in src/commands/cloud.ts"
154
+ Task: "Implement SSH error handling function in src/commands/cloud.ts"
155
+ Task: "Implement interactive prompt helpers in src/commands/cloud.ts"
156
+
157
+ # These polish tasks can be launched together:
158
+ Task: "Add comprehensive error messages for all failure scenarios"
159
+ Task: "Add user feedback improvements with chalk colors"
160
+ Task: "Add configuration validation with helpful suggestions"
161
+ ```
162
+
163
+ ---
164
+
165
+ ## Implementation Strategy
166
+
167
+ ### MVP First (User Story 1 Only)
168
+
169
+ 1. Complete Phase 1: Setup (T001-T002)
170
+ 2. Complete Phase 2: Foundational (T003-T007) - CRITICAL phase
171
+ 3. Complete Phase 3: User Story 1 (T008-T014)
172
+ 4. **STOP and VALIDATE**: Test `hsh cloud login --env dev --service todo-mini`
173
+ 5. Deploy/demo if ready - basic cloud login functionality working
174
+
175
+ ### Incremental Delivery
176
+
177
+ 1. Complete Setup + Foundational → Foundation ready
178
+ 2. Add User Story 1 → Test independently → Deploy/Demo (MVP!)
179
+ 3. Add User Story 2 → Test independently → Deploy/Demo (Full interactive experience)
180
+ 4. Add Backward Compatibility → Test existing commands still work
181
+ 5. Add Polish → Final production-ready version
182
+
183
+ ### Parallel Team Strategy
184
+
185
+ With multiple developers:
186
+
187
+ 1. Team completes Setup + Foundational together
188
+ 2. Once Foundational is done:
189
+ - Developer A: User Story 1 (T008-T014)
190
+ - Developer B: User Story 2 (T015-T020)
191
+ - Developer C: Backward Compatibility (T021-T024)
192
+ 3. Stories complete and integrate independently
193
+
194
+ ---
195
+
196
+ ## Manual Testing Plan
197
+
198
+ Based on quickstart.md validation checklist:
199
+
200
+ **After User Story 1 completion:**
201
+
202
+ - [ ] `hsh cloud --help` shows available subcommands
203
+ - [ ] `hsh cloud login --help` shows login-specific options
204
+ - [ ] `hsh cloud login --env dev --service todo-mini` connects successfully
205
+
206
+ **After User Story 2 completion:**
207
+
208
+ - [ ] `hsh cloud login` prompts for missing parameters
209
+ - [ ] Invalid service name shows helpful error message
210
+ - [ ] Invalid environment shows helpful error message
211
+
212
+ **After Backward Compatibility completion:**
213
+
214
+ - [ ] Existing `hsh cursor` command still works with new config structure
215
+ - [ ] Existing `hsh surf` command still works with new config structure
216
+ - [ ] Legacy configuration automatically migrates to new structure
217
+
218
+ **After Polish completion:**
219
+
220
+ - [ ] Missing private key file shows helpful error message
221
+ - [ ] Wrong private key permissions shows warning with fix command
222
+ - [ ] Production access requires confirmation
223
+
224
+ ---
225
+
226
+ ## Notes
227
+
228
+ - [P] tasks = different files, no dependencies
229
+ - [Story] label maps task to specific user story for traceability
230
+ - Each user story should be independently completable and testable
231
+ - Manual testing replaces automated tests as specified in the plan
232
+ - Commit after each task or logical group
233
+ - Stop at any checkpoint to validate story independently
234
+ - Configuration migration maintains backward compatibility
235
+ - Follow TypeScript strict mode and project constitution requirements