sisyo 1.7.0 → 1.8.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.
Files changed (61) hide show
  1. package/LICENSE +16 -16
  2. package/README.md +167 -166
  3. package/bin/known-hashes.json +6 -1
  4. package/bin/sisyo.js +285 -285
  5. package/package.json +30 -30
  6. package/templates/.claude/rules/agents-and-tests.md +32 -24
  7. package/templates/.claude/rules/docs.md +19 -19
  8. package/templates/.claude/skills/fastapi-best-practices/ASYNC-PATTERNS.md +121 -121
  9. package/templates/.claude/skills/fastapi-best-practices/DATABASE.md +153 -153
  10. package/templates/.claude/skills/fastapi-best-practices/DEPENDENCIES.md +140 -140
  11. package/templates/.claude/skills/fastapi-best-practices/PROJECT-STRUCTURE.md +90 -90
  12. package/templates/.claude/skills/fastapi-best-practices/PYDANTIC-GUIDE.md +155 -155
  13. package/templates/.claude/skills/fastapi-best-practices/SKILL.md +123 -123
  14. package/templates/.claude/skills/g6-style/SKILL.md +125 -125
  15. package/templates/.claude/skills/g6-style/references/checks.md +58 -58
  16. package/templates/.claude/skills/g6-style/references/imagery.md +103 -103
  17. package/templates/.claude/skills/g6-style/references/motion.md +121 -121
  18. package/templates/.claude/skills/g6-style/references/sections.md +263 -263
  19. package/templates/.claude/skills/g6-style/references/tokens.md +197 -197
  20. package/templates/.claude/skills/hindsight/SKILL.md +175 -175
  21. package/templates/.claude/skills/hoang-auth/SKILL.md +188 -0
  22. package/templates/.claude/skills/html-docs/SKILL.md +207 -207
  23. package/templates/.claude/skills/i18n-multilang/SKILL.md +153 -153
  24. package/templates/.claude/skills/i18n-multilang/assets/languages.json +47 -47
  25. package/templates/.claude/skills/i18n-multilang/assets/plural-vectors.json +46 -46
  26. package/templates/.claude/skills/i18n-multilang/assets/project/README.md +17 -17
  27. package/templates/.claude/skills/i18n-multilang/assets/project/gitattributes.txt +6 -6
  28. package/templates/.claude/skills/i18n-multilang/assets/project/gitignore.txt +4 -4
  29. package/templates/.claude/skills/i18n-multilang/assets/project/glossary.json +6 -6
  30. package/templates/.claude/skills/i18n-multilang/assets/project/i18n.config.json +22 -22
  31. package/templates/.claude/skills/i18n-multilang/assets/project/locales/__source__/common.json +10 -10
  32. package/templates/.claude/skills/i18n-multilang/assets/project/notes/common.json +5 -5
  33. package/templates/.claude/skills/i18n-multilang/assets/project/style.md +20 -20
  34. package/templates/.claude/skills/i18n-multilang/references/format.md +100 -100
  35. package/templates/.claude/skills/i18n-multilang/references/languages.md +97 -97
  36. package/templates/.claude/skills/i18n-multilang/references/layout-and-versioning.md +256 -256
  37. package/templates/.claude/skills/i18n-multilang/references/numbers.md +161 -161
  38. package/templates/.claude/skills/i18n-multilang/references/platform-unity.md +142 -142
  39. package/templates/.claude/skills/i18n-multilang/references/platform-web.md +107 -107
  40. package/templates/.claude/skills/i18n-multilang/references/translation.md +143 -143
  41. package/templates/.claude/skills/i18n-multilang/references/voice.md +271 -271
  42. package/templates/.claude/skills/i18n-multilang/scripts/i18n.py +1041 -1041
  43. package/templates/.claude/skills/i18n-multilang/scripts/numwords.py +1013 -1013
  44. package/templates/.claude/skills/i18n-multilang/scripts/voice.py +478 -478
  45. package/templates/.claude/skills/neon-game-ui-ux-skill/COMPONENTS.md +490 -490
  46. package/templates/.claude/skills/neon-game-ui-ux-skill/GAMIFICATION.md +246 -246
  47. package/templates/.claude/skills/neon-game-ui-ux-skill/ICONS.md +249 -249
  48. package/templates/.claude/skills/neon-game-ui-ux-skill/LAYOUT-NAV.md +362 -362
  49. package/templates/.claude/skills/neon-game-ui-ux-skill/MOTION-A11Y.md +168 -168
  50. package/templates/.claude/skills/neon-game-ui-ux-skill/SKILL.md +137 -137
  51. package/templates/.claude/skills/neon-game-ui-ux-skill/TOKENS.md +323 -323
  52. package/templates/.claude/skills/react-page-oriented/SKILL.md +407 -407
  53. package/templates/.claude/skills/react-page-oriented/triggers.md +12 -12
  54. package/templates/.claude/skills/terraform-best-practices/SKILL.md +341 -341
  55. package/templates/.claude/skills/typesafe-jev/SKILL.md +148 -148
  56. package/templates/.claude/skills/vibe-docs/SKILL.md +242 -242
  57. package/templates/SISYO.md +37 -37
  58. package/templates/docs/99_progress/features.md +7 -7
  59. package/templates/docs/99_progress/handoff.md +19 -19
  60. package/templates/docs/99_progress/todo.md +15 -15
  61. package/templates/docs/MAP.md +26 -26
package/bin/sisyo.js CHANGED
@@ -1,285 +1,285 @@
1
- #!/usr/bin/env node
2
-
3
- const fs = require("fs");
4
- const path = require("path");
5
- const crypto = require("crypto");
6
-
7
- const RESET = "\x1b[0m";
8
- const GREEN = "\x1b[32m";
9
- const YELLOW = "\x1b[33m";
10
- const RED = "\x1b[31m";
11
- const CYAN = "\x1b[36m";
12
- const BOLD = "\x1b[1m";
13
- const DIM = "\x1b[2m";
14
-
15
- function log(msg) { console.log(msg); }
16
- function ok(msg) { log(`${GREEN}+${RESET} ${msg}`); }
17
- function up(msg) { log(`${YELLOW}~${RESET} ${msg}`); }
18
- function warn(msg) { log(`${RED}!${RESET} ${msg}`); }
19
- function info(msg) { log(`${DIM} ${msg}${RESET}`); }
20
-
21
- const PKG = require(path.join(__dirname, "..", "package.json"));
22
-
23
- // ---------------------------------------------------------------------------
24
- // Ownership model
25
- //
26
- // MANAGED (sisyo-owned) — everything under .claude/ that ships in templates/
27
- // (rules/docs.md, skills/*). Replaced on --update, but ONLY
28
- // when the local copy is byte-identical to what sisyo last
29
- // installed (tracked by hash in the manifest). A locally
30
- // edited managed file is never overwritten: the new version
31
- // is written next to it as <file>.sisyo-new instead.
32
- //
33
- // USER-OWNED — SISYO.md, CLAUDE.md, docs/**. Created once if missing,
34
- // never touched again, not even with --force.
35
- //
36
- // The manifest (.claude/sisyo.json) records the installed sisyo version and the hash
37
- // of every managed file as sisyo wrote it.
38
- // ---------------------------------------------------------------------------
39
-
40
- const MANIFEST_REL = ".claude/sisyo.json";
41
- const NEW_SUFFIX = ".sisyo-new";
42
-
43
- function toPosix(p) { return p.split(path.sep).join("/"); }
44
- function isManaged(rel) { return rel.startsWith(".claude/") && rel !== MANIFEST_REL; }
45
- // Hash with line endings normalized: git autocrlf rewrites LF <-> CRLF on checkout, and
46
- // that must not make an untouched file look "modified locally".
47
- function sha256(buf) {
48
- const text = buf.toString("utf8").replace(/\r\n/g, "\n");
49
- return crypto.createHash("sha256").update(text).digest("hex");
50
- }
51
- function hashFile(p) { return sha256(fs.readFileSync(p)); }
52
-
53
- // Hashes of every version of each managed file sisyo has ever shipped (from git history).
54
- // Lets an install that predates the manifest (< v1.6) be recognised as untouched.
55
- function readKnownHashes() {
56
- try { return require(path.join(__dirname, "known-hashes.json")); } catch { return {}; }
57
- }
58
-
59
- function readManifest(target) {
60
- const p = path.join(target, MANIFEST_REL);
61
- if (!fs.existsSync(p)) return null;
62
- try {
63
- const m = JSON.parse(fs.readFileSync(p, "utf8"));
64
- return { version: m.version || "unknown", files: m.files || {} };
65
- } catch {
66
- return null;
67
- }
68
- }
69
-
70
- function writeManifest(target, files) {
71
- const p = path.join(target, MANIFEST_REL);
72
- fs.mkdirSync(path.dirname(p), { recursive: true });
73
- const sorted = {};
74
- for (const k of Object.keys(files).sort()) sorted[k] = files[k];
75
- fs.writeFileSync(p, JSON.stringify({ version: PKG.version, files: sorted }, null, 2) + "\n");
76
- }
77
-
78
- function listTemplateFiles(dir, base = dir) {
79
- const out = [];
80
- for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
81
- const full = path.join(dir, entry.name);
82
- if (entry.isDirectory()) out.push(...listTemplateFiles(full, base));
83
- else out.push({ rel: toPosix(path.relative(base, full)), src: full });
84
- }
85
- return out;
86
- }
87
-
88
- function ensureClaudeMdImport(target, dryRun) {
89
- const claudePath = path.join(target, "CLAUDE.md");
90
- const importLine = "@SISYO.md";
91
- if (fs.existsSync(claudePath)) {
92
- const content = fs.readFileSync(claudePath, "utf8");
93
- if (!content.includes(importLine)) {
94
- if (!dryRun) fs.appendFileSync(claudePath, `\n${importLine}\n`);
95
- up("CLAUDE.md (added @SISYO.md import)");
96
- }
97
- } else {
98
- if (!dryRun) fs.writeFileSync(claudePath, `${importLine}\n`);
99
- ok("CLAUDE.md");
100
- }
101
- }
102
-
103
- function fillDates(target, onlyRels) {
104
- const today = new Date().toISOString().split("T")[0];
105
- const files = [
106
- "docs/MAP.md",
107
- "docs/99_progress/handoff.md",
108
- "docs/99_progress/todo.md",
109
- "docs/99_progress/features.md",
110
- ];
111
- for (const rel of files) {
112
- if (!onlyRels.has(rel)) continue; // never rewrite docs that already existed
113
- const p = path.join(target, rel);
114
- if (!fs.existsSync(p)) continue;
115
- const content = fs.readFileSync(p, "utf8");
116
- if (content.includes("YYYY-MM-DD")) {
117
- fs.writeFileSync(p, content.replace(/YYYY-MM-DD/g, today));
118
- }
119
- }
120
- }
121
-
122
- function ensureGitignore(target, dryRun) {
123
- const gitignorePath = path.join(target, ".gitignore");
124
- if (!fs.existsSync(gitignorePath)) return;
125
- const gitignore = fs.readFileSync(gitignorePath, "utf8");
126
- const lines = [];
127
- if (!gitignore.includes("CLAUDE.local.md")) lines.push("CLAUDE.local.md", ".claude/settings.local.json");
128
- if (!gitignore.includes(NEW_SUFFIX)) lines.push(`*${NEW_SUFFIX}`);
129
- if (lines.length === 0) return;
130
- if (!dryRun) fs.appendFileSync(gitignorePath, "\n# Claude Code local\n" + lines.join("\n") + "\n");
131
- ok(".gitignore updated");
132
- }
133
-
134
- function main() {
135
- const args = process.argv.slice(2);
136
- const updateMode = args.includes("--update");
137
- const force = args.includes("--force");
138
- const dryRun = args.includes("--dry-run");
139
- const targetDir = args.find(a => !a.startsWith("-")) || ".";
140
- const target = path.resolve(targetDir);
141
- const templatesDir = path.join(__dirname, "..", "templates");
142
-
143
- log("");
144
- if (updateMode) {
145
- log(`${BOLD}${CYAN}sisyo${RESET} ${DIM}v${PKG.version} — updating managed files${force ? " (force)" : ""}${dryRun ? " (dry-run)" : ""}${RESET}`);
146
- } else {
147
- log(`${BOLD}${CYAN}sisyo${RESET} ${DIM}v${PKG.version} — Smart docs for Claude Code${dryRun ? " (dry-run)" : ""}${RESET}`);
148
- }
149
- log("");
150
-
151
- if (!fs.existsSync(templatesDir)) {
152
- console.error("Error: templates directory not found");
153
- process.exit(1);
154
- }
155
-
156
- const manifest = readManifest(target);
157
- const prevFiles = manifest ? manifest.files : {};
158
- const nextFiles = {};
159
- const conflicts = [];
160
- const known = readKnownHashes();
161
- const addedRels = new Set();
162
- let updated = 0, added = 0, unchanged = 0;
163
-
164
- if (updateMode && manifest) info(`installed: v${manifest.version} → v${PKG.version}`);
165
- if (updateMode && !manifest) {
166
- info("no manifest found (installed before v1.6). Files identical to an older sisyo");
167
- info("release are updated; anything else is treated as locally modified.");
168
- }
169
-
170
- const templates = listTemplateFiles(templatesDir);
171
-
172
- for (const { rel, src } of templates) {
173
- const dest = path.join(target, rel);
174
- const managed = isManaged(rel);
175
- const srcBuf = fs.readFileSync(src);
176
- const srcHash = sha256(srcBuf);
177
-
178
- if (!fs.existsSync(dest)) {
179
- if (!dryRun) {
180
- fs.mkdirSync(path.dirname(dest), { recursive: true });
181
- fs.writeFileSync(dest, srcBuf);
182
- }
183
- if (managed) nextFiles[rel] = srcHash;
184
- ok(rel);
185
- addedRels.add(rel);
186
- added++;
187
- continue;
188
- }
189
-
190
- if (!managed) {
191
- info(`skip ${rel} (yours)`);
192
- continue;
193
- }
194
-
195
- const curHash = hashFile(dest);
196
- const newPath = dest + NEW_SUFFIX;
197
-
198
- if (curHash === srcHash) {
199
- nextFiles[rel] = srcHash;
200
- unchanged++;
201
- if (fs.existsSync(newPath) && !dryRun) fs.unlinkSync(newPath); // resolved by hand
202
- continue;
203
- }
204
-
205
- if (!updateMode) {
206
- info(`skip ${rel} (exists — run with --update)`);
207
- nextFiles[rel] = prevFiles[rel] || curHash;
208
- continue;
209
- }
210
-
211
- // Untouched = identical to what the manifest says sisyo installed, or (no manifest
212
- // entry, i.e. installed before v1.6) identical to some version sisyo once shipped.
213
- const pristine = prevFiles[rel] !== undefined
214
- ? prevFiles[rel] === curHash
215
- : (known[rel] || []).includes(curHash);
216
- if (pristine || force) {
217
- if (!dryRun) {
218
- fs.writeFileSync(dest, srcBuf);
219
- if (fs.existsSync(newPath)) fs.unlinkSync(newPath);
220
- }
221
- nextFiles[rel] = srcHash;
222
- up(`${rel} (updated${force && !pristine ? ", overwrote local edits" : ""})`);
223
- updated++;
224
- continue;
225
- }
226
-
227
- // Locally modified → keep theirs, drop the new version next to it.
228
- if (!dryRun) fs.writeFileSync(newPath, srcBuf);
229
- nextFiles[rel] = prevFiles[rel] || curHash;
230
- warn(`${rel} modified locally — kept yours, new version at ${rel}${NEW_SUFFIX}`);
231
- conflicts.push(rel);
232
- }
233
-
234
- // Managed files sisyo no longer ships: remove only if still pristine.
235
- if (updateMode) {
236
- const shipped = new Set(templates.map(t => t.rel));
237
- for (const rel of Object.keys(prevFiles)) {
238
- if (shipped.has(rel)) continue;
239
- const dest = path.join(target, rel);
240
- if (!fs.existsSync(dest)) continue;
241
- if (hashFile(dest) === prevFiles[rel]) {
242
- if (!dryRun) {
243
- fs.unlinkSync(dest);
244
- try { fs.rmdirSync(path.dirname(dest)); } catch { /* not empty — keep */ }
245
- }
246
- up(`${rel} (removed — no longer shipped)`);
247
- } else {
248
- warn(`${rel} no longer shipped by sisyo but modified locally — left in place`);
249
- nextFiles[rel] = prevFiles[rel];
250
- }
251
- }
252
- }
253
-
254
- ensureClaudeMdImport(target, dryRun);
255
- if (!dryRun) fillDates(target, addedRels);
256
- ensureGitignore(target, dryRun);
257
- if (!dryRun) writeManifest(target, nextFiles);
258
-
259
- log("");
260
- if (dryRun) {
261
- log(`${BOLD}Dry run.${RESET} +${added} added, ~${updated} updated, ${unchanged} unchanged, ${conflicts.length} conflicts. Nothing written.`);
262
- } else if (updateMode) {
263
- log(`${BOLD}Done!${RESET} +${added} added, ~${updated} updated, ${unchanged} unchanged. Your SISYO.md, CLAUDE.md and docs/ are untouched.`);
264
- } else {
265
- log(`${BOLD}Done!${RESET} Next steps:`);
266
- log("");
267
- log(` 1. Edit ${CYAN}SISYO.md${RESET} — replace [Project Name] with yours`);
268
- log(` 2. Open Claude Code and start building`);
269
- log(` 3. Docs auto-update as you work`);
270
- }
271
- if (conflicts.length > 0) {
272
- log("");
273
- log(`${RED}${conflicts.length} file(s) were modified locally and NOT overwritten:${RESET}`);
274
- for (const rel of conflicts) log(` ${rel} → ${rel}${NEW_SUFFIX}`);
275
- log("");
276
- log(` Review: git diff --no-index <file> <file>${NEW_SUFFIX}`);
277
- log(` Accept: move the ${NEW_SUFFIX} file over the original, or rerun with ${CYAN}--force${RESET}`);
278
- log(` Keep: delete the ${NEW_SUFFIX} file (sisyo will offer it again next update)`);
279
- }
280
- log("");
281
- log(`${DIM}Docs system: SISYO.md -> docs/MAP.md -> _summary.md -> detail files${RESET}`);
282
- log("");
283
- }
284
-
285
- main();
1
+ #!/usr/bin/env node
2
+
3
+ const fs = require("fs");
4
+ const path = require("path");
5
+ const crypto = require("crypto");
6
+
7
+ const RESET = "\x1b[0m";
8
+ const GREEN = "\x1b[32m";
9
+ const YELLOW = "\x1b[33m";
10
+ const RED = "\x1b[31m";
11
+ const CYAN = "\x1b[36m";
12
+ const BOLD = "\x1b[1m";
13
+ const DIM = "\x1b[2m";
14
+
15
+ function log(msg) { console.log(msg); }
16
+ function ok(msg) { log(`${GREEN}+${RESET} ${msg}`); }
17
+ function up(msg) { log(`${YELLOW}~${RESET} ${msg}`); }
18
+ function warn(msg) { log(`${RED}!${RESET} ${msg}`); }
19
+ function info(msg) { log(`${DIM} ${msg}${RESET}`); }
20
+
21
+ const PKG = require(path.join(__dirname, "..", "package.json"));
22
+
23
+ // ---------------------------------------------------------------------------
24
+ // Ownership model
25
+ //
26
+ // MANAGED (sisyo-owned) — everything under .claude/ that ships in templates/
27
+ // (rules/docs.md, skills/*). Replaced on --update, but ONLY
28
+ // when the local copy is byte-identical to what sisyo last
29
+ // installed (tracked by hash in the manifest). A locally
30
+ // edited managed file is never overwritten: the new version
31
+ // is written next to it as <file>.sisyo-new instead.
32
+ //
33
+ // USER-OWNED — SISYO.md, CLAUDE.md, docs/**. Created once if missing,
34
+ // never touched again, not even with --force.
35
+ //
36
+ // The manifest (.claude/sisyo.json) records the installed sisyo version and the hash
37
+ // of every managed file as sisyo wrote it.
38
+ // ---------------------------------------------------------------------------
39
+
40
+ const MANIFEST_REL = ".claude/sisyo.json";
41
+ const NEW_SUFFIX = ".sisyo-new";
42
+
43
+ function toPosix(p) { return p.split(path.sep).join("/"); }
44
+ function isManaged(rel) { return rel.startsWith(".claude/") && rel !== MANIFEST_REL; }
45
+ // Hash with line endings normalized: git autocrlf rewrites LF <-> CRLF on checkout, and
46
+ // that must not make an untouched file look "modified locally".
47
+ function sha256(buf) {
48
+ const text = buf.toString("utf8").replace(/\r\n/g, "\n");
49
+ return crypto.createHash("sha256").update(text).digest("hex");
50
+ }
51
+ function hashFile(p) { return sha256(fs.readFileSync(p)); }
52
+
53
+ // Hashes of every version of each managed file sisyo has ever shipped (from git history).
54
+ // Lets an install that predates the manifest (< v1.6) be recognised as untouched.
55
+ function readKnownHashes() {
56
+ try { return require(path.join(__dirname, "known-hashes.json")); } catch { return {}; }
57
+ }
58
+
59
+ function readManifest(target) {
60
+ const p = path.join(target, MANIFEST_REL);
61
+ if (!fs.existsSync(p)) return null;
62
+ try {
63
+ const m = JSON.parse(fs.readFileSync(p, "utf8"));
64
+ return { version: m.version || "unknown", files: m.files || {} };
65
+ } catch {
66
+ return null;
67
+ }
68
+ }
69
+
70
+ function writeManifest(target, files) {
71
+ const p = path.join(target, MANIFEST_REL);
72
+ fs.mkdirSync(path.dirname(p), { recursive: true });
73
+ const sorted = {};
74
+ for (const k of Object.keys(files).sort()) sorted[k] = files[k];
75
+ fs.writeFileSync(p, JSON.stringify({ version: PKG.version, files: sorted }, null, 2) + "\n");
76
+ }
77
+
78
+ function listTemplateFiles(dir, base = dir) {
79
+ const out = [];
80
+ for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
81
+ const full = path.join(dir, entry.name);
82
+ if (entry.isDirectory()) out.push(...listTemplateFiles(full, base));
83
+ else out.push({ rel: toPosix(path.relative(base, full)), src: full });
84
+ }
85
+ return out;
86
+ }
87
+
88
+ function ensureClaudeMdImport(target, dryRun) {
89
+ const claudePath = path.join(target, "CLAUDE.md");
90
+ const importLine = "@SISYO.md";
91
+ if (fs.existsSync(claudePath)) {
92
+ const content = fs.readFileSync(claudePath, "utf8");
93
+ if (!content.includes(importLine)) {
94
+ if (!dryRun) fs.appendFileSync(claudePath, `\n${importLine}\n`);
95
+ up("CLAUDE.md (added @SISYO.md import)");
96
+ }
97
+ } else {
98
+ if (!dryRun) fs.writeFileSync(claudePath, `${importLine}\n`);
99
+ ok("CLAUDE.md");
100
+ }
101
+ }
102
+
103
+ function fillDates(target, onlyRels) {
104
+ const today = new Date().toISOString().split("T")[0];
105
+ const files = [
106
+ "docs/MAP.md",
107
+ "docs/99_progress/handoff.md",
108
+ "docs/99_progress/todo.md",
109
+ "docs/99_progress/features.md",
110
+ ];
111
+ for (const rel of files) {
112
+ if (!onlyRels.has(rel)) continue; // never rewrite docs that already existed
113
+ const p = path.join(target, rel);
114
+ if (!fs.existsSync(p)) continue;
115
+ const content = fs.readFileSync(p, "utf8");
116
+ if (content.includes("YYYY-MM-DD")) {
117
+ fs.writeFileSync(p, content.replace(/YYYY-MM-DD/g, today));
118
+ }
119
+ }
120
+ }
121
+
122
+ function ensureGitignore(target, dryRun) {
123
+ const gitignorePath = path.join(target, ".gitignore");
124
+ if (!fs.existsSync(gitignorePath)) return;
125
+ const gitignore = fs.readFileSync(gitignorePath, "utf8");
126
+ const lines = [];
127
+ if (!gitignore.includes("CLAUDE.local.md")) lines.push("CLAUDE.local.md", ".claude/settings.local.json");
128
+ if (!gitignore.includes(NEW_SUFFIX)) lines.push(`*${NEW_SUFFIX}`);
129
+ if (lines.length === 0) return;
130
+ if (!dryRun) fs.appendFileSync(gitignorePath, "\n# Claude Code local\n" + lines.join("\n") + "\n");
131
+ ok(".gitignore updated");
132
+ }
133
+
134
+ function main() {
135
+ const args = process.argv.slice(2);
136
+ const updateMode = args.includes("--update");
137
+ const force = args.includes("--force");
138
+ const dryRun = args.includes("--dry-run");
139
+ const targetDir = args.find(a => !a.startsWith("-")) || ".";
140
+ const target = path.resolve(targetDir);
141
+ const templatesDir = path.join(__dirname, "..", "templates");
142
+
143
+ log("");
144
+ if (updateMode) {
145
+ log(`${BOLD}${CYAN}sisyo${RESET} ${DIM}v${PKG.version} — updating managed files${force ? " (force)" : ""}${dryRun ? " (dry-run)" : ""}${RESET}`);
146
+ } else {
147
+ log(`${BOLD}${CYAN}sisyo${RESET} ${DIM}v${PKG.version} — Smart docs for Claude Code${dryRun ? " (dry-run)" : ""}${RESET}`);
148
+ }
149
+ log("");
150
+
151
+ if (!fs.existsSync(templatesDir)) {
152
+ console.error("Error: templates directory not found");
153
+ process.exit(1);
154
+ }
155
+
156
+ const manifest = readManifest(target);
157
+ const prevFiles = manifest ? manifest.files : {};
158
+ const nextFiles = {};
159
+ const conflicts = [];
160
+ const known = readKnownHashes();
161
+ const addedRels = new Set();
162
+ let updated = 0, added = 0, unchanged = 0;
163
+
164
+ if (updateMode && manifest) info(`installed: v${manifest.version} → v${PKG.version}`);
165
+ if (updateMode && !manifest) {
166
+ info("no manifest found (installed before v1.6). Files identical to an older sisyo");
167
+ info("release are updated; anything else is treated as locally modified.");
168
+ }
169
+
170
+ const templates = listTemplateFiles(templatesDir);
171
+
172
+ for (const { rel, src } of templates) {
173
+ const dest = path.join(target, rel);
174
+ const managed = isManaged(rel);
175
+ const srcBuf = fs.readFileSync(src);
176
+ const srcHash = sha256(srcBuf);
177
+
178
+ if (!fs.existsSync(dest)) {
179
+ if (!dryRun) {
180
+ fs.mkdirSync(path.dirname(dest), { recursive: true });
181
+ fs.writeFileSync(dest, srcBuf);
182
+ }
183
+ if (managed) nextFiles[rel] = srcHash;
184
+ ok(rel);
185
+ addedRels.add(rel);
186
+ added++;
187
+ continue;
188
+ }
189
+
190
+ if (!managed) {
191
+ info(`skip ${rel} (yours)`);
192
+ continue;
193
+ }
194
+
195
+ const curHash = hashFile(dest);
196
+ const newPath = dest + NEW_SUFFIX;
197
+
198
+ if (curHash === srcHash) {
199
+ nextFiles[rel] = srcHash;
200
+ unchanged++;
201
+ if (fs.existsSync(newPath) && !dryRun) fs.unlinkSync(newPath); // resolved by hand
202
+ continue;
203
+ }
204
+
205
+ if (!updateMode) {
206
+ info(`skip ${rel} (exists — run with --update)`);
207
+ nextFiles[rel] = prevFiles[rel] || curHash;
208
+ continue;
209
+ }
210
+
211
+ // Untouched = identical to what the manifest says sisyo installed, or (no manifest
212
+ // entry, i.e. installed before v1.6) identical to some version sisyo once shipped.
213
+ const pristine = prevFiles[rel] !== undefined
214
+ ? prevFiles[rel] === curHash
215
+ : (known[rel] || []).includes(curHash);
216
+ if (pristine || force) {
217
+ if (!dryRun) {
218
+ fs.writeFileSync(dest, srcBuf);
219
+ if (fs.existsSync(newPath)) fs.unlinkSync(newPath);
220
+ }
221
+ nextFiles[rel] = srcHash;
222
+ up(`${rel} (updated${force && !pristine ? ", overwrote local edits" : ""})`);
223
+ updated++;
224
+ continue;
225
+ }
226
+
227
+ // Locally modified → keep theirs, drop the new version next to it.
228
+ if (!dryRun) fs.writeFileSync(newPath, srcBuf);
229
+ nextFiles[rel] = prevFiles[rel] || curHash;
230
+ warn(`${rel} modified locally — kept yours, new version at ${rel}${NEW_SUFFIX}`);
231
+ conflicts.push(rel);
232
+ }
233
+
234
+ // Managed files sisyo no longer ships: remove only if still pristine.
235
+ if (updateMode) {
236
+ const shipped = new Set(templates.map(t => t.rel));
237
+ for (const rel of Object.keys(prevFiles)) {
238
+ if (shipped.has(rel)) continue;
239
+ const dest = path.join(target, rel);
240
+ if (!fs.existsSync(dest)) continue;
241
+ if (hashFile(dest) === prevFiles[rel]) {
242
+ if (!dryRun) {
243
+ fs.unlinkSync(dest);
244
+ try { fs.rmdirSync(path.dirname(dest)); } catch { /* not empty — keep */ }
245
+ }
246
+ up(`${rel} (removed — no longer shipped)`);
247
+ } else {
248
+ warn(`${rel} no longer shipped by sisyo but modified locally — left in place`);
249
+ nextFiles[rel] = prevFiles[rel];
250
+ }
251
+ }
252
+ }
253
+
254
+ ensureClaudeMdImport(target, dryRun);
255
+ if (!dryRun) fillDates(target, addedRels);
256
+ ensureGitignore(target, dryRun);
257
+ if (!dryRun) writeManifest(target, nextFiles);
258
+
259
+ log("");
260
+ if (dryRun) {
261
+ log(`${BOLD}Dry run.${RESET} +${added} added, ~${updated} updated, ${unchanged} unchanged, ${conflicts.length} conflicts. Nothing written.`);
262
+ } else if (updateMode) {
263
+ log(`${BOLD}Done!${RESET} +${added} added, ~${updated} updated, ${unchanged} unchanged. Your SISYO.md, CLAUDE.md and docs/ are untouched.`);
264
+ } else {
265
+ log(`${BOLD}Done!${RESET} Next steps:`);
266
+ log("");
267
+ log(` 1. Edit ${CYAN}SISYO.md${RESET} — replace [Project Name] with yours`);
268
+ log(` 2. Open Claude Code and start building`);
269
+ log(` 3. Docs auto-update as you work`);
270
+ }
271
+ if (conflicts.length > 0) {
272
+ log("");
273
+ log(`${RED}${conflicts.length} file(s) were modified locally and NOT overwritten:${RESET}`);
274
+ for (const rel of conflicts) log(` ${rel} → ${rel}${NEW_SUFFIX}`);
275
+ log("");
276
+ log(` Review: git diff --no-index <file> <file>${NEW_SUFFIX}`);
277
+ log(` Accept: move the ${NEW_SUFFIX} file over the original, or rerun with ${CYAN}--force${RESET}`);
278
+ log(` Keep: delete the ${NEW_SUFFIX} file (sisyo will offer it again next update)`);
279
+ }
280
+ log("");
281
+ log(`${DIM}Docs system: SISYO.md -> docs/MAP.md -> _summary.md -> detail files${RESET}`);
282
+ log("");
283
+ }
284
+
285
+ main();
package/package.json CHANGED
@@ -1,30 +1,30 @@
1
- {
2
- "name": "sisyo",
3
- "version": "1.7.0",
4
- "description": "Smart documentation system for vibe coding with Claude Code. Token-efficient MAP.md routing.",
5
- "bin": {
6
- "sisyo": "./bin/sisyo.js"
7
- },
8
- "scripts": {
9
- "hashes": "node scripts/gen-known-hashes.js",
10
- "prepublishOnly": "node scripts/gen-known-hashes.js"
11
- },
12
- "files": [
13
- "bin/",
14
- "templates/"
15
- ],
16
- "keywords": [
17
- "claude-code",
18
- "vibe-coding",
19
- "documentation",
20
- "ai-coding",
21
- "developer-tools",
22
- "sisyo"
23
- ],
24
- "author": "HoangThang <blog.thangchiba.com>",
25
- "homepage": "https://blog.thangchiba.com",
26
- "license": "MIT",
27
- "engines": {
28
- "node": ">=16"
29
- }
30
- }
1
+ {
2
+ "name": "sisyo",
3
+ "version": "1.8.0",
4
+ "description": "Smart documentation system for vibe coding with Claude Code. Token-efficient MAP.md routing.",
5
+ "bin": {
6
+ "sisyo": "./bin/sisyo.js"
7
+ },
8
+ "scripts": {
9
+ "hashes": "node scripts/gen-known-hashes.js",
10
+ "prepublishOnly": "node scripts/gen-known-hashes.js"
11
+ },
12
+ "files": [
13
+ "bin/",
14
+ "templates/"
15
+ ],
16
+ "keywords": [
17
+ "claude-code",
18
+ "vibe-coding",
19
+ "documentation",
20
+ "ai-coding",
21
+ "developer-tools",
22
+ "sisyo"
23
+ ],
24
+ "author": "HoangThang <blog.thangchiba.com>",
25
+ "homepage": "https://blog.thangchiba.com",
26
+ "license": "MIT",
27
+ "engines": {
28
+ "node": ">=16"
29
+ }
30
+ }