youmd 0.4.9 → 0.6.0
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/dist/__tests__/api.test.d.ts +2 -0
- package/dist/__tests__/api.test.d.ts.map +1 -0
- package/dist/__tests__/api.test.js +84 -0
- package/dist/__tests__/api.test.js.map +1 -0
- package/dist/__tests__/compiler.test.d.ts +2 -0
- package/dist/__tests__/compiler.test.d.ts.map +1 -0
- package/dist/__tests__/compiler.test.js +127 -0
- package/dist/__tests__/compiler.test.js.map +1 -0
- package/dist/__tests__/config.test.d.ts +2 -0
- package/dist/__tests__/config.test.d.ts.map +1 -0
- package/dist/__tests__/config.test.js +79 -0
- package/dist/__tests__/config.test.js.map +1 -0
- package/dist/__tests__/decompile.test.d.ts +2 -0
- package/dist/__tests__/decompile.test.d.ts.map +1 -0
- package/dist/__tests__/decompile.test.js +102 -0
- package/dist/__tests__/decompile.test.js.map +1 -0
- package/dist/__tests__/hash.test.d.ts +2 -0
- package/dist/__tests__/hash.test.d.ts.map +1 -0
- package/dist/__tests__/hash.test.js +44 -0
- package/dist/__tests__/hash.test.js.map +1 -0
- package/dist/__tests__/integration.test.d.ts +2 -0
- package/dist/__tests__/integration.test.d.ts.map +1 -0
- package/dist/__tests__/integration.test.js +277 -0
- package/dist/__tests__/integration.test.js.map +1 -0
- package/dist/__tests__/skill-renderer.test.d.ts +2 -0
- package/dist/__tests__/skill-renderer.test.d.ts.map +1 -0
- package/dist/__tests__/skill-renderer.test.js +68 -0
- package/dist/__tests__/skill-renderer.test.js.map +1 -0
- package/dist/commands/add.d.ts.map +1 -1
- package/dist/commands/add.js +6 -3
- package/dist/commands/add.js.map +1 -1
- package/dist/commands/agents.d.ts +2 -0
- package/dist/commands/agents.d.ts.map +1 -0
- package/dist/commands/agents.js +93 -0
- package/dist/commands/agents.js.map +1 -0
- package/dist/commands/build.d.ts.map +1 -1
- package/dist/commands/build.js +96 -21
- package/dist/commands/build.js.map +1 -1
- package/dist/commands/chat.d.ts.map +1 -1
- package/dist/commands/chat.js +110 -11
- package/dist/commands/chat.js.map +1 -1
- package/dist/commands/diff.d.ts +1 -1
- package/dist/commands/diff.d.ts.map +1 -1
- package/dist/commands/diff.js +402 -16
- package/dist/commands/diff.js.map +1 -1
- package/dist/commands/export.js +1 -1
- package/dist/commands/export.js.map +1 -1
- package/dist/commands/init.d.ts +1 -0
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +138 -0
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/link.d.ts +1 -0
- package/dist/commands/link.d.ts.map +1 -1
- package/dist/commands/link.js +77 -13
- package/dist/commands/link.js.map +1 -1
- package/dist/commands/login.d.ts.map +1 -1
- package/dist/commands/login.js +48 -27
- package/dist/commands/login.js.map +1 -1
- package/dist/commands/logs.d.ts +7 -0
- package/dist/commands/logs.d.ts.map +1 -0
- package/dist/commands/logs.js +115 -0
- package/dist/commands/logs.js.map +1 -0
- package/dist/commands/mcp.d.ts +6 -0
- package/dist/commands/mcp.d.ts.map +1 -0
- package/dist/commands/mcp.js +258 -0
- package/dist/commands/mcp.js.map +1 -0
- package/dist/commands/preview.d.ts.map +1 -1
- package/dist/commands/preview.js +191 -7
- package/dist/commands/preview.js.map +1 -1
- package/dist/commands/private.d.ts.map +1 -1
- package/dist/commands/private.js +248 -0
- package/dist/commands/private.js.map +1 -1
- package/dist/commands/prompts.d.ts +12 -0
- package/dist/commands/prompts.d.ts.map +1 -0
- package/dist/commands/prompts.js +245 -0
- package/dist/commands/prompts.js.map +1 -0
- package/dist/commands/publish.d.ts.map +1 -1
- package/dist/commands/publish.js +69 -6
- package/dist/commands/publish.js.map +1 -1
- package/dist/commands/pull.d.ts.map +1 -1
- package/dist/commands/pull.js +110 -137
- package/dist/commands/pull.js.map +1 -1
- package/dist/commands/push.d.ts +1 -0
- package/dist/commands/push.d.ts.map +1 -1
- package/dist/commands/push.js +236 -38
- package/dist/commands/push.js.map +1 -1
- package/dist/commands/register.d.ts.map +1 -1
- package/dist/commands/register.js +40 -84
- package/dist/commands/register.js.map +1 -1
- package/dist/commands/skill.d.ts +8 -0
- package/dist/commands/skill.d.ts.map +1 -0
- package/dist/commands/skill.js +1226 -0
- package/dist/commands/skill.js.map +1 -0
- package/dist/commands/status.d.ts.map +1 -1
- package/dist/commands/status.js +221 -69
- package/dist/commands/status.js.map +1 -1
- package/dist/commands/sync.d.ts.map +1 -1
- package/dist/commands/sync.js +12 -0
- package/dist/commands/sync.js.map +1 -1
- package/dist/commands/whoami.d.ts.map +1 -1
- package/dist/commands/whoami.js +62 -33
- package/dist/commands/whoami.js.map +1 -1
- package/dist/index.js +187 -6
- package/dist/index.js.map +1 -1
- package/dist/lib/api.d.ts +169 -12
- package/dist/lib/api.d.ts.map +1 -1
- package/dist/lib/api.js +183 -33
- package/dist/lib/api.js.map +1 -1
- package/dist/lib/ascii.d.ts.map +1 -1
- package/dist/lib/ascii.js +20 -48
- package/dist/lib/ascii.js.map +1 -1
- package/dist/lib/compiler.d.ts +16 -33
- package/dist/lib/compiler.d.ts.map +1 -1
- package/dist/lib/compiler.js +499 -84
- package/dist/lib/compiler.js.map +1 -1
- package/dist/lib/config.d.ts +27 -0
- package/dist/lib/config.d.ts.map +1 -1
- package/dist/lib/config.js +50 -0
- package/dist/lib/config.js.map +1 -1
- package/dist/lib/decompile.d.ts +21 -0
- package/dist/lib/decompile.d.ts.map +1 -0
- package/dist/lib/decompile.js +304 -0
- package/dist/lib/decompile.js.map +1 -0
- package/dist/lib/hash.d.ts +3 -0
- package/dist/lib/hash.d.ts.map +1 -0
- package/dist/lib/hash.js +31 -0
- package/dist/lib/hash.js.map +1 -0
- package/dist/lib/onboarding.d.ts +4 -4
- package/dist/lib/onboarding.d.ts.map +1 -1
- package/dist/lib/onboarding.js +228 -81
- package/dist/lib/onboarding.js.map +1 -1
- package/dist/lib/skill-catalog.d.ts +57 -0
- package/dist/lib/skill-catalog.d.ts.map +1 -0
- package/dist/lib/skill-catalog.js +245 -0
- package/dist/lib/skill-catalog.js.map +1 -0
- package/dist/lib/skill-renderer.d.ts +55 -0
- package/dist/lib/skill-renderer.d.ts.map +1 -0
- package/dist/lib/skill-renderer.js +382 -0
- package/dist/lib/skill-renderer.js.map +1 -0
- package/dist/lib/skills.d.ts +130 -0
- package/dist/lib/skills.d.ts.map +1 -0
- package/dist/lib/skills.js +876 -0
- package/dist/lib/skills.js.map +1 -0
- package/dist/lib/vault.d.ts +40 -0
- package/dist/lib/vault.d.ts.map +1 -0
- package/dist/lib/vault.js +187 -0
- package/dist/lib/vault.js.map +1 -0
- package/dist/mcp/server.d.ts +21 -0
- package/dist/mcp/server.d.ts.map +1 -0
- package/dist/mcp/server.js +1283 -0
- package/dist/mcp/server.js.map +1 -0
- package/examples/houston/directives/agent.md +13 -0
- package/examples/houston/preferences/agent.md +14 -0
- package/examples/houston/profile/about.md +15 -0
- package/examples/houston/profile/links.md +10 -0
- package/examples/houston/profile/projects.md +37 -0
- package/examples/houston/profile/values.md +9 -0
- package/examples/houston/voice/voice.md +13 -0
- package/examples/jordan/directives/agent.md +13 -0
- package/examples/jordan/preferences/agent.md +16 -0
- package/examples/jordan/profile/about.md +15 -0
- package/examples/jordan/profile/links.md +10 -0
- package/examples/jordan/profile/projects.md +29 -0
- package/examples/jordan/profile/values.md +9 -0
- package/examples/jordan/voice/voice.md +12 -0
- package/examples/priya/directives/agent.md +13 -0
- package/examples/priya/preferences/agent.md +15 -0
- package/examples/priya/profile/about.md +15 -0
- package/examples/priya/profile/links.md +9 -0
- package/examples/priya/profile/projects.md +28 -0
- package/examples/priya/profile/values.md +9 -0
- package/examples/priya/voice/voice.md +12 -0
- package/package.json +15 -6
- package/skills/claude-md-generator.md +91 -0
- package/skills/meta-improve.md +84 -0
- package/skills/proactive-context-fill.md +52 -0
- package/skills/project-context-init.md +77 -0
- package/skills/voice-sync.md +89 -0
- package/skills/you-logs.md +71 -0
package/dist/commands/build.js
CHANGED
|
@@ -42,53 +42,98 @@ const path = __importStar(require("path"));
|
|
|
42
42
|
const chalk_1 = __importDefault(require("chalk"));
|
|
43
43
|
const config_1 = require("../lib/config");
|
|
44
44
|
const compiler_1 = require("../lib/compiler");
|
|
45
|
-
const
|
|
45
|
+
const render_1 = require("../lib/render");
|
|
46
|
+
const hash_1 = require("../lib/hash");
|
|
47
|
+
const ACCENT = chalk_1.default.hex("#C46A3A");
|
|
48
|
+
const DIM = chalk_1.default.dim;
|
|
49
|
+
const BUILD_SPINNERS = [
|
|
50
|
+
"assembling your identity context",
|
|
51
|
+
"weaving your narrative thread",
|
|
52
|
+
"crystallizing who you are",
|
|
53
|
+
"forging your identity context",
|
|
54
|
+
"encoding your context mosaic",
|
|
55
|
+
"compiling your digital twin",
|
|
56
|
+
];
|
|
57
|
+
function randomBuildLabel() {
|
|
58
|
+
return BUILD_SPINNERS[Math.floor(Math.random() * BUILD_SPINNERS.length)];
|
|
59
|
+
}
|
|
46
60
|
async function buildCommand() {
|
|
47
61
|
if (!(0, config_1.localBundleExists)()) {
|
|
48
62
|
console.log("");
|
|
49
|
-
console.log(chalk_1.default.yellow(" no .youmd/ directory found"));
|
|
63
|
+
console.log(chalk_1.default.yellow(" no .youmd/ directory found."));
|
|
50
64
|
console.log("");
|
|
51
65
|
console.log(" run " + chalk_1.default.cyan("youmd init") + " to create one.");
|
|
52
66
|
console.log("");
|
|
53
67
|
return;
|
|
54
68
|
}
|
|
55
69
|
const bundleDir = (0, config_1.getLocalBundleDir)();
|
|
56
|
-
// Detect if this is the first build
|
|
70
|
+
// Detect if this is the first build
|
|
57
71
|
const isFirstBuild = !fs.existsSync(path.join(bundleDir, "manifest.json"));
|
|
72
|
+
// Check for empty profile/
|
|
73
|
+
const profileDir = path.join(bundleDir, "profile");
|
|
74
|
+
const profileFiles = fs.existsSync(profileDir)
|
|
75
|
+
? fs.readdirSync(profileDir).filter((f) => f.endsWith(".md"))
|
|
76
|
+
: [];
|
|
77
|
+
if (profileFiles.length === 0) {
|
|
78
|
+
console.log("");
|
|
79
|
+
console.log(chalk_1.default.yellow(" warning: profile/ directory is empty or missing"));
|
|
80
|
+
console.log(DIM(" run " + chalk_1.default.cyan("youmd pull") + " to fetch your profile, or add .md files to .youmd/profile/"));
|
|
81
|
+
console.log("");
|
|
82
|
+
}
|
|
58
83
|
console.log("");
|
|
59
|
-
console.log(" " + chalk_1.default.bold("you.md") +
|
|
84
|
+
console.log(" " + chalk_1.default.bold("you.md") + DIM(" -- build"));
|
|
60
85
|
console.log("");
|
|
61
|
-
//
|
|
62
|
-
const spinner = new
|
|
86
|
+
// Personality spinner
|
|
87
|
+
const spinner = new render_1.BrailleSpinner(randomBuildLabel());
|
|
63
88
|
spinner.start();
|
|
64
89
|
const result = (0, compiler_1.compileBundle)(bundleDir);
|
|
65
|
-
// Brief pause for the spinner to feel real
|
|
66
90
|
await new Promise((r) => setTimeout(r, 400));
|
|
67
91
|
spinner.stop();
|
|
68
|
-
// Print each file read
|
|
69
|
-
const
|
|
92
|
+
// Print each file read, organized by directory
|
|
93
|
+
const allDirs = ["profile", "preferences", "voice", "directives"];
|
|
94
|
+
const totalSteps = result.filesRead.length + 3;
|
|
70
95
|
let step = 0;
|
|
96
|
+
for (const dir of allDirs) {
|
|
97
|
+
const dirFiles = result.filesRead.filter((f) => f.type === dir || (dir === "preferences" && f.type === "preference") || (dir === "directives" && f.type === "directive"));
|
|
98
|
+
for (const entry of dirFiles) {
|
|
99
|
+
step++;
|
|
100
|
+
const prefix = step < totalSteps ? "\u251C\u2500\u2500" : "\u2514\u2500\u2500";
|
|
101
|
+
console.log(` ${prefix} ${DIM("read")} ${ACCENT(dir + "/")}${entry.file}`);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
// Unexpected types
|
|
71
105
|
for (const entry of result.filesRead) {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
106
|
+
if (!allDirs.includes(entry.type) && entry.type !== "preference" && entry.type !== "directive") {
|
|
107
|
+
step++;
|
|
108
|
+
const prefix = step < totalSteps ? "\u251C\u2500\u2500" : "\u2514\u2500\u2500";
|
|
109
|
+
console.log(` ${prefix} ${DIM("read")} ${ACCENT(entry.type + "/")}${entry.file}`);
|
|
110
|
+
}
|
|
76
111
|
}
|
|
77
112
|
// Compile step
|
|
78
113
|
step++;
|
|
79
|
-
console.log(` ${step < totalSteps ? "\u251C\u2500\u2500" : "\u2514\u2500\u2500"} ${
|
|
114
|
+
console.log(` ${step < totalSteps ? "\u251C\u2500\u2500" : "\u2514\u2500\u2500"} ${DIM("compile")} you.json`);
|
|
80
115
|
// Generate step
|
|
81
116
|
step++;
|
|
82
|
-
console.log(` ${step < totalSteps ? "\u251C\u2500\u2500" : "\u2514\u2500\u2500"} ${
|
|
117
|
+
console.log(` ${step < totalSteps ? "\u251C\u2500\u2500" : "\u2514\u2500\u2500"} ${DIM("generate")} you.md`);
|
|
83
118
|
// Write manifest
|
|
84
119
|
step++;
|
|
85
|
-
console.log(` \u2514\u2500\u2500 ${
|
|
120
|
+
console.log(` \u2514\u2500\u2500 ${DIM("write")} manifest.json`);
|
|
86
121
|
// Write output files
|
|
87
122
|
(0, compiler_1.writeBundle)(bundleDir, result);
|
|
88
|
-
//
|
|
89
|
-
const
|
|
90
|
-
const totalSections = result.bundle.profile.length + result.bundle.preferences.length;
|
|
123
|
+
// Compute and store the local content hash
|
|
124
|
+
const youJsonPath = path.join(bundleDir, "you.json");
|
|
91
125
|
const youMdPath = path.join(bundleDir, "you.md");
|
|
126
|
+
let localHash = "";
|
|
127
|
+
if (fs.existsSync(youJsonPath)) {
|
|
128
|
+
const youJson = JSON.parse(fs.readFileSync(youJsonPath, "utf-8"));
|
|
129
|
+
const youMdContent = fs.existsSync(youMdPath) ? fs.readFileSync(youMdPath, "utf-8") : "";
|
|
130
|
+
localHash = (0, hash_1.computeContentHash)(youJson, youMdContent);
|
|
131
|
+
const localConfig = (0, config_1.readLocalConfig)() || { version: 1, sources: [] };
|
|
132
|
+
localConfig.localContentHash = localHash;
|
|
133
|
+
(0, config_1.writeLocalConfig)(localConfig);
|
|
134
|
+
}
|
|
135
|
+
// Stats
|
|
136
|
+
const { filledSections, totalSections, version, directories } = result.stats;
|
|
92
137
|
const contentSize = fs.existsSync(youMdPath) ? fs.statSync(youMdPath).size : 0;
|
|
93
138
|
const sizeLabel = contentSize > 1024
|
|
94
139
|
? (contentSize / 1024).toFixed(1) + " KB"
|
|
@@ -96,8 +141,38 @@ async function buildCommand() {
|
|
|
96
141
|
console.log("");
|
|
97
142
|
console.log(" " + chalk_1.default.green("\u2713") +
|
|
98
143
|
" bundle compiled" +
|
|
99
|
-
|
|
100
|
-
console.log(
|
|
144
|
+
DIM(` -- v${version}`));
|
|
145
|
+
console.log(DIM(` ${result.filesRead.length} files read, ${filledSections}/${totalSections} sections filled, ${sizeLabel}`));
|
|
146
|
+
if (localHash) {
|
|
147
|
+
console.log(DIM(` content hash: ${(0, hash_1.shortHash)(localHash)}`));
|
|
148
|
+
}
|
|
149
|
+
if (directories.length > 0) {
|
|
150
|
+
console.log(DIM(` directories: ${directories.join(", ")}`));
|
|
151
|
+
}
|
|
152
|
+
// Content summary
|
|
153
|
+
const yj = result.youJson;
|
|
154
|
+
const summaryParts = [];
|
|
155
|
+
const identity = yj.identity;
|
|
156
|
+
if (identity?.name)
|
|
157
|
+
summaryParts.push(ACCENT(String(identity.name)));
|
|
158
|
+
const projects = yj.projects;
|
|
159
|
+
if (projects?.length)
|
|
160
|
+
summaryParts.push(`${projects.length} project${projects.length === 1 ? "" : "s"}`);
|
|
161
|
+
const values = yj.values;
|
|
162
|
+
if (values?.length)
|
|
163
|
+
summaryParts.push(`${values.length} value${values.length === 1 ? "" : "s"}`);
|
|
164
|
+
const links = yj.links;
|
|
165
|
+
if (links && Object.keys(links).length > 0)
|
|
166
|
+
summaryParts.push(`${Object.keys(links).length} link${Object.keys(links).length === 1 ? "" : "s"}`);
|
|
167
|
+
const voice = yj.voice;
|
|
168
|
+
if (voice?.overall)
|
|
169
|
+
summaryParts.push("voice");
|
|
170
|
+
const ad = yj.agent_directives;
|
|
171
|
+
if (ad?.communication_style || ad?.negative_prompts?.length)
|
|
172
|
+
summaryParts.push("directives");
|
|
173
|
+
if (summaryParts.length > 0) {
|
|
174
|
+
console.log(DIM(` ${summaryParts.join(DIM(" / "))}`));
|
|
175
|
+
}
|
|
101
176
|
console.log("");
|
|
102
177
|
if (isFirstBuild) {
|
|
103
178
|
const config = (0, config_1.readGlobalConfig)();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.js","sourceRoot":"","sources":["../../src/commands/build.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"build.js","sourceRoot":"","sources":["../../src/commands/build.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwBA,oCAgJC;AAxKD,uCAAyB;AACzB,2CAA6B;AAC7B,kDAA0B;AAC1B,0CAA0H;AAC1H,8CAA6D;AAC7D,0CAA+C;AAC/C,sCAA4D;AAE5D,MAAM,MAAM,GAAG,eAAK,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;AACpC,MAAM,GAAG,GAAG,eAAK,CAAC,GAAG,CAAC;AAEtB,MAAM,cAAc,GAAG;IACrB,kCAAkC;IAClC,+BAA+B;IAC/B,2BAA2B;IAC3B,+BAA+B;IAC/B,8BAA8B;IAC9B,6BAA6B;CAC9B,CAAC;AAEF,SAAS,gBAAgB;IACvB,OAAO,cAAc,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC;AAC3E,CAAC;AAEM,KAAK,UAAU,YAAY;IAChC,IAAI,CAAC,IAAA,0BAAiB,GAAE,EAAE,CAAC;QACzB,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAChB,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,MAA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,IAAI,QAAQ,CAAC;QACzC,OAAO,CAAC,GAAG,CAAC,IAAI,GAAG,eAAK,CAAC,IAAI,CAAC,kCAAkC,IAAI,GAAG,CAAC,CAAC,CAAC;QAC1E,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAClB,CAAC;AACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat.d.ts","sourceRoot":"","sources":["../../src/commands/chat.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"chat.d.ts","sourceRoot":"","sources":["../../src/commands/chat.ts"],"names":[],"mappings":"AAy9BA,wBAAsB,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC,CAmkBjD"}
|
package/dist/commands/chat.js
CHANGED
|
@@ -48,7 +48,8 @@ const api_1 = require("../lib/api");
|
|
|
48
48
|
const render_1 = require("../lib/render");
|
|
49
49
|
const onboarding_1 = require("../lib/onboarding");
|
|
50
50
|
// ─── URL Detection + Scraping (mirrors web useYouAgent) ──────────────
|
|
51
|
-
const
|
|
51
|
+
const config_2 = require("../lib/config");
|
|
52
|
+
const CONVEX_SITE_URL = (0, config_2.getConvexSiteUrl)();
|
|
52
53
|
const STREAM_URL = `${CONVEX_SITE_URL}/api/v1/chat/stream`;
|
|
53
54
|
// ─── Streaming LLM client ─────────────────────────────────────────────
|
|
54
55
|
async function streamLLM(_apiKey, messages, onToken) {
|
|
@@ -373,13 +374,40 @@ function readTextFile(filePath) {
|
|
|
373
374
|
}
|
|
374
375
|
}
|
|
375
376
|
// ─── Constants ────────────────────────────────────────────────────────
|
|
376
|
-
const CHAT_SYSTEM_PROMPT = `you are the you.md agent — the first AI that truly knows people. you help humans build and maintain their identity
|
|
377
|
+
const CHAT_SYSTEM_PROMPT = `you are the you.md agent — the first AI that truly knows people. you help humans build and maintain their identity context protocol for the agent internet — an MCP where the context is you. not a chatbot. not an assistant. an identity specialist with a personality.
|
|
377
378
|
|
|
378
379
|
--- voice ---
|
|
379
380
|
|
|
380
381
|
warm but not gushy. direct. dry humor when it lands naturally — never forced. genuinely curious about people. you find humans endlessly interesting and you're not shy about it. you sound like a sharp coworker who also happens to be a great listener.
|
|
381
382
|
|
|
382
|
-
terminal-native tone. lowercase always. no exclamation marks. no emoji. short sentences. 2-4 sentences per turn, max. one question at a time. acknowledge what someone said before moving on. reference specific things from their profile: "you mentioned X —
|
|
383
|
+
terminal-native tone. lowercase always. no exclamation marks. no emoji. short sentences. 2-4 sentences per turn, max. one question at a time. acknowledge what someone said before moving on. reference specific things from their profile: "you mentioned X — updating that now."
|
|
384
|
+
|
|
385
|
+
every response must have voice. even one-liners. "done." is fine. "noted — updating your stack." is fine. what's NOT fine is "i have updated the section for you." — that's assistant-speak.
|
|
386
|
+
|
|
387
|
+
--- action orientation ---
|
|
388
|
+
|
|
389
|
+
you ACT first, explain second. never ask permission to do obvious things.
|
|
390
|
+
- "adding that to your projects now." (not "would you like me to add that?")
|
|
391
|
+
- "updated your bio with that." (not "shall i update your bio?")
|
|
392
|
+
- "captured that in your directives." (not "do you want me to save that?")
|
|
393
|
+
- "scraping your site now." (not "i can pull your site if you'd like.")
|
|
394
|
+
|
|
395
|
+
if someone shares information, capture it. if someone shares a link, scrape it. if someone corrects something, fix it immediately. always moving forward.
|
|
396
|
+
|
|
397
|
+
--- self-awareness ---
|
|
398
|
+
|
|
399
|
+
you ARE the system. you ARE you.md. never refer to "the system" or "the platform" or "the backend" as something separate from you.
|
|
400
|
+
- "i'll pull that data" not "the system will pull that data"
|
|
401
|
+
- "i'm scraping your profile now" not "the platform handles scraping"
|
|
402
|
+
- "couldn't reach your site — i'll try again" not "the system encountered an error"
|
|
403
|
+
|
|
404
|
+
--- context maintenance ---
|
|
405
|
+
|
|
406
|
+
remember everything in this conversation. reference specific things with exact details.
|
|
407
|
+
- use their exact project names in follow-ups
|
|
408
|
+
- echo their framing back to them
|
|
409
|
+
- connect new information to old: "that tracks with what you said about [specific thing]"
|
|
410
|
+
- never ask for information they already gave you
|
|
383
411
|
|
|
384
412
|
--- relationship building ---
|
|
385
413
|
|
|
@@ -396,15 +424,37 @@ you are not a service. you are the user's identity partner. build rapport throug
|
|
|
396
424
|
- never use emoji, exclamation marks, or capitalize (except proper nouns/acronyms).
|
|
397
425
|
- never use corporate speak, marketing language, or filler words.
|
|
398
426
|
- never say "that's interesting" without saying what and why.
|
|
399
|
-
- never say "haha" or "lol" or "great question."
|
|
400
427
|
- never be a form in disguise. don't list sections and ask them to fill each one.
|
|
401
428
|
- never tell the user to edit markdown files themselves — you handle that.
|
|
402
429
|
- never generate ASCII art or text-art portraits.
|
|
403
430
|
- never make up information you don't have. be honest about gaps.
|
|
404
431
|
|
|
432
|
+
--- NEVER say (exact phrases banned) ---
|
|
433
|
+
|
|
434
|
+
- "would you like me to..." / "shall i..." / "do you want me to..." — just do it.
|
|
435
|
+
- "the system handles that" / "the platform does that" / "that's handled by the backend" — you ARE the system.
|
|
436
|
+
- "great question" — respond to the question.
|
|
437
|
+
- "haha" / "lol" / "ha" — never.
|
|
438
|
+
- "tell me more" — say "the part about [specific thing] — expand on that."
|
|
439
|
+
- "absolutely" / "certainly" / "of course" — assistant-speak. say "on it" or just do it.
|
|
440
|
+
- "is there anything else..." / "let me know if you need anything" — you're not a help desk.
|
|
441
|
+
- "sounds good" (as a full response) — add what you're doing about it.
|
|
442
|
+
- "i've updated your profile" (generic) — say WHAT you updated: "updated your bio to lead with the AI angle."
|
|
443
|
+
- "i can help you with that" — you're already helping. just do the thing.
|
|
444
|
+
- "As an AI..." — never acknowledge being an AI apologetically.
|
|
445
|
+
|
|
446
|
+
--- using memories aggressively ---
|
|
447
|
+
|
|
448
|
+
memories are your superpower. the user's identity bundle below may contain memories — facts, preferences, decisions from previous conversations. USE THEM:
|
|
449
|
+
- if they have a preference, apply it without asking.
|
|
450
|
+
- if there's a decision about a project, reference it: "you decided X last time — still the plan?"
|
|
451
|
+
- if there's a fact about their stack, weave it in naturally.
|
|
452
|
+
- if there's a goal, check progress: "you were aiming for [goal] — how's that going?"
|
|
453
|
+
- reference at least one specific memory or profile detail per response. be natural — weave, don't list.
|
|
454
|
+
|
|
405
455
|
--- structured output ---
|
|
406
456
|
|
|
407
|
-
you're maintaining their you-md/v1 identity
|
|
457
|
+
you're maintaining their you-md/v1 identity context. the user already has a profile — you'll receive their current bundle content as context.
|
|
408
458
|
|
|
409
459
|
PUBLIC sections:
|
|
410
460
|
- profile/about.md — bio, background, narrative (H1 = name, real prose)
|
|
@@ -464,7 +514,15 @@ function createRL() {
|
|
|
464
514
|
}
|
|
465
515
|
function ask(rl, question) {
|
|
466
516
|
return new Promise((resolve) => {
|
|
517
|
+
const interfaceWithState = rl;
|
|
518
|
+
if (interfaceWithState.closed || interfaceWithState.input?.readableEnded) {
|
|
519
|
+
resolve("/done");
|
|
520
|
+
return;
|
|
521
|
+
}
|
|
522
|
+
const handleClose = () => resolve("/done");
|
|
523
|
+
rl.once("close", handleClose);
|
|
467
524
|
rl.question(question, (answer) => {
|
|
525
|
+
rl.removeListener("close", handleClose);
|
|
468
526
|
resolve(answer.trim());
|
|
469
527
|
});
|
|
470
528
|
});
|
|
@@ -548,7 +606,7 @@ function showLinkInfo(bundleDir) {
|
|
|
548
606
|
console.log(" " + chalk_1.default.cyan(`https://you.md/${username}/context`));
|
|
549
607
|
console.log("");
|
|
550
608
|
console.log(" " + chalk_1.default.bold("add to your system prompt / CLAUDE.md:"));
|
|
551
|
-
console.log(chalk_1.default.dim(` "my identity
|
|
609
|
+
console.log(chalk_1.default.dim(` "my identity context: https://you.md/${username}/context"`));
|
|
552
610
|
console.log("");
|
|
553
611
|
console.log(chalk_1.default.dim(" manage links with: " + chalk_1.default.cyan("youmd link create")));
|
|
554
612
|
console.log("");
|
|
@@ -565,7 +623,7 @@ async function handlePublish(bundleDir) {
|
|
|
565
623
|
// Compile first
|
|
566
624
|
const result = (0, compiler_1.compileBundle)(bundleDir);
|
|
567
625
|
(0, compiler_1.writeBundle)(bundleDir, result);
|
|
568
|
-
console.log(chalk_1.default.dim(` compiled bundle v${result.
|
|
626
|
+
console.log(chalk_1.default.dim(` compiled bundle v${result.stats.version}`));
|
|
569
627
|
// Read bundle files
|
|
570
628
|
const youJson = JSON.parse(fs.readFileSync(path.join(bundleDir, "you.json"), "utf-8"));
|
|
571
629
|
const youMd = fs.readFileSync(path.join(bundleDir, "you.md"), "utf-8");
|
|
@@ -613,7 +671,7 @@ function handleRebuild(bundleDir) {
|
|
|
613
671
|
(0, compiler_1.writeBundle)(bundleDir, result);
|
|
614
672
|
console.log(" " +
|
|
615
673
|
chalk_1.default.green("rebuilt") +
|
|
616
|
-
chalk_1.default.dim(` -- bundle v${result.
|
|
674
|
+
chalk_1.default.dim(` -- bundle v${result.stats.version}`));
|
|
617
675
|
console.log("");
|
|
618
676
|
}
|
|
619
677
|
function showHelp() {
|
|
@@ -641,7 +699,7 @@ function showShareBlock(bundleDir) {
|
|
|
641
699
|
// fall through with null
|
|
642
700
|
}
|
|
643
701
|
}
|
|
644
|
-
const contextUrl =
|
|
702
|
+
const contextUrl = `${CONVEX_SITE_URL}/api/v1/profiles?username=${username}`;
|
|
645
703
|
const profileUrl = `https://you.md/${username}`;
|
|
646
704
|
const lines = [];
|
|
647
705
|
lines.push(`Read my identity context before we start:`);
|
|
@@ -1230,7 +1288,7 @@ async function chatCommand() {
|
|
|
1230
1288
|
}
|
|
1231
1289
|
}
|
|
1232
1290
|
catch {
|
|
1233
|
-
|
|
1291
|
+
console.log(chalk_1.default.yellow(" [private context update failed]"));
|
|
1234
1292
|
}
|
|
1235
1293
|
}
|
|
1236
1294
|
}
|
|
@@ -1244,10 +1302,51 @@ async function chatCommand() {
|
|
|
1244
1302
|
console.log(chalk_1.default.hex("#C46A3A")(` [updated project context: ${pu.file}]`));
|
|
1245
1303
|
}
|
|
1246
1304
|
catch {
|
|
1247
|
-
|
|
1305
|
+
console.log(chalk_1.default.yellow(` [project context update failed: ${pu.file}]`));
|
|
1306
|
+
}
|
|
1307
|
+
}
|
|
1308
|
+
}
|
|
1309
|
+
}
|
|
1310
|
+
// --- Context Compaction (Claude Code-style) ---
|
|
1311
|
+
const turnCount = messages.filter((m) => m.role === "user").length;
|
|
1312
|
+
if (turnCount >= 15 && messages.length > 10) {
|
|
1313
|
+
try {
|
|
1314
|
+
const compactRes = await fetch(`${CONVEX_SITE_URL}/api/v1/chat/compact`, {
|
|
1315
|
+
method: "POST",
|
|
1316
|
+
headers: { "Content-Type": "application/json" },
|
|
1317
|
+
body: JSON.stringify({
|
|
1318
|
+
sessionId: `cli-${Date.now()}`,
|
|
1319
|
+
messages,
|
|
1320
|
+
keepRecent: 8,
|
|
1321
|
+
}),
|
|
1322
|
+
signal: AbortSignal.timeout(25000),
|
|
1323
|
+
});
|
|
1324
|
+
if (compactRes.ok) {
|
|
1325
|
+
const result = await compactRes.json();
|
|
1326
|
+
if (result.compacted && result.messages) {
|
|
1327
|
+
messages.length = 0;
|
|
1328
|
+
messages.push(...result.messages);
|
|
1329
|
+
// Save extracted memories
|
|
1330
|
+
if (result.extractedMemories?.length && (0, config_1.isAuthenticated)()) {
|
|
1331
|
+
try {
|
|
1332
|
+
await (0, api_1.saveMemories)(result.extractedMemories.map((m) => ({
|
|
1333
|
+
category: m.category,
|
|
1334
|
+
content: m.content,
|
|
1335
|
+
source: "compaction",
|
|
1336
|
+
tags: m.tags,
|
|
1337
|
+
})));
|
|
1338
|
+
}
|
|
1339
|
+
catch {
|
|
1340
|
+
// non-fatal
|
|
1341
|
+
}
|
|
1342
|
+
}
|
|
1343
|
+
console.log(chalk_1.default.dim(` context compacted -- ${result.stats?.messagesRemoved} turns summarized${result.stats?.memoriesExtracted ? `, ${result.stats.memoriesExtracted} memories saved` : ""}`));
|
|
1248
1344
|
}
|
|
1249
1345
|
}
|
|
1250
1346
|
}
|
|
1347
|
+
catch {
|
|
1348
|
+
// non-fatal
|
|
1349
|
+
}
|
|
1251
1350
|
}
|
|
1252
1351
|
printAgentMessage(parsed.display);
|
|
1253
1352
|
}
|