-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcapture.js
More file actions
executable file
·257 lines (222 loc) · 6.92 KB
/
capture.js
File metadata and controls
executable file
·257 lines (222 loc) · 6.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
#!/usr/bin/env node
/**
* UbiCity Learning Experience Capture Tool
*
* Quick capture interface for recording learning moments as they happen.
* Designed to minimize friction - get the experience recorded, analyze later.
*/
const readline = require('readline');
const { UrbanKnowledgeMapper } = require('./mapper');
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
function question(prompt) {
return new Promise(resolve => {
rl.question(prompt, answer => resolve(answer));
});
}
async function captureExperience() {
console.log('\n🏙️ UbiCity Learning Experience Capture\n');
console.log('Record a learning moment as it happens.\n');
const experience = {
learner: {},
context: { location: {} },
experience: {},
metadata: {}
};
// Essential info first
console.log('--- Who ---');
experience.learner.id = await question('Your learner ID (or pseudonym): ');
console.log('\n--- Where ---');
experience.context.location.name = await question('Location name: ');
const locationType = await question(
'Location type (public_space/institution/cafe/library/park/other): '
);
experience.context.location.type = locationType || 'other';
const addCoords = await question('Add GPS coordinates? (y/n): ');
if (addCoords.toLowerCase() === 'y') {
const lat = await question('Latitude: ');
const lon = await question('Longitude: ');
experience.context.location.coordinates = {
lat: parseFloat(lat),
lon: parseFloat(lon)
};
}
console.log('\n--- What ---');
const expType = await question(
'Experience type (observation/experiment/failure/discovery/collaboration/insight/question/practice/reflection): '
);
experience.experience.type = expType || 'observation';
experience.experience.description = await question(
'Describe what you learned or attempted: '
);
const domainsInput = await question(
'Domains involved (comma-separated, e.g., "design,code,urban planning"): '
);
experience.experience.domains = domainsInput
.split(',')
.map(d => d.trim())
.filter(d => d);
console.log('\n--- Outcome ---');
const successInput = await question('Was this a success? (y/n/partial): ');
experience.experience.outcome = {
success: successInput.toLowerCase() === 'y'
};
const connections = await question(
'Any unexpected connections discovered? (comma-separated or press Enter to skip): '
);
if (connections) {
experience.experience.outcome.connections_made = connections
.split(',')
.map(c => c.trim())
.filter(c => c);
}
const questions = await question(
'New questions that emerged? (comma-separated or press Enter to skip): '
);
if (questions) {
experience.experience.outcome.next_questions = questions
.split(',')
.map(q => q.trim())
.filter(q => q);
}
console.log('\n--- Metadata ---');
const tags = await question('Tags (comma-separated, optional): ');
if (tags) {
experience.metadata.tags = tags.split(',').map(t => t.trim()).filter(t => t);
}
const privacy = await question('Privacy level (public/community/private) [community]: ');
experience.metadata.privacy_level = privacy || 'community';
// Capture it
console.log('\n💾 Saving experience...');
const mapper = new UrbanKnowledgeMapper();
mapper.loadAll();
try {
const id = mapper.captureExperience(experience);
console.log(`\n✅ Experience captured with ID: ${id}`);
console.log(`\nTotal experiences in system: ${mapper.experiences.size}`);
// Show quick insights
const location = experience.context.location.name;
const locationExps = Array.from(mapper.locationIndex.get(location) || []);
if (locationExps.length > 1) {
console.log(
`\n📍 You now have ${locationExps.length} experiences at ${location}`
);
}
const domainCount = experience.experience.domains?.length || 0;
if (domainCount > 1) {
console.log(
`\n🔗 This interdisciplinary experience spans ${domainCount} domains`
);
}
} catch (error) {
console.error('\n❌ Error capturing experience:', error.message);
}
rl.close();
}
// Quick capture mode - minimal questions
async function quickCapture() {
console.log('\n⚡ Quick Capture Mode\n');
const learnerId = await question('Learner ID: ');
const location = await question('Where: ');
const description = await question('What happened: ');
const domains = await question('Domains (comma-separated): ');
const experience = {
learner: { id: learnerId },
context: {
location: { name: location, type: 'other' }
},
experience: {
type: 'observation',
description,
domains: domains.split(',').map(d => d.trim()).filter(d => d)
},
metadata: {
privacy_level: 'community'
}
};
const mapper = new UrbanKnowledgeMapper();
mapper.loadAll();
try {
const id = mapper.captureExperience(experience);
console.log(`\n✅ ${id}`);
} catch (error) {
console.error('\n❌', error.message);
}
rl.close();
}
// Template mode - generate example JSON for manual editing
function generateTemplate() {
const template = {
learner: {
id: 'learner-001',
background: ['design', 'programming'],
interests: ['urban computing', 'creative coding']
},
context: {
location: {
name: 'Public Library Makerspace',
type: 'library',
coordinates: {
lat: 51.5074,
lon: -0.1278
}
},
situation: 'Weekly Arduino workshop',
connections: [
{
type: 'mentor',
id: 'maker-jane'
}
]
},
experience: {
type: 'experiment',
description:
'Attempted to connect Arduino to city air quality sensors, initial attempt failed but learned about I2C protocol',
domains: ['electronics', 'environmental science', 'programming'],
artifacts: [
{
type: 'photo',
uri: './photos/arduino-setup.jpg',
description: 'Initial circuit diagram'
}
],
outcome: {
success: false,
next_questions: [
'How do professional environmental monitoring systems work?',
'Could we create a city-wide citizen sensor network?'
],
connections_made: [
'Air quality data relates to urban planning decisions',
'Similar to how botanists collect data in field studies'
]
}
},
metadata: {
tags: ['arduino', 'sensors', 'environment', 'failure'],
privacy_level: 'public',
related_experiences: []
}
};
console.log(JSON.stringify(template, null, 2));
}
// Main
const mode = process.argv[2] || 'full';
switch (mode) {
case 'quick':
case 'q':
quickCapture().catch(console.error);
break;
case 'template':
case 't':
generateTemplate();
break;
case 'full':
case 'f':
default:
captureExperience().catch(console.error);
break;
}