@ghostpaw/questlog 0.5.1 → 0.6.1

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 (41) hide show
  1. package/README.md +92 -1
  2. package/SKILL.md +293 -0
  3. package/dist/cli.js +7202 -0
  4. package/dist/database-DShQ4N46.d.cts +20 -0
  5. package/dist/database-DShQ4N46.d.ts +20 -0
  6. package/dist/index.cjs +35 -5
  7. package/dist/index.d.cts +5 -19
  8. package/dist/index.d.ts +5 -19
  9. package/dist/index.js +35 -5
  10. package/dist/mcp-server.js +5929 -0
  11. package/dist/mcp.cjs +4952 -0
  12. package/dist/mcp.d.cts +89 -0
  13. package/dist/mcp.d.ts +89 -0
  14. package/dist/mcp.js +4944 -0
  15. package/package.json +46 -9
  16. package/skills/questlog/SKILL.md +293 -0
  17. package/skills/questlog/references/archive-delete-and-prune.md +25 -0
  18. package/skills/questlog/references/choose-work-shape.md +25 -0
  19. package/skills/questlog/references/clarify-ambiguous-requests.md +24 -0
  20. package/skills/questlog/references/close-work-and-claim-outcomes.md +23 -0
  21. package/skills/questlog/references/create-concrete-quest.md +21 -0
  22. package/skills/questlog/references/detect-slips-and-staleness.md +22 -0
  23. package/skills/questlog/references/escalate-and-unblock.md +22 -0
  24. package/skills/questlog/references/frame-initiative-questline.md +23 -0
  25. package/skills/questlog/references/handle-exceptions-and-weird-cases.md +24 -0
  26. package/skills/questlog/references/intake-triage.md +25 -0
  27. package/skills/questlog/references/maintain-clear-ownership.md +22 -0
  28. package/skills/questlog/references/manage-approvals-and-promises.md +22 -0
  29. package/skills/questlog/references/plan-successor-work.md +22 -0
  30. package/skills/questlog/references/plan-time-correctly.md +22 -0
  31. package/skills/questlog/references/prioritize-across-streams.md +21 -0
  32. package/skills/questlog/references/protect-capacity-and-focus.md +20 -0
  33. package/skills/questlog/references/recover-from-modeling-mistakes.md +25 -0
  34. package/skills/questlog/references/report-status-and-manage-expectations.md +20 -0
  35. package/skills/questlog/references/revise-or-reshape-commitment.md +22 -0
  36. package/skills/questlog/references/run-operational-review.md +24 -0
  37. package/skills/questlog/references/run-recurring-rhythms.md +24 -0
  38. package/skills/questlog/references/search-and-retrieve-context.md +23 -0
  39. package/skills/questlog/references/sequence-with-unlocks.md +23 -0
  40. package/skills/questlog/references/settle-rumor-into-structure.md +25 -0
  41. package/skills/questlog/references/tag-and-filter-portfolios.md +21 -0
@@ -0,0 +1,20 @@
1
+ interface QuestlogRunResult {
2
+ lastInsertRowid: number | bigint;
3
+ changes?: number | bigint | undefined;
4
+ }
5
+ interface QuestlogStatement {
6
+ run(...params: unknown[]): QuestlogRunResult;
7
+ get<TRecord = Record<string, unknown>>(...params: unknown[]): TRecord | undefined;
8
+ all<TRecord = Record<string, unknown>>(...params: unknown[]): TRecord[];
9
+ }
10
+ /**
11
+ * SQLite dependency injected into every questlog operation.
12
+ * Node.js `DatabaseSync` satisfies this interface directly.
13
+ */
14
+ type QuestlogDb = {
15
+ exec(sql: string): void;
16
+ prepare(sql: string): QuestlogStatement;
17
+ close(): void;
18
+ };
19
+
20
+ export type { QuestlogDb as Q };
@@ -0,0 +1,20 @@
1
+ interface QuestlogRunResult {
2
+ lastInsertRowid: number | bigint;
3
+ changes?: number | bigint | undefined;
4
+ }
5
+ interface QuestlogStatement {
6
+ run(...params: unknown[]): QuestlogRunResult;
7
+ get<TRecord = Record<string, unknown>>(...params: unknown[]): TRecord | undefined;
8
+ all<TRecord = Record<string, unknown>>(...params: unknown[]): TRecord[];
9
+ }
10
+ /**
11
+ * SQLite dependency injected into every questlog operation.
12
+ * Node.js `DatabaseSync` satisfies this interface directly.
13
+ */
14
+ type QuestlogDb = {
15
+ exec(sql: string): void;
16
+ prepare(sql: string): QuestlogStatement;
17
+ close(): void;
18
+ };
19
+
20
+ export type { QuestlogDb as Q };
package/dist/index.cjs CHANGED
@@ -2056,8 +2056,7 @@ function searchQuestlog(db, query) {
2056
2056
  AND blocker.deleted_at IS NULL
2057
2057
  AND NOT (blocker.resolved_at IS NOT NULL AND blocker.success = 1)
2058
2058
  ) AS has_blockers
2059
- FROM quests_fts
2060
- JOIN quests q ON q.id = quests_fts.rowid
2059
+ FROM quests_fts CROSS JOIN quests q ON q.id = quests_fts.rowid
2061
2060
  WHERE quests_fts MATCH ? AND q.deleted_at IS NULL`
2062
2061
  ).all(trimmed).map((row) => {
2063
2062
  const state = deriveQuestState({
@@ -2089,8 +2088,7 @@ function searchQuestlog(db, query) {
2089
2088
  snippet(rumors_fts, 1, '[', ']', '\u2026', 10) AS snippet,
2090
2089
  r.settled_at,
2091
2090
  r.dismissed_at
2092
- FROM rumors_fts
2093
- JOIN rumors r ON r.id = rumors_fts.rowid
2091
+ FROM rumors_fts CROSS JOIN rumors r ON r.id = rumors_fts.rowid
2094
2092
  WHERE rumors_fts MATCH ? AND r.deleted_at IS NULL`
2095
2093
  ).all(trimmed).map((row) => ({
2096
2094
  entityKind: "rumor",
@@ -4766,6 +4764,30 @@ function runQuestToolHandler(db, input) {
4766
4764
  }
4767
4765
  );
4768
4766
  }
4767
+ const blockers = db.prepare(
4768
+ `SELECT blocker.id FROM quest_unlocks prerequisite
4769
+ JOIN quests blocker ON blocker.id = prerequisite.from_quest_id
4770
+ WHERE prerequisite.to_quest_id = ?
4771
+ AND prerequisite.deleted_at IS NULL
4772
+ AND blocker.deleted_at IS NULL
4773
+ AND NOT (blocker.resolved_at IS NOT NULL AND blocker.success = 1)
4774
+ ORDER BY blocker.id`
4775
+ ).all(current.id).map(({ id }) => getQuestDetail(db, id));
4776
+ if (blockers.length && !input.force) {
4777
+ return toolFailure(
4778
+ "domain",
4779
+ "invalid_state",
4780
+ `Quest "${current.title}" is blocked by ${blockers.map((quest) => quest.title).join(", ")}.`,
4781
+ "Finish the blocking prerequisites before starting this quest, or set force to true.",
4782
+ {
4783
+ entities: [toQuestRef(current), ...blockers.map(toQuestRef)],
4784
+ next: blockers.map((quest) => ({
4785
+ ...inspectItemNext(toQuestRef(quest)),
4786
+ message: `Inspect and finish blocker "${quest.title}".`
4787
+ }))
4788
+ }
4789
+ );
4790
+ }
4769
4791
  startQuest(db, input.questId, input.startedAt);
4770
4792
  const detail = getQuestDetail(db, input.questId);
4771
4793
  return toolSuccess(
@@ -4777,7 +4799,13 @@ function runQuestToolHandler(db, input) {
4777
4799
  quest: detail
4778
4800
  },
4779
4801
  {
4780
- entities: [toQuestRef(detail)]
4802
+ entities: [toQuestRef(detail)],
4803
+ warnings: blockers.length ? [
4804
+ {
4805
+ code: "derived_value_used",
4806
+ message: `Forced start with unmet prerequisites: ${blockers.map((quest) => quest.title).join(", ")}.`
4807
+ }
4808
+ ] : void 0
4781
4809
  }
4782
4810
  );
4783
4811
  }
@@ -4886,6 +4914,7 @@ var runQuestTool = defineQuestlogTool({
4886
4914
  action: "Which execution lifecycle step to perform on the quest.",
4887
4915
  questId: "The concrete quest whose execution state should change.",
4888
4916
  startedAt: "Optional actual start timestamp for the start action.",
4917
+ force: "Start despite unmet unlock prerequisites. Defaults to false.",
4889
4918
  effortSeconds: "Positive active-effort increment in seconds for the log-effort action.",
4890
4919
  now: "Optional timestamp for the effort log action.",
4891
4920
  outcome: "Terminal outcome text for finish or abandon actions.",
@@ -4904,6 +4933,7 @@ var runQuestTool = defineQuestlogTool({
4904
4933
  ]),
4905
4934
  questId: integerSchema("Quest whose execution state should change."),
4906
4935
  startedAt: integerSchema("Optional start timestamp for the start action."),
4936
+ force: booleanSchema("Start despite unmet unlock prerequisites. Defaults to false."),
4907
4937
  effortSeconds: integerSchema(
4908
4938
  "Positive active-effort increment in seconds. Required for log_effort."
4909
4939
  ),
package/dist/index.d.cts CHANGED
@@ -1,21 +1,4 @@
1
- interface QuestlogRunResult {
2
- lastInsertRowid: number | bigint;
3
- changes?: number | bigint | undefined;
4
- }
5
- interface QuestlogStatement {
6
- run(...params: unknown[]): QuestlogRunResult;
7
- get<TRecord = Record<string, unknown>>(...params: unknown[]): TRecord | undefined;
8
- all<TRecord = Record<string, unknown>>(...params: unknown[]): TRecord[];
9
- }
10
- /**
11
- * SQLite dependency injected into every questlog operation.
12
- * Node.js `DatabaseSync` satisfies this interface directly.
13
- */
14
- type QuestlogDb = {
15
- exec(sql: string): void;
16
- prepare(sql: string): QuestlogStatement;
17
- close(): void;
18
- };
1
+ import { Q as QuestlogDb } from './database-DShQ4N46.cjs';
19
2
 
20
3
  /**
21
4
  * Creates the full standalone questlog schema, including FTS and indexing.
@@ -682,6 +665,8 @@ interface QuestlogSearchResult {
682
665
 
683
666
  /**
684
667
  * Full-text search across quest and rumor content.
668
+ * CROSS JOIN keeps the FTS table as the outer loop; with a plain JOIN SQLite
669
+ * may walk idx_quests_deleted_at and probe the FTS index once per quest.
685
670
  */
686
671
  declare function searchQuestlog(db: QuestlogDb, query: string): QuestlogSearchResult[];
687
672
 
@@ -1434,6 +1419,7 @@ type RunQuestToolInput = {
1434
1419
  action: 'start';
1435
1420
  questId: number;
1436
1421
  startedAt?: number;
1422
+ force?: boolean;
1437
1423
  };
1438
1424
  interface RunQuestToolData {
1439
1425
  action: RunQuestToolInput['action'];
@@ -1720,4 +1706,4 @@ declare namespace write {
1720
1706
  export { write_abandonQuest as abandonQuest, write_abandonQuestAndSpawnFollowups as abandonQuestAndSpawnFollowups, write_addQuestReward as addQuestReward, write_addUnlock as addUnlock, write_archiveQuestline as archiveQuestline, write_archiveRepeatableQuest as archiveRepeatableQuest, write_captureRumor as captureRumor, write_claimQuestReward as claimQuestReward, write_createQuest as createQuest, write_createQuestline as createQuestline, write_createRepeatableQuest as createRepeatableQuest, write_detachQuestFromQuestline as detachQuestFromQuestline, write_dismissRumor as dismissRumor, write_finishQuest as finishQuest, write_logQuestEffort as logQuestEffort, write_moveQuestToQuestline as moveQuestToQuestline, write_planQuestTime as planQuestTime, write_removeQuestReward as removeQuestReward, write_removeUnlock as removeUnlock, write_reopenRumor as reopenRumor, write_replaceQuestTags as replaceQuestTags, write_replaceRepeatableQuestRewards as replaceRepeatableQuestRewards, write_replaceRepeatableQuestTags as replaceRepeatableQuestTags, write_replaceUnlocks as replaceUnlocks, write_reviseQuestObjective as reviseQuestObjective, write_settleRumor as settleRumor, write_softDeleteQuest as softDeleteQuest, write_softDeleteQuestline as softDeleteQuestline, write_softDeleteRepeatableQuest as softDeleteRepeatableQuest, write_softDeleteRumor as softDeleteRumor, write_spawnDueRepeatableQuests as spawnDueRepeatableQuests, write_startQuest as startQuest, write_tagQuest as tagQuest, write_untagQuest as untagQuest, write_updateQuestReward as updateQuestReward, write_updateQuestline as updateQuestline, write_updateRepeatableQuest as updateRepeatableQuest, write_updateRumor as updateRumor };
1721
1707
  }
1722
1708
 
1723
- export { type AbandonQuestResult, type CaptureRumorInput, type CreateQuestInput, type CreateQuestlineInput, type CreateRepeatableQuestInput, type DueRepeatableAnchor, type FollowupQuestInput, type JsonSchema, type JsonSchemaType, type MarkerDefinition, type MarkerId, type PlanQuestTimeInput, type Quest, type QuestDetail, type QuestListFilters, type QuestReward, type QuestRewardInput, type QuestState, type QuestUnlock, type Questline, type QuestlineDetail, type QuestlogDb, type QuestlogSearchResult, type QuestlogSkill, type QuestlogSkillRegistry, type QuestlogSoul, type QuestlogSoulTrait, type QuestlogToolDefinition, type QuestlogToolMapping, type RepeatableQuest, type RepeatableQuestReward, type RepeatableQuestRewardInput, type Rumor, type RumorDetail, type RumorOutput, type RumorState, type SettleRumorInput, type SettleRumorResult, type Tag, type ToolClarificationCode, type ToolDefinitionRegistry, type ToolEntityKind, type ToolEntityRef, type ToolErrorCode, type ToolErrorKind, type ToolFailure, type ToolInputDescriptions, type ToolListItem, type ToolNeedsClarification, type ToolNextStepHint, type ToolNextStepHintKind, type ToolOutcomeKind, type ToolOutputDescription, type ToolResult, type ToolSideEffects, type ToolSuccess, type ToolWarning, type ToolWarningCode, type UpdateQuestlineInput, type UpdateRepeatableQuestInput, type UpdateRumorInput, abandonQuest, abandonQuestAndSpawnFollowups, addQuestReward, addUnlock, archiveDeleteAndPruneSkill, archiveQuestline, archiveRepeatableQuest, arraySchema, booleanSchema, captureRumor, captureRumorTool, captureRumorToolHandler, captureRumorToolName, chooseWorkShapeSkill, claimQuestReward, clarifyAmbiguousRequestsSkill, closeWorkAndClaimOutcomesSkill, createConcreteQuestSkill, createQuest, createQuestline, createRepeatableQuest, defineQuestlogSkill, defineQuestlogTool, detachQuestFromQuestline, detectSlipsAndStalenessSkill, dismissRumor, enumSchema, escalateAndUnblockSkill, finishQuest, frameInitiativeQuestlineSkill, getQuestDetail, getQuestlineDetail, getQuestlogSkillByName, getQuestlogToolByName, getRumorDetail, getRumorOutputs, handleExceptionsAndWeirdCasesSkill, initQuestlogTables, inspectQuestlogItemTool, inspectQuestlogItemToolHandler, inspectQuestlogItemToolName, intakeTriageSkill, integerSchema, listActiveQuests, listAvailableQuests, listBlockedQuests, listDeferredQuests, listDueRepeatableQuestAnchors, listDueSoonQuests, listInProgressQuests, listMissedScheduledQuests, listOpenQuests, listOverdueQuests, listQuestlines, listQuestlogSkills, listQuestlogToolDefinitions, listResolvedQuests, listRumors, listScheduledForDay, listScheduledNow, literalSchema, logQuestEffort, maintainClearOwnershipSkill, manageApprovalsAndPromisesSkill, manageRepeatableTool, manageRepeatableToolHandler, manageRepeatableToolName, index$2 as markers, moveQuestToQuestline, numberSchema, objectSchema, oneOfSchema, organizeWorkTool, organizeWorkToolHandler, organizeWorkToolName, planQuestTime, planQuestTool, planQuestToolHandler, planQuestToolName, planSuccessorWorkSkill, planTimeCorrectlySkill, prioritizeAcrossStreamsSkill, protectCapacityAndFocusSkill, questlogSkills, questlogToolMappings, questlogTools, read, recoverFromModelingMistakesSkill, removeQuestReward, removeUnlock, reopenRumor, replaceQuestTags, replaceRepeatableQuestRewards, replaceRepeatableQuestTags, replaceUnlocks, reportStatusAndManageExpectationsSkill, retireWorkTool, retireWorkToolHandler, retireWorkToolName, reviewQuestlogTool, reviewQuestlogToolHandler, reviewQuestlogToolName, reviseOrReshapeCommitmentSkill, reviseQuestObjective, rewardWorkTool, rewardWorkToolHandler, rewardWorkToolName, runOperationalReviewSkill, runQuestTool, runQuestToolHandler, runQuestToolName, runRecurringRhythmsSkill, searchAndRetrieveContextSkill, searchQuestlogTool, searchQuestlogToolHandler, searchQuestlogToolName, sequenceWithUnlocksSkill, settleRumor, settleRumorIntoStructureSkill, shapeWorkTool, shapeWorkToolHandler, shapeWorkToolName, index$1 as skills, softDeleteQuest, softDeleteQuestline, softDeleteRepeatableQuest, softDeleteRumor, soul, spawnDueRepeatableQuests, startQuest, stringSchema, tagAndFilterPortfoliosSkill, tagQuest, tagWorkTool, tagWorkToolHandler, tagWorkToolName, toolFailure, toolNeedsClarification, toolNoOp, toolSuccess, toolWarning, index as tools, untagQuest, updateQuestReward, updateQuestline, updateRepeatableQuest, updateRumor, write };
1709
+ export { type AbandonQuestResult, type CaptureRumorInput, type CreateQuestInput, type CreateQuestlineInput, type CreateRepeatableQuestInput, type DueRepeatableAnchor, type FollowupQuestInput, type JsonSchema, type JsonSchemaType, type MarkerDefinition, type MarkerId, type PlanQuestTimeInput, type Quest, type QuestDetail, type QuestListFilters, type QuestReward, type QuestRewardInput, type QuestState, type QuestUnlock, type Questline, type QuestlineDetail, QuestlogDb, type QuestlogSearchResult, type QuestlogSkill, type QuestlogSkillRegistry, type QuestlogSoul, type QuestlogSoulTrait, type QuestlogToolDefinition, type QuestlogToolMapping, type RepeatableQuest, type RepeatableQuestReward, type RepeatableQuestRewardInput, type Rumor, type RumorDetail, type RumorOutput, type RumorState, type SettleRumorInput, type SettleRumorResult, type Tag, type ToolClarificationCode, type ToolDefinitionRegistry, type ToolEntityKind, type ToolEntityRef, type ToolErrorCode, type ToolErrorKind, type ToolFailure, type ToolInputDescriptions, type ToolListItem, type ToolNeedsClarification, type ToolNextStepHint, type ToolNextStepHintKind, type ToolOutcomeKind, type ToolOutputDescription, type ToolResult, type ToolSideEffects, type ToolSuccess, type ToolWarning, type ToolWarningCode, type UpdateQuestlineInput, type UpdateRepeatableQuestInput, type UpdateRumorInput, abandonQuest, abandonQuestAndSpawnFollowups, addQuestReward, addUnlock, archiveDeleteAndPruneSkill, archiveQuestline, archiveRepeatableQuest, arraySchema, booleanSchema, captureRumor, captureRumorTool, captureRumorToolHandler, captureRumorToolName, chooseWorkShapeSkill, claimQuestReward, clarifyAmbiguousRequestsSkill, closeWorkAndClaimOutcomesSkill, createConcreteQuestSkill, createQuest, createQuestline, createRepeatableQuest, defineQuestlogSkill, defineQuestlogTool, detachQuestFromQuestline, detectSlipsAndStalenessSkill, dismissRumor, enumSchema, escalateAndUnblockSkill, finishQuest, frameInitiativeQuestlineSkill, getQuestDetail, getQuestlineDetail, getQuestlogSkillByName, getQuestlogToolByName, getRumorDetail, getRumorOutputs, handleExceptionsAndWeirdCasesSkill, initQuestlogTables, inspectQuestlogItemTool, inspectQuestlogItemToolHandler, inspectQuestlogItemToolName, intakeTriageSkill, integerSchema, listActiveQuests, listAvailableQuests, listBlockedQuests, listDeferredQuests, listDueRepeatableQuestAnchors, listDueSoonQuests, listInProgressQuests, listMissedScheduledQuests, listOpenQuests, listOverdueQuests, listQuestlines, listQuestlogSkills, listQuestlogToolDefinitions, listResolvedQuests, listRumors, listScheduledForDay, listScheduledNow, literalSchema, logQuestEffort, maintainClearOwnershipSkill, manageApprovalsAndPromisesSkill, manageRepeatableTool, manageRepeatableToolHandler, manageRepeatableToolName, index$2 as markers, moveQuestToQuestline, numberSchema, objectSchema, oneOfSchema, organizeWorkTool, organizeWorkToolHandler, organizeWorkToolName, planQuestTime, planQuestTool, planQuestToolHandler, planQuestToolName, planSuccessorWorkSkill, planTimeCorrectlySkill, prioritizeAcrossStreamsSkill, protectCapacityAndFocusSkill, questlogSkills, questlogToolMappings, questlogTools, read, recoverFromModelingMistakesSkill, removeQuestReward, removeUnlock, reopenRumor, replaceQuestTags, replaceRepeatableQuestRewards, replaceRepeatableQuestTags, replaceUnlocks, reportStatusAndManageExpectationsSkill, retireWorkTool, retireWorkToolHandler, retireWorkToolName, reviewQuestlogTool, reviewQuestlogToolHandler, reviewQuestlogToolName, reviseOrReshapeCommitmentSkill, reviseQuestObjective, rewardWorkTool, rewardWorkToolHandler, rewardWorkToolName, runOperationalReviewSkill, runQuestTool, runQuestToolHandler, runQuestToolName, runRecurringRhythmsSkill, searchAndRetrieveContextSkill, searchQuestlogTool, searchQuestlogToolHandler, searchQuestlogToolName, sequenceWithUnlocksSkill, settleRumor, settleRumorIntoStructureSkill, shapeWorkTool, shapeWorkToolHandler, shapeWorkToolName, index$1 as skills, softDeleteQuest, softDeleteQuestline, softDeleteRepeatableQuest, softDeleteRumor, soul, spawnDueRepeatableQuests, startQuest, stringSchema, tagAndFilterPortfoliosSkill, tagQuest, tagWorkTool, tagWorkToolHandler, tagWorkToolName, toolFailure, toolNeedsClarification, toolNoOp, toolSuccess, toolWarning, index as tools, untagQuest, updateQuestReward, updateQuestline, updateRepeatableQuest, updateRumor, write };
package/dist/index.d.ts CHANGED
@@ -1,21 +1,4 @@
1
- interface QuestlogRunResult {
2
- lastInsertRowid: number | bigint;
3
- changes?: number | bigint | undefined;
4
- }
5
- interface QuestlogStatement {
6
- run(...params: unknown[]): QuestlogRunResult;
7
- get<TRecord = Record<string, unknown>>(...params: unknown[]): TRecord | undefined;
8
- all<TRecord = Record<string, unknown>>(...params: unknown[]): TRecord[];
9
- }
10
- /**
11
- * SQLite dependency injected into every questlog operation.
12
- * Node.js `DatabaseSync` satisfies this interface directly.
13
- */
14
- type QuestlogDb = {
15
- exec(sql: string): void;
16
- prepare(sql: string): QuestlogStatement;
17
- close(): void;
18
- };
1
+ import { Q as QuestlogDb } from './database-DShQ4N46.js';
19
2
 
20
3
  /**
21
4
  * Creates the full standalone questlog schema, including FTS and indexing.
@@ -682,6 +665,8 @@ interface QuestlogSearchResult {
682
665
 
683
666
  /**
684
667
  * Full-text search across quest and rumor content.
668
+ * CROSS JOIN keeps the FTS table as the outer loop; with a plain JOIN SQLite
669
+ * may walk idx_quests_deleted_at and probe the FTS index once per quest.
685
670
  */
686
671
  declare function searchQuestlog(db: QuestlogDb, query: string): QuestlogSearchResult[];
687
672
 
@@ -1434,6 +1419,7 @@ type RunQuestToolInput = {
1434
1419
  action: 'start';
1435
1420
  questId: number;
1436
1421
  startedAt?: number;
1422
+ force?: boolean;
1437
1423
  };
1438
1424
  interface RunQuestToolData {
1439
1425
  action: RunQuestToolInput['action'];
@@ -1720,4 +1706,4 @@ declare namespace write {
1720
1706
  export { write_abandonQuest as abandonQuest, write_abandonQuestAndSpawnFollowups as abandonQuestAndSpawnFollowups, write_addQuestReward as addQuestReward, write_addUnlock as addUnlock, write_archiveQuestline as archiveQuestline, write_archiveRepeatableQuest as archiveRepeatableQuest, write_captureRumor as captureRumor, write_claimQuestReward as claimQuestReward, write_createQuest as createQuest, write_createQuestline as createQuestline, write_createRepeatableQuest as createRepeatableQuest, write_detachQuestFromQuestline as detachQuestFromQuestline, write_dismissRumor as dismissRumor, write_finishQuest as finishQuest, write_logQuestEffort as logQuestEffort, write_moveQuestToQuestline as moveQuestToQuestline, write_planQuestTime as planQuestTime, write_removeQuestReward as removeQuestReward, write_removeUnlock as removeUnlock, write_reopenRumor as reopenRumor, write_replaceQuestTags as replaceQuestTags, write_replaceRepeatableQuestRewards as replaceRepeatableQuestRewards, write_replaceRepeatableQuestTags as replaceRepeatableQuestTags, write_replaceUnlocks as replaceUnlocks, write_reviseQuestObjective as reviseQuestObjective, write_settleRumor as settleRumor, write_softDeleteQuest as softDeleteQuest, write_softDeleteQuestline as softDeleteQuestline, write_softDeleteRepeatableQuest as softDeleteRepeatableQuest, write_softDeleteRumor as softDeleteRumor, write_spawnDueRepeatableQuests as spawnDueRepeatableQuests, write_startQuest as startQuest, write_tagQuest as tagQuest, write_untagQuest as untagQuest, write_updateQuestReward as updateQuestReward, write_updateQuestline as updateQuestline, write_updateRepeatableQuest as updateRepeatableQuest, write_updateRumor as updateRumor };
1721
1707
  }
1722
1708
 
1723
- export { type AbandonQuestResult, type CaptureRumorInput, type CreateQuestInput, type CreateQuestlineInput, type CreateRepeatableQuestInput, type DueRepeatableAnchor, type FollowupQuestInput, type JsonSchema, type JsonSchemaType, type MarkerDefinition, type MarkerId, type PlanQuestTimeInput, type Quest, type QuestDetail, type QuestListFilters, type QuestReward, type QuestRewardInput, type QuestState, type QuestUnlock, type Questline, type QuestlineDetail, type QuestlogDb, type QuestlogSearchResult, type QuestlogSkill, type QuestlogSkillRegistry, type QuestlogSoul, type QuestlogSoulTrait, type QuestlogToolDefinition, type QuestlogToolMapping, type RepeatableQuest, type RepeatableQuestReward, type RepeatableQuestRewardInput, type Rumor, type RumorDetail, type RumorOutput, type RumorState, type SettleRumorInput, type SettleRumorResult, type Tag, type ToolClarificationCode, type ToolDefinitionRegistry, type ToolEntityKind, type ToolEntityRef, type ToolErrorCode, type ToolErrorKind, type ToolFailure, type ToolInputDescriptions, type ToolListItem, type ToolNeedsClarification, type ToolNextStepHint, type ToolNextStepHintKind, type ToolOutcomeKind, type ToolOutputDescription, type ToolResult, type ToolSideEffects, type ToolSuccess, type ToolWarning, type ToolWarningCode, type UpdateQuestlineInput, type UpdateRepeatableQuestInput, type UpdateRumorInput, abandonQuest, abandonQuestAndSpawnFollowups, addQuestReward, addUnlock, archiveDeleteAndPruneSkill, archiveQuestline, archiveRepeatableQuest, arraySchema, booleanSchema, captureRumor, captureRumorTool, captureRumorToolHandler, captureRumorToolName, chooseWorkShapeSkill, claimQuestReward, clarifyAmbiguousRequestsSkill, closeWorkAndClaimOutcomesSkill, createConcreteQuestSkill, createQuest, createQuestline, createRepeatableQuest, defineQuestlogSkill, defineQuestlogTool, detachQuestFromQuestline, detectSlipsAndStalenessSkill, dismissRumor, enumSchema, escalateAndUnblockSkill, finishQuest, frameInitiativeQuestlineSkill, getQuestDetail, getQuestlineDetail, getQuestlogSkillByName, getQuestlogToolByName, getRumorDetail, getRumorOutputs, handleExceptionsAndWeirdCasesSkill, initQuestlogTables, inspectQuestlogItemTool, inspectQuestlogItemToolHandler, inspectQuestlogItemToolName, intakeTriageSkill, integerSchema, listActiveQuests, listAvailableQuests, listBlockedQuests, listDeferredQuests, listDueRepeatableQuestAnchors, listDueSoonQuests, listInProgressQuests, listMissedScheduledQuests, listOpenQuests, listOverdueQuests, listQuestlines, listQuestlogSkills, listQuestlogToolDefinitions, listResolvedQuests, listRumors, listScheduledForDay, listScheduledNow, literalSchema, logQuestEffort, maintainClearOwnershipSkill, manageApprovalsAndPromisesSkill, manageRepeatableTool, manageRepeatableToolHandler, manageRepeatableToolName, index$2 as markers, moveQuestToQuestline, numberSchema, objectSchema, oneOfSchema, organizeWorkTool, organizeWorkToolHandler, organizeWorkToolName, planQuestTime, planQuestTool, planQuestToolHandler, planQuestToolName, planSuccessorWorkSkill, planTimeCorrectlySkill, prioritizeAcrossStreamsSkill, protectCapacityAndFocusSkill, questlogSkills, questlogToolMappings, questlogTools, read, recoverFromModelingMistakesSkill, removeQuestReward, removeUnlock, reopenRumor, replaceQuestTags, replaceRepeatableQuestRewards, replaceRepeatableQuestTags, replaceUnlocks, reportStatusAndManageExpectationsSkill, retireWorkTool, retireWorkToolHandler, retireWorkToolName, reviewQuestlogTool, reviewQuestlogToolHandler, reviewQuestlogToolName, reviseOrReshapeCommitmentSkill, reviseQuestObjective, rewardWorkTool, rewardWorkToolHandler, rewardWorkToolName, runOperationalReviewSkill, runQuestTool, runQuestToolHandler, runQuestToolName, runRecurringRhythmsSkill, searchAndRetrieveContextSkill, searchQuestlogTool, searchQuestlogToolHandler, searchQuestlogToolName, sequenceWithUnlocksSkill, settleRumor, settleRumorIntoStructureSkill, shapeWorkTool, shapeWorkToolHandler, shapeWorkToolName, index$1 as skills, softDeleteQuest, softDeleteQuestline, softDeleteRepeatableQuest, softDeleteRumor, soul, spawnDueRepeatableQuests, startQuest, stringSchema, tagAndFilterPortfoliosSkill, tagQuest, tagWorkTool, tagWorkToolHandler, tagWorkToolName, toolFailure, toolNeedsClarification, toolNoOp, toolSuccess, toolWarning, index as tools, untagQuest, updateQuestReward, updateQuestline, updateRepeatableQuest, updateRumor, write };
1709
+ export { type AbandonQuestResult, type CaptureRumorInput, type CreateQuestInput, type CreateQuestlineInput, type CreateRepeatableQuestInput, type DueRepeatableAnchor, type FollowupQuestInput, type JsonSchema, type JsonSchemaType, type MarkerDefinition, type MarkerId, type PlanQuestTimeInput, type Quest, type QuestDetail, type QuestListFilters, type QuestReward, type QuestRewardInput, type QuestState, type QuestUnlock, type Questline, type QuestlineDetail, QuestlogDb, type QuestlogSearchResult, type QuestlogSkill, type QuestlogSkillRegistry, type QuestlogSoul, type QuestlogSoulTrait, type QuestlogToolDefinition, type QuestlogToolMapping, type RepeatableQuest, type RepeatableQuestReward, type RepeatableQuestRewardInput, type Rumor, type RumorDetail, type RumorOutput, type RumorState, type SettleRumorInput, type SettleRumorResult, type Tag, type ToolClarificationCode, type ToolDefinitionRegistry, type ToolEntityKind, type ToolEntityRef, type ToolErrorCode, type ToolErrorKind, type ToolFailure, type ToolInputDescriptions, type ToolListItem, type ToolNeedsClarification, type ToolNextStepHint, type ToolNextStepHintKind, type ToolOutcomeKind, type ToolOutputDescription, type ToolResult, type ToolSideEffects, type ToolSuccess, type ToolWarning, type ToolWarningCode, type UpdateQuestlineInput, type UpdateRepeatableQuestInput, type UpdateRumorInput, abandonQuest, abandonQuestAndSpawnFollowups, addQuestReward, addUnlock, archiveDeleteAndPruneSkill, archiveQuestline, archiveRepeatableQuest, arraySchema, booleanSchema, captureRumor, captureRumorTool, captureRumorToolHandler, captureRumorToolName, chooseWorkShapeSkill, claimQuestReward, clarifyAmbiguousRequestsSkill, closeWorkAndClaimOutcomesSkill, createConcreteQuestSkill, createQuest, createQuestline, createRepeatableQuest, defineQuestlogSkill, defineQuestlogTool, detachQuestFromQuestline, detectSlipsAndStalenessSkill, dismissRumor, enumSchema, escalateAndUnblockSkill, finishQuest, frameInitiativeQuestlineSkill, getQuestDetail, getQuestlineDetail, getQuestlogSkillByName, getQuestlogToolByName, getRumorDetail, getRumorOutputs, handleExceptionsAndWeirdCasesSkill, initQuestlogTables, inspectQuestlogItemTool, inspectQuestlogItemToolHandler, inspectQuestlogItemToolName, intakeTriageSkill, integerSchema, listActiveQuests, listAvailableQuests, listBlockedQuests, listDeferredQuests, listDueRepeatableQuestAnchors, listDueSoonQuests, listInProgressQuests, listMissedScheduledQuests, listOpenQuests, listOverdueQuests, listQuestlines, listQuestlogSkills, listQuestlogToolDefinitions, listResolvedQuests, listRumors, listScheduledForDay, listScheduledNow, literalSchema, logQuestEffort, maintainClearOwnershipSkill, manageApprovalsAndPromisesSkill, manageRepeatableTool, manageRepeatableToolHandler, manageRepeatableToolName, index$2 as markers, moveQuestToQuestline, numberSchema, objectSchema, oneOfSchema, organizeWorkTool, organizeWorkToolHandler, organizeWorkToolName, planQuestTime, planQuestTool, planQuestToolHandler, planQuestToolName, planSuccessorWorkSkill, planTimeCorrectlySkill, prioritizeAcrossStreamsSkill, protectCapacityAndFocusSkill, questlogSkills, questlogToolMappings, questlogTools, read, recoverFromModelingMistakesSkill, removeQuestReward, removeUnlock, reopenRumor, replaceQuestTags, replaceRepeatableQuestRewards, replaceRepeatableQuestTags, replaceUnlocks, reportStatusAndManageExpectationsSkill, retireWorkTool, retireWorkToolHandler, retireWorkToolName, reviewQuestlogTool, reviewQuestlogToolHandler, reviewQuestlogToolName, reviseOrReshapeCommitmentSkill, reviseQuestObjective, rewardWorkTool, rewardWorkToolHandler, rewardWorkToolName, runOperationalReviewSkill, runQuestTool, runQuestToolHandler, runQuestToolName, runRecurringRhythmsSkill, searchAndRetrieveContextSkill, searchQuestlogTool, searchQuestlogToolHandler, searchQuestlogToolName, sequenceWithUnlocksSkill, settleRumor, settleRumorIntoStructureSkill, shapeWorkTool, shapeWorkToolHandler, shapeWorkToolName, index$1 as skills, softDeleteQuest, softDeleteQuestline, softDeleteRepeatableQuest, softDeleteRumor, soul, spawnDueRepeatableQuests, startQuest, stringSchema, tagAndFilterPortfoliosSkill, tagQuest, tagWorkTool, tagWorkToolHandler, tagWorkToolName, toolFailure, toolNeedsClarification, toolNoOp, toolSuccess, toolWarning, index as tools, untagQuest, updateQuestReward, updateQuestline, updateRepeatableQuest, updateRumor, write };
package/dist/index.js CHANGED
@@ -2054,8 +2054,7 @@ function searchQuestlog(db, query) {
2054
2054
  AND blocker.deleted_at IS NULL
2055
2055
  AND NOT (blocker.resolved_at IS NOT NULL AND blocker.success = 1)
2056
2056
  ) AS has_blockers
2057
- FROM quests_fts
2058
- JOIN quests q ON q.id = quests_fts.rowid
2057
+ FROM quests_fts CROSS JOIN quests q ON q.id = quests_fts.rowid
2059
2058
  WHERE quests_fts MATCH ? AND q.deleted_at IS NULL`
2060
2059
  ).all(trimmed).map((row) => {
2061
2060
  const state = deriveQuestState({
@@ -2087,8 +2086,7 @@ function searchQuestlog(db, query) {
2087
2086
  snippet(rumors_fts, 1, '[', ']', '\u2026', 10) AS snippet,
2088
2087
  r.settled_at,
2089
2088
  r.dismissed_at
2090
- FROM rumors_fts
2091
- JOIN rumors r ON r.id = rumors_fts.rowid
2089
+ FROM rumors_fts CROSS JOIN rumors r ON r.id = rumors_fts.rowid
2092
2090
  WHERE rumors_fts MATCH ? AND r.deleted_at IS NULL`
2093
2091
  ).all(trimmed).map((row) => ({
2094
2092
  entityKind: "rumor",
@@ -4764,6 +4762,30 @@ function runQuestToolHandler(db, input) {
4764
4762
  }
4765
4763
  );
4766
4764
  }
4765
+ const blockers = db.prepare(
4766
+ `SELECT blocker.id FROM quest_unlocks prerequisite
4767
+ JOIN quests blocker ON blocker.id = prerequisite.from_quest_id
4768
+ WHERE prerequisite.to_quest_id = ?
4769
+ AND prerequisite.deleted_at IS NULL
4770
+ AND blocker.deleted_at IS NULL
4771
+ AND NOT (blocker.resolved_at IS NOT NULL AND blocker.success = 1)
4772
+ ORDER BY blocker.id`
4773
+ ).all(current.id).map(({ id }) => getQuestDetail(db, id));
4774
+ if (blockers.length && !input.force) {
4775
+ return toolFailure(
4776
+ "domain",
4777
+ "invalid_state",
4778
+ `Quest "${current.title}" is blocked by ${blockers.map((quest) => quest.title).join(", ")}.`,
4779
+ "Finish the blocking prerequisites before starting this quest, or set force to true.",
4780
+ {
4781
+ entities: [toQuestRef(current), ...blockers.map(toQuestRef)],
4782
+ next: blockers.map((quest) => ({
4783
+ ...inspectItemNext(toQuestRef(quest)),
4784
+ message: `Inspect and finish blocker "${quest.title}".`
4785
+ }))
4786
+ }
4787
+ );
4788
+ }
4767
4789
  startQuest(db, input.questId, input.startedAt);
4768
4790
  const detail = getQuestDetail(db, input.questId);
4769
4791
  return toolSuccess(
@@ -4775,7 +4797,13 @@ function runQuestToolHandler(db, input) {
4775
4797
  quest: detail
4776
4798
  },
4777
4799
  {
4778
- entities: [toQuestRef(detail)]
4800
+ entities: [toQuestRef(detail)],
4801
+ warnings: blockers.length ? [
4802
+ {
4803
+ code: "derived_value_used",
4804
+ message: `Forced start with unmet prerequisites: ${blockers.map((quest) => quest.title).join(", ")}.`
4805
+ }
4806
+ ] : void 0
4779
4807
  }
4780
4808
  );
4781
4809
  }
@@ -4884,6 +4912,7 @@ var runQuestTool = defineQuestlogTool({
4884
4912
  action: "Which execution lifecycle step to perform on the quest.",
4885
4913
  questId: "The concrete quest whose execution state should change.",
4886
4914
  startedAt: "Optional actual start timestamp for the start action.",
4915
+ force: "Start despite unmet unlock prerequisites. Defaults to false.",
4887
4916
  effortSeconds: "Positive active-effort increment in seconds for the log-effort action.",
4888
4917
  now: "Optional timestamp for the effort log action.",
4889
4918
  outcome: "Terminal outcome text for finish or abandon actions.",
@@ -4902,6 +4931,7 @@ var runQuestTool = defineQuestlogTool({
4902
4931
  ]),
4903
4932
  questId: integerSchema("Quest whose execution state should change."),
4904
4933
  startedAt: integerSchema("Optional start timestamp for the start action."),
4934
+ force: booleanSchema("Start despite unmet unlock prerequisites. Defaults to false."),
4905
4935
  effortSeconds: integerSchema(
4906
4936
  "Positive active-effort increment in seconds. Required for log_effort."
4907
4937
  ),