hypomnema 1.2.1 → 1.3.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 (38) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/commands/crystallize.md +23 -6
  4. package/commands/feedback.md +1 -1
  5. package/docs/CONTRIBUTING.md +96 -11
  6. package/hooks/hypo-auto-commit.mjs +3 -3
  7. package/hooks/hypo-auto-minimal-crystallize.mjs +8 -3
  8. package/hooks/hypo-cwd-change.mjs +2 -2
  9. package/hooks/hypo-first-prompt.mjs +1 -1
  10. package/hooks/hypo-personal-check.mjs +57 -7
  11. package/hooks/hypo-session-start.mjs +51 -4
  12. package/hooks/hypo-shared.mjs +137 -12
  13. package/hooks/version-check.mjs +204 -6
  14. package/package.json +5 -2
  15. package/scripts/bump-version.mjs +9 -3
  16. package/scripts/check-bilingual.mjs +115 -0
  17. package/scripts/crystallize.mjs +124 -15
  18. package/scripts/doctor.mjs +45 -9
  19. package/scripts/feedback-sync.mjs +44 -15
  20. package/scripts/feedback.mjs +5 -5
  21. package/scripts/fix-status-verify.mjs +256 -0
  22. package/scripts/init.mjs +45 -4
  23. package/scripts/install-git-hooks.mjs +258 -0
  24. package/scripts/lib/adr-corpus.mjs +79 -0
  25. package/scripts/lib/check-bilingual.mjs +141 -0
  26. package/scripts/lib/extensions.mjs +3 -3
  27. package/scripts/lib/feedback-scope.mjs +21 -0
  28. package/scripts/lib/fix-manifest.mjs +109 -0
  29. package/scripts/lib/fix-status-verify.mjs +438 -0
  30. package/scripts/lib/pre-commit-format.mjs +251 -0
  31. package/scripts/lib/project-create.mjs +2 -2
  32. package/scripts/lint.mjs +48 -8
  33. package/scripts/pre-commit-format.mjs +198 -0
  34. package/scripts/smoke-pack.mjs +16 -0
  35. package/scripts/upgrade.mjs +55 -23
  36. package/skills/crystallize/SKILL.md +13 -2
  37. package/templates/hypo-config.md +1 -1
  38. package/templates/hypo-guide.md +4 -0
@@ -0,0 +1,141 @@
1
+ /**
2
+ * lib/check-bilingual.mjs — pure validators for the bilingual release-doc rule.
3
+ *
4
+ * Rule source: CLAUDE.md learned_behaviors release-doc-bilingual (2026-05-24).
5
+ * Every Hypomnema OSS ship must carry an English body PLUS a Korean summary
6
+ * block in both the CHANGELOG section and the git tag annotation. This module
7
+ * exports the parsing/validation primitives; the CLI wrapper in
8
+ * scripts/check-bilingual.mjs handles I/O and exit codes.
9
+ *
10
+ * Scope (deliberate): this gate only enforces the KOREAN half. The English
11
+ * half has been historically present in every ship — the rule exists because
12
+ * the Korean half is what gets silently dropped under time pressure (see
13
+ * release-doc-bilingual feedback page). A tag body of "---" + Korean with an
14
+ * empty English section would technically pass these validators, but that's
15
+ * acceptable because such a body is not a realistic failure mode for a
16
+ * maintainer who already wrote the English release notes. If "English missing"
17
+ * ever becomes a real regression vector, add an English-half threshold.
18
+ *
19
+ * Why pure functions: lets tests/runner.mjs construct synthetic CHANGELOG /
20
+ * tag-body strings without touching real git or real CHANGELOG.md.
21
+ */
22
+
23
+ // AC00–D7A3 covers all precomposed Hangul syllables. We NFC-normalize the
24
+ // input before counting so jamo-only inputs (decomposed) still match after
25
+ // composition.
26
+ export const HANGUL_RE = /[가-힣]/g;
27
+ export const HANGUL_BODY_THRESHOLD = 10;
28
+
29
+ export function countHangul(text) {
30
+ return (text.normalize('NFC').match(HANGUL_RE) || []).length;
31
+ }
32
+
33
+ export function escapeRegex(s) {
34
+ return s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
35
+ }
36
+
37
+ /**
38
+ * Validate that CHANGELOG.md content has a "## [<version>]" section containing
39
+ * a "### 한글 요약" sub-section with >= HANGUL_BODY_THRESHOLD Hangul chars.
40
+ *
41
+ * @param {string} content CHANGELOG.md raw content (CRLF tolerated).
42
+ * @param {string} version Semver string to look up (e.g. "1.2.1").
43
+ * @returns {{ok: true, hangulCount: number} | {ok: false, reason: string}}
44
+ */
45
+ export function validateChangelog(content, version) {
46
+ if (!version) return { ok: false, reason: 'no version supplied' };
47
+ const lines = content.replace(/\r\n/g, '\n').split('\n');
48
+ const versionEsc = escapeRegex(version);
49
+ // Anchor closing bracket so 1.2.1 does NOT match the prefix of 1.2.10.
50
+ // Allow trailing " - YYYY-MM-DD" or nothing.
51
+ const sectionRe = new RegExp(`^## \\[${versionEsc}\\](\\s.*)?$`);
52
+
53
+ const startIndices = [];
54
+ for (let i = 0; i < lines.length; i++) {
55
+ if (sectionRe.test(lines[i])) startIndices.push(i);
56
+ }
57
+ if (startIndices.length === 0) {
58
+ return { ok: false, reason: `no "## [${version}]" section in CHANGELOG.md` };
59
+ }
60
+ if (startIndices.length > 1) {
61
+ return {
62
+ ok: false,
63
+ reason: `duplicate "## [${version}]" sections (${startIndices.length}) in CHANGELOG.md`,
64
+ };
65
+ }
66
+
67
+ const start = startIndices[0];
68
+ let sectionEnd = lines.length;
69
+ for (let i = start + 1; i < lines.length; i++) {
70
+ if (/^## /.test(lines[i])) {
71
+ sectionEnd = i;
72
+ break;
73
+ }
74
+ }
75
+ const sectionLines = lines.slice(start, sectionEnd);
76
+
77
+ const koreanHeadIdx = sectionLines.findIndex((l) => l.trim() === '### 한글 요약');
78
+ if (koreanHeadIdx === -1) {
79
+ return { ok: false, reason: `section [${version}] missing "### 한글 요약" sub-section` };
80
+ }
81
+
82
+ // Bound the Korean block: stop at the next H2 OR H3. CHANGELOG.md has
83
+ // sibling H3s like "### Internal", "### Fixed" — Hangul in those sections
84
+ // does not count toward the "### 한글 요약" requirement.
85
+ let koreanEnd = sectionLines.length;
86
+ for (let i = koreanHeadIdx + 1; i < sectionLines.length; i++) {
87
+ if (/^(##|###) /.test(sectionLines[i])) {
88
+ koreanEnd = i;
89
+ break;
90
+ }
91
+ }
92
+ const body = sectionLines.slice(koreanHeadIdx + 1, koreanEnd).join('\n');
93
+ const count = countHangul(body);
94
+ if (count < HANGUL_BODY_THRESHOLD) {
95
+ return {
96
+ ok: false,
97
+ reason:
98
+ `section [${version}] "### 한글 요약" body has ${count} Hangul chars ` +
99
+ `(threshold: ${HANGUL_BODY_THRESHOLD}). Heading alone does not count — write real Korean summary.`,
100
+ };
101
+ }
102
+ return { ok: true, hangulCount: count };
103
+ }
104
+
105
+ /**
106
+ * Validate that a git tag annotation body has a "---" separator with Korean
107
+ * text after the LAST such separator. Tolerates earlier "---" markdown
108
+ * horizontal rules in the English body.
109
+ *
110
+ * @param {string} body Tag annotation body, as returned by
111
+ * `git tag -l --format='%(contents)' <ref>`.
112
+ * @returns {{ok: true, hangulCount: number} | {ok: false, reason: string}}
113
+ */
114
+ export function validateTagBody(body) {
115
+ const lines = body.replace(/\r\n/g, '\n').split('\n');
116
+ let lastSepIdx = -1;
117
+ for (let i = lines.length - 1; i >= 0; i--) {
118
+ if (lines[i].trim() === '---') {
119
+ lastSepIdx = i;
120
+ break;
121
+ }
122
+ }
123
+ if (lastSepIdx === -1) {
124
+ return {
125
+ ok: false,
126
+ reason:
127
+ 'tag annotation has no "---" separator line (expected: English body + "---" + Korean)',
128
+ };
129
+ }
130
+ const tail = lines.slice(lastSepIdx + 1).join('\n');
131
+ const count = countHangul(tail);
132
+ if (count < HANGUL_BODY_THRESHOLD) {
133
+ return {
134
+ ok: false,
135
+ reason:
136
+ `tag body after the last "---" has only ${count} Hangul chars ` +
137
+ `(threshold: ${HANGUL_BODY_THRESHOLD}). Write a real Korean summary after the separator.`,
138
+ };
139
+ }
140
+ return { ok: true, hangulCount: count };
141
+ }
@@ -80,8 +80,8 @@ function pkgRootDir(target) {
80
80
 
81
81
  /**
82
82
  * Discover sync-eligible extensions under `extDir`. Returns a per-type map plus a
83
- * `warnings` array. Applies the `.hypoignore` filter (#30), the basename
84
- * whitelist (#9), and pairs each file with its optional `<name>.manifest.json`.
83
+ * `warnings` array. Applies the `.hypoignore` filter (fix #30), the basename
84
+ * whitelist (plan §5 #9), and pairs each file with its optional `<name>.manifest.json`.
85
85
  * No-ops gracefully when extDir is absent (e.g. --from-remote clones, plan §5 #8).
86
86
  */
87
87
  export function discoverExtensions(extDir, hypoignorePatterns, hypoDir) {
@@ -364,7 +364,7 @@ export function syncExtensions({
364
364
  const discovered = discoverExtensions(extDir, patterns, hypoDir);
365
365
  result.warnings.push(...discovered.warnings);
366
366
 
367
- // E4 (#32): Codex supports hooks + commands only. If the user authored
367
+ // E4 (fix #32): Codex supports hooks + commands only. If the user authored
368
368
  // skills/agents extensions, surface a one-time notice that they are skipped
369
369
  // for this target rather than silently dropping them (plan §2 E4).
370
370
  if (target === 'codex') {
@@ -0,0 +1,21 @@
1
+ // Feedback page `scope:` field vocabulary — shared single source of truth.
2
+ //
3
+ // Consumed by:
4
+ // - scripts/lint.mjs (lint-time validation of feedback page frontmatter)
5
+ // - scripts/feedback.mjs (create-time --scope validation in /hypo:feedback)
6
+ // Keep this the ONLY definition; both consumers import it so the two validators
7
+ // never drift (ADR 0034 / OQ-34). feedback-sync.mjs matches scope by plain string
8
+ // equality (not this regex), so it is intentionally not a consumer.
9
+ //
10
+ // Accepts `global` or `project:<id>`. The `<id>` charset matches what
11
+ // deriveProjectId() (feedback-sync.mjs) emits from a cwd: `/` and `.` are both
12
+ // replaced with `-`, producing leading-dash, mixed-case ids like
13
+ // `-Users-you-Workspace-Project`. So the class allows a leading `-`, mixed case,
14
+ // and `_`/`-` — but deliberately NOT `.`:
15
+ // - deriveProjectId never emits `.` (it is replaced), so excluding it loses
16
+ // nothing for the derived path; and
17
+ // - the resolved project-id is path-joined in feedback-sync.mjs:213, so keeping
18
+ // `.` out of the vocabulary avoids ever blessing `project:.` / `project:..`.
19
+ // Known limit: a cwd containing spaces (or other path chars outside [A-Za-z0-9_-])
20
+ // still derives an id this regex rejects; pass `--project-id=<id>` for those.
21
+ export const FEEDBACK_SCOPE_RE = /^(global|project:[A-Za-z0-9_-]+)$/;
@@ -0,0 +1,109 @@
1
+ /**
2
+ * fix-manifest — evidence mapping for claimed-merged fixes (Phase 2, A-sot).
3
+ *
4
+ * ADR 0036: this module is the *evidence* SoT (fix → test + ADR-line), NOT the
5
+ * *status* SoT. "Is fix N merged?" is answered solely by the wiki spec
6
+ * (parseStatus). A manifest row says "if the spec claims N merged, here is the
7
+ * test that proves the behavior and the production-code line that proves the
8
+ * ADR's core decision shipped."
9
+ *
10
+ * Shape (ADR 0036 decision 2 — NO `status` field):
11
+ * { fixId:number, testNames:string[], adrPath:string|null, adrKeyLine:string }
12
+ *
13
+ * - testNames: MUST set-equal the `// @fix #N:` anchors in tests/runner.mjs
14
+ * (drift is an error — MANIFEST_TEST_DRIFT). Multiple anchors → multiple
15
+ * names. The NO_AUTO_TEST sentinel is the ONLY allowed lone entry; it may
16
+ * not be mixed with real test names.
17
+ * - adrPath: path (relative to the wiki root) of the ADR whose core decision
18
+ * this fix implements. `null` iff adrKeyLine is the NO_ADR sentinel.
19
+ * - adrKeyLine: a maintainer-curated literal that embodies the fix's shipped
20
+ * decision and exists verbatim in production code (scripts/ hooks/ commands/
21
+ * skills/ templates/). Verified by fixed-string grep — 0 hits is
22
+ * ADR_LINE_MISSING. The NO_ADR sentinel exempts a fix that has no ADR (small
23
+ * / doctor fixes); the test-green check still applies. NO_ADR is NOT for
24
+ * fixes that have an ADR but whose evidence lives outside the corpus.
25
+ *
26
+ * Coverage contract: every fix that is BOTH claimed-merged in the spec AND
27
+ * anchored in the runner must have exactly one row here (MANIFEST_MISSING_ROW
28
+ * is an error). Fixes anchored but not claimed (e.g. #18) are ORPHAN_ANCHOR
29
+ * warnings and need no row.
30
+ *
31
+ * Corpus note (spec §A amendment, 2026-06-07): the ADR-line grep corpus is
32
+ * scripts/ hooks/ commands/ skills/ AND templates/. templates/ ships via npm
33
+ * `files`, so prompt-driven fixes whose decision is installed as template text
34
+ * (e.g. #20 proactive close offer) are honestly verifiable there.
35
+ */
36
+
37
+ export const NO_ADR = 'NO_ADR';
38
+ export const NO_AUTO_TEST = 'NO_AUTO_TEST';
39
+
40
+ export const FIX_MANIFEST = [
41
+ {
42
+ fixId: 15,
43
+ testNames: ['all type-conditional fields present → green'],
44
+ adrPath: 'decisions/0030-hypoignore-enforce-all-injection-hooks.md',
45
+ adrKeyLine: 'isIgnored(path, HYPO_DIR, patterns)',
46
+ },
47
+ {
48
+ fixId: 17,
49
+ testNames: [
50
+ '5 mandatory memory files fresh → suppressOutput:true',
51
+ 'project hot.md not updated today → block, reason names the file',
52
+ 'open-questions.md absent/stale → still passes (conditional, not gated)',
53
+ ],
54
+ adrPath: 'decisions/0022-session-close-ux-automation.md',
55
+ adrKeyLine: 'sessionCloseFileStatus',
56
+ },
57
+ {
58
+ // Behavioral / prompt-driven: no automated test, evidence is the installed
59
+ // template prompt (templates/hypo-guide.md). Has an ADR (0022), so NOT
60
+ // NO_ADR — the adrKeyLine greps the shipped template text.
61
+ fixId: 20,
62
+ testNames: [NO_AUTO_TEST],
63
+ adrPath: 'decisions/0022-session-close-ux-automation.md',
64
+ adrKeyLine: '이 작업이 마무리되었나요? 세션을 정리(crystallize)할까요?',
65
+ },
66
+ {
67
+ fixId: 25,
68
+ testNames: [
69
+ 'replay-compact-guard-detects-slash-clear: /clear with incomplete wiki → WIKI_AUTOCLOSE',
70
+ ],
71
+ adrPath: 'decisions/0022-session-close-ux-automation.md',
72
+ adrKeyLine: '[WIKI_AUTOCLOSE]',
73
+ },
74
+ {
75
+ // Removal fix (capacity bypass deleted). The shipped evidence is the
76
+ // deliberate removal-marker comment + the negative-control test.
77
+ fixId: 26,
78
+ testNames: [
79
+ 'replay-personal-check-bypass-order: wiki-context-critical.json does NOT bypass (fix #26 negative control)',
80
+ ],
81
+ adrPath: 'decisions/0022-session-close-ux-automation.md',
82
+ adrKeyLine: 'Capacity bypass (≥90%) REMOVED — fix #26',
83
+ },
84
+ {
85
+ fixId: 27,
86
+ testNames: [
87
+ 'replay-auto-minimal-crystallize-on-incomplete-close: mutating + no marker + close-intent → block',
88
+ 'replay-auto-minimal-crystallize-on-incomplete-close: valid marker → continue (even with close-intent)',
89
+ ],
90
+ adrPath: 'decisions/0022-session-close-ux-automation.md',
91
+ adrKeyLine: 'The hook NEVER writes the marker',
92
+ },
93
+ {
94
+ // No dedicated ADR (schema-vocab tag validation); test-green only.
95
+ fixId: 36,
96
+ testNames: ['PascalCase tag → error', 'unknown tag (not in vocab) → error'],
97
+ adrPath: null,
98
+ adrKeyLine: NO_ADR,
99
+ },
100
+ {
101
+ fixId: 38,
102
+ testNames: [
103
+ 'clean-wiki payload → ok:true, new entries appended (apply dedup is exact-entry, not date-based)',
104
+ 'idempotent: re-running same payload produces no new bytes (file mtimes unchanged)',
105
+ ],
106
+ adrPath: 'decisions/0029-crystallize-session-close-depth-expansion.md',
107
+ adrKeyLine: 'exact-entry append dedup',
108
+ },
109
+ ];