intentional-cognition-os 1.2.3 → 1.2.4

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/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## [v1.2.4] - 2026-05-22
4
+
5
+ - fix(compiler): analyzeQuestion strict-then-broad + possessive normalization (closes fmo) (#81) (50a0053)
6
+
7
+
3
8
  ## [v1.2.3] - 2026-05-22
4
9
 
5
10
  - fix(cli,plugin): ask --json + run.sh orchestrator + first real dog-food run (P1 bug filed) (#80) (0fb8b00)
package/README.md CHANGED
@@ -152,7 +152,7 @@ Global flags on every command: `--workspace <path>`, `--json`, `--verbose`, `--q
152
152
 
153
153
  ## Status
154
154
 
155
- **v1.0.5 — stable.** 1.2.3 tests passing across 5 packages. Used daily by the author. Public release on npm.
155
+ **v1.0.5 — stable.** 1.2.4 tests passing across 5 packages. Used daily by the author. Public release on npm.
156
156
 
157
157
  - **Stable**: all 14 commands, the compilation passes, ask + research + recall + render + promote, the audit chain.
158
158
  - **In progress**: post-v1 coverage uplift on compiler + cli packages; mutation-testing baseline.
package/dist/index.js CHANGED
@@ -8394,29 +8394,46 @@ var STOP_WORDS2 = /* @__PURE__ */ new Set([
8394
8394
  "give",
8395
8395
  "show"
8396
8396
  ]);
8397
+ function extractTokens(question) {
8398
+ const noPossessives = question.replace(/[‘’']s\b/g, "");
8399
+ const spaced = noPossessives.replace(/[^\w\s]/g, " ").toLowerCase();
8400
+ return spaced.split(/\s+/).filter((t) => t.length >= 2 && !STOP_WORDS2.has(t));
8401
+ }
8397
8402
  function buildFtsQuery(question) {
8398
- const cleaned = question.replace(/[-"*()^?!]/g, " ").toLowerCase();
8399
- const tokens = cleaned.split(/\s+/).map((t) => t.replace(/[^\w]/g, "")).filter((t) => t.length >= 2 && !STOP_WORDS2.has(t));
8403
+ const tokens = extractTokens(question);
8400
8404
  if (tokens.length === 0) {
8401
8405
  return null;
8402
8406
  }
8403
- return tokens.join(" ");
8407
+ const quoted = tokens.map((t) => `"${t}"`);
8408
+ return {
8409
+ strict: quoted.join(" "),
8410
+ // implicit AND
8411
+ broad: quoted.join(" OR ")
8412
+ };
8404
8413
  }
8405
8414
  function analyzeQuestion(db, _workspacePath, question) {
8406
8415
  const ftsQuery = buildFtsQuery(question);
8407
8416
  if (ftsQuery === null) {
8408
8417
  return err(new Error("Question contains no searchable terms after stop-word removal"));
8409
8418
  }
8410
- const searchResult = searchPages(db, ftsQuery, 10);
8411
- if (!searchResult.ok) {
8412
- return err(new Error(`Search failed: ${searchResult.error.message}`));
8419
+ const strictResult = searchPages(db, ftsQuery.strict, 10);
8420
+ if (!strictResult.ok) {
8421
+ return err(new Error(`Search failed: ${strictResult.error.message}`));
8422
+ }
8423
+ let relevantPages = strictResult.value;
8424
+ if (relevantPages.length === 0 && ftsQuery.strict !== ftsQuery.broad) {
8425
+ const broadResult = searchPages(db, ftsQuery.broad, 10);
8426
+ if (!broadResult.ok) {
8427
+ return err(new Error(`Search failed: ${broadResult.error.message}`));
8428
+ }
8429
+ relevantPages = broadResult.value;
8413
8430
  }
8414
8431
  const type = classifyQuestion(question);
8415
8432
  const suggestResearch = detectComplexity(question);
8416
8433
  return ok({
8417
8434
  originalQuestion: question,
8418
8435
  type,
8419
- relevantPages: searchResult.value,
8436
+ relevantPages,
8420
8437
  suggestResearch
8421
8438
  });
8422
8439
  }