gnosys 5.5.0 → 5.7.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/README.md +44 -0
- package/dist/cli.js +959 -438
- package/dist/cli.js.map +1 -1
- package/dist/lib/audit.d.ts +13 -0
- package/dist/lib/audit.d.ts.map +1 -1
- package/dist/lib/audit.js +42 -0
- package/dist/lib/audit.js.map +1 -1
- package/dist/lib/chat/choose.d.ts +75 -0
- package/dist/lib/chat/choose.d.ts.map +1 -0
- package/dist/lib/chat/choose.js +146 -0
- package/dist/lib/chat/choose.js.map +1 -0
- package/dist/lib/chat/commands.d.ts +96 -0
- package/dist/lib/chat/commands.d.ts.map +1 -0
- package/dist/lib/chat/commands.js +367 -0
- package/dist/lib/chat/commands.js.map +1 -0
- package/dist/lib/chat/focus.d.ts +70 -0
- package/dist/lib/chat/focus.d.ts.map +1 -0
- package/dist/lib/chat/focus.js +120 -0
- package/dist/lib/chat/focus.js.map +1 -0
- package/dist/lib/chat/index.d.ts +32 -0
- package/dist/lib/chat/index.d.ts.map +1 -0
- package/dist/lib/chat/index.js +151 -0
- package/dist/lib/chat/index.js.map +1 -0
- package/dist/lib/chat/intent.d.ts +100 -0
- package/dist/lib/chat/intent.d.ts.map +1 -0
- package/dist/lib/chat/intent.js +192 -0
- package/dist/lib/chat/intent.js.map +1 -0
- package/dist/lib/chat/llmTurn.d.ts +55 -0
- package/dist/lib/chat/llmTurn.d.ts.map +1 -0
- package/dist/lib/chat/llmTurn.js +103 -0
- package/dist/lib/chat/llmTurn.js.map +1 -0
- package/dist/lib/chat/recall.d.ts +58 -0
- package/dist/lib/chat/recall.d.ts.map +1 -0
- package/dist/lib/chat/recall.js +109 -0
- package/dist/lib/chat/recall.js.map +1 -0
- package/dist/lib/chat/render.d.ts +30 -0
- package/dist/lib/chat/render.d.ts.map +1 -0
- package/dist/lib/chat/render.js +755 -0
- package/dist/lib/chat/render.js.map +1 -0
- package/dist/lib/chat/session.d.ts +121 -0
- package/dist/lib/chat/session.d.ts.map +1 -0
- package/dist/lib/chat/session.js +148 -0
- package/dist/lib/chat/session.js.map +1 -0
- package/dist/lib/chat/toolFence.d.ts +54 -0
- package/dist/lib/chat/toolFence.d.ts.map +1 -0
- package/dist/lib/chat/toolFence.js +90 -0
- package/dist/lib/chat/toolFence.js.map +1 -0
- package/dist/lib/chat/tools.d.ts +48 -0
- package/dist/lib/chat/tools.d.ts.map +1 -0
- package/dist/lib/chat/tools.js +338 -0
- package/dist/lib/chat/tools.js.map +1 -0
- package/dist/lib/chat/types.d.ts +42 -0
- package/dist/lib/chat/types.d.ts.map +1 -0
- package/dist/lib/chat/types.js +6 -0
- package/dist/lib/chat/types.js.map +1 -0
- package/dist/lib/chat/write.d.ts +66 -0
- package/dist/lib/chat/write.d.ts.map +1 -0
- package/dist/lib/chat/write.js +203 -0
- package/dist/lib/chat/write.js.map +1 -0
- package/dist/lib/db.d.ts +41 -1
- package/dist/lib/db.d.ts.map +1 -1
- package/dist/lib/db.js +136 -28
- package/dist/lib/db.js.map +1 -1
- package/dist/lib/exportProject.d.ts +51 -0
- package/dist/lib/exportProject.d.ts.map +1 -0
- package/dist/lib/exportProject.js +72 -0
- package/dist/lib/exportProject.js.map +1 -0
- package/dist/lib/importProject.d.ts +35 -0
- package/dist/lib/importProject.d.ts.map +1 -0
- package/dist/lib/importProject.js +135 -0
- package/dist/lib/importProject.js.map +1 -0
- package/dist/lib/remote.d.ts +23 -0
- package/dist/lib/remote.d.ts.map +1 -1
- package/dist/lib/remote.js +88 -0
- package/dist/lib/remote.js.map +1 -1
- package/dist/lib/remoteWizard.d.ts.map +1 -1
- package/dist/lib/remoteWizard.js +13 -17
- package/dist/lib/remoteWizard.js.map +1 -1
- package/dist/lib/setup/sections/ides.d.ts +20 -0
- package/dist/lib/setup/sections/ides.d.ts.map +1 -0
- package/dist/lib/setup/sections/ides.js +124 -0
- package/dist/lib/setup/sections/ides.js.map +1 -0
- package/dist/lib/setup/sections/preferences.d.ts +30 -0
- package/dist/lib/setup/sections/preferences.d.ts.map +1 -0
- package/dist/lib/setup/sections/preferences.js +128 -0
- package/dist/lib/setup/sections/preferences.js.map +1 -0
- package/dist/lib/setup/sections/routing.d.ts +21 -0
- package/dist/lib/setup/sections/routing.d.ts.map +1 -0
- package/dist/lib/setup/sections/routing.js +160 -0
- package/dist/lib/setup/sections/routing.js.map +1 -0
- package/dist/lib/setup/summary.d.ts +42 -0
- package/dist/lib/setup/summary.d.ts.map +1 -0
- package/dist/lib/setup/summary.js +206 -0
- package/dist/lib/setup/summary.js.map +1 -0
- package/dist/lib/timeline.d.ts +7 -0
- package/dist/lib/timeline.d.ts.map +1 -1
- package/dist/lib/timeline.js +19 -5
- package/dist/lib/timeline.js.map +1 -1
- package/package.json +7 -1
package/dist/lib/audit.d.ts
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
*
|
|
8
8
|
* Logs are stored in .gnosys/.config/audit.jsonl (append-only).
|
|
9
9
|
*/
|
|
10
|
+
import type { GnosysDB } from "./db.js";
|
|
10
11
|
export interface AuditEntry {
|
|
11
12
|
timestamp: string;
|
|
12
13
|
operation: AuditOperation;
|
|
@@ -36,6 +37,18 @@ export declare function readAuditLog(storePath: string, options?: {
|
|
|
36
37
|
operation?: AuditOperation;
|
|
37
38
|
limit?: number;
|
|
38
39
|
}): AuditEntry[];
|
|
40
|
+
/**
|
|
41
|
+
* v5.7.0: read audit entries from the central DB's audit_log table.
|
|
42
|
+
*
|
|
43
|
+
* The legacy `readAuditLog(storePath)` reads `.gnosys/.config/audit.jsonl`
|
|
44
|
+
* which post-DB-only is empty for most users. This variant queries the
|
|
45
|
+
* central DB directly and returns entries in the same shape.
|
|
46
|
+
*/
|
|
47
|
+
export declare function readAuditFromDb(db: GnosysDB, options?: {
|
|
48
|
+
days?: number;
|
|
49
|
+
operation?: AuditOperation;
|
|
50
|
+
limit?: number;
|
|
51
|
+
}): AuditEntry[];
|
|
39
52
|
/**
|
|
40
53
|
* Format audit entries as a human-readable timeline.
|
|
41
54
|
*/
|
package/dist/lib/audit.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"audit.d.ts","sourceRoot":"","sources":["../../src/lib/audit.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;
|
|
1
|
+
{"version":3,"file":"audit.d.ts","sourceRoot":"","sources":["../../src/lib/audit.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,OAAO,KAAK,EAAE,QAAQ,EAAgB,MAAM,SAAS,CAAC;AAItD,MAAM,WAAW,UAAU;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,cAAc,CAAC;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC;AAED,MAAM,MAAM,cAAc,GACtB,MAAM,GACN,OAAO,GACP,QAAQ,GACR,QAAQ,GACR,WAAW,GACX,WAAW,GACX,SAAS,GACT,UAAU,GACV,QAAQ,GACR,KAAK,GACL,QAAQ,GACR,aAAa,GACb,OAAO,CAAC;AAOZ;;;GAGG;AACH,wBAAgB,SAAS,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAcjD;AAED;;GAEG;AACH,wBAAgB,QAAQ,CACtB,KAAK,EAAE,IAAI,CAAC,UAAU,EAAE,WAAW,CAAC,GACnC,IAAI,CASN;AAED;;GAEG;AACH,wBAAgB,YAAY,CAC1B,SAAS,EAAE,MAAM,EACjB,OAAO,CAAC,EAAE;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,cAAc,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,GACtE,UAAU,EAAE,CAwCd;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAC7B,EAAE,EAAE,QAAQ,EACZ,OAAO,CAAC,EAAE;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,cAAc,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,GACtE,UAAU,EAAE,CAkCd;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,UAAU,EAAE,GAAG,MAAM,CA6CjE;AAED;;GAEG;AACH,wBAAgB,UAAU,IAAI,IAAI,CAKjC"}
|
package/dist/lib/audit.js
CHANGED
|
@@ -80,6 +80,48 @@ export function readAuditLog(storePath, options) {
|
|
|
80
80
|
}
|
|
81
81
|
return entries;
|
|
82
82
|
}
|
|
83
|
+
/**
|
|
84
|
+
* v5.7.0: read audit entries from the central DB's audit_log table.
|
|
85
|
+
*
|
|
86
|
+
* The legacy `readAuditLog(storePath)` reads `.gnosys/.config/audit.jsonl`
|
|
87
|
+
* which post-DB-only is empty for most users. This variant queries the
|
|
88
|
+
* central DB directly and returns entries in the same shape.
|
|
89
|
+
*/
|
|
90
|
+
export function readAuditFromDb(db, options) {
|
|
91
|
+
if (!db.isAvailable())
|
|
92
|
+
return [];
|
|
93
|
+
let sinceIso;
|
|
94
|
+
if (options?.days) {
|
|
95
|
+
const cutoff = new Date();
|
|
96
|
+
cutoff.setDate(cutoff.getDate() - options.days);
|
|
97
|
+
sinceIso = cutoff.toISOString();
|
|
98
|
+
}
|
|
99
|
+
const rows = db.queryAuditLog({
|
|
100
|
+
sinceIso,
|
|
101
|
+
operation: options?.operation,
|
|
102
|
+
limit: options?.limit,
|
|
103
|
+
});
|
|
104
|
+
return rows.map((row) => {
|
|
105
|
+
const detailsParsed = (() => {
|
|
106
|
+
if (!row.details)
|
|
107
|
+
return undefined;
|
|
108
|
+
try {
|
|
109
|
+
return JSON.parse(row.details);
|
|
110
|
+
}
|
|
111
|
+
catch {
|
|
112
|
+
return { raw: row.details };
|
|
113
|
+
}
|
|
114
|
+
})();
|
|
115
|
+
return {
|
|
116
|
+
timestamp: row.timestamp,
|
|
117
|
+
operation: row.operation,
|
|
118
|
+
memoryId: row.memory_id ?? undefined,
|
|
119
|
+
durationMs: row.duration_ms ?? undefined,
|
|
120
|
+
traceId: row.trace_id ?? undefined,
|
|
121
|
+
details: detailsParsed,
|
|
122
|
+
};
|
|
123
|
+
});
|
|
124
|
+
}
|
|
83
125
|
/**
|
|
84
126
|
* Format audit entries as a human-readable timeline.
|
|
85
127
|
*/
|
package/dist/lib/audit.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"audit.js","sourceRoot":"","sources":["../../src/lib/audit.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"audit.js","sourceRoot":"","sources":["../../src/lib/audit.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AAgCxB,2EAA2E;AAE3E,IAAI,aAAa,GAAkB,IAAI,CAAC;AACxC,IAAI,WAAW,GAA0B,IAAI,CAAC;AAE9C;;;GAGG;AACH,MAAM,UAAU,SAAS,CAAC,SAAiB;IACzC,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;IAElD,4DAA4D;IAC5D,IAAI,CAAC;QACH,EAAE,CAAC,SAAS,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC/C,CAAC;IAAC,MAAM,CAAC;QACP,iBAAiB;IACnB,CAAC;IAED,aAAa,GAAG,IAAI,CAAC,IAAI,CAAC,SA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|
2
|
+
* Multi-choice protocol — gnosys-choose fenced YAML.
|
|
3
|
+
*
|
|
4
|
+
* The LLM is taught (via system prompt) to emit a fenced block when it wants
|
|
5
|
+
* the user to pick from a small set of options:
|
|
6
|
+
*
|
|
7
|
+
* ```gnosys-choose
|
|
8
|
+
* prompt: Which approach should we take?
|
|
9
|
+
* options:
|
|
10
|
+
* - id: a
|
|
11
|
+
* label: Refactor in place — keep the same module
|
|
12
|
+
* detail: Lower risk, but the existing API stays awkward
|
|
13
|
+
* - id: b
|
|
14
|
+
* label: Extract to a new module
|
|
15
|
+
* detail: Cleaner separation; one-time migration cost
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* The TUI parses the fence after the assistant turn completes, renders an
|
|
19
|
+
* arrow-key selectable list, and on selection injects a synthetic user turn
|
|
20
|
+
* "[picked: <id> — <label>]" before running the next LLM call.
|
|
21
|
+
*
|
|
22
|
+
* The protocol works in reverse too — TUI helpers can pose multiple-choice
|
|
23
|
+
* questions to the user using the same parser/renderer pieces.
|
|
24
|
+
*
|
|
25
|
+
* Failures are soft: a malformed fence renders as plain text in the
|
|
26
|
+
* conversation buffer. We log a `chat_choose_parse_error` style notice so
|
|
27
|
+
* agents can debug without blocking the chat.
|
|
28
|
+
*/
|
|
29
|
+
export interface ChooseOption {
|
|
30
|
+
id: string;
|
|
31
|
+
label: string;
|
|
32
|
+
detail?: string;
|
|
33
|
+
}
|
|
34
|
+
export interface ChooseBlock {
|
|
35
|
+
prompt: string;
|
|
36
|
+
options: ChooseOption[];
|
|
37
|
+
}
|
|
38
|
+
/** System prompt addendum that teaches the LLM the fence syntax. */
|
|
39
|
+
export declare const CHOOSE_SYSTEM_PROMPT_ADDENDUM = "\nWhen you want the user to pick from a SHORT set of options (2\u20136), emit a fenced block:\n\n```gnosys-choose\nprompt: <one-line question>\noptions:\n - id: a\n label: <short>\n detail: <one-line context, optional>\n - id: b\n label: <short>\n```\n\nUse this only when a discrete choice will materially change what you do next. Don't use it for yes/no \u2014 just ask in prose. Don't use it to summarize options that the user has already chosen between.";
|
|
40
|
+
/**
|
|
41
|
+
* Find the first gnosys-choose fence in a text and parse it. Returns
|
|
42
|
+
* - { block, before, after } when a well-formed fence is present
|
|
43
|
+
* - { error } when a fence exists but failed to parse
|
|
44
|
+
* - null when no fence is present
|
|
45
|
+
*/
|
|
46
|
+
export type ExtractResult = {
|
|
47
|
+
kind: "ok";
|
|
48
|
+
block: ChooseBlock;
|
|
49
|
+
before: string;
|
|
50
|
+
after: string;
|
|
51
|
+
} | {
|
|
52
|
+
kind: "parse-error";
|
|
53
|
+
before: string;
|
|
54
|
+
rawFence: string;
|
|
55
|
+
after: string;
|
|
56
|
+
reason: string;
|
|
57
|
+
} | null;
|
|
58
|
+
export declare function extractChooseFence(text: string): ExtractResult;
|
|
59
|
+
/**
|
|
60
|
+
* Hand-rolled YAML parser for the minimal gnosys-choose schema.
|
|
61
|
+
* No external dependency. Tolerates Windows line endings and trailing whitespace.
|
|
62
|
+
*
|
|
63
|
+
* Accepts:
|
|
64
|
+
* prompt: <text> # one-line scalar
|
|
65
|
+
* options: # list literal follows
|
|
66
|
+
* - id: <token>
|
|
67
|
+
* label: <text>
|
|
68
|
+
* detail: <text> # optional
|
|
69
|
+
* - id: <token>
|
|
70
|
+
* label: <text>
|
|
71
|
+
*/
|
|
72
|
+
export declare function parseChooseYaml(yaml: string): ChooseBlock;
|
|
73
|
+
/** Format a user's selection as a synthetic user turn. */
|
|
74
|
+
export declare function formatSelection(option: ChooseOption): string;
|
|
75
|
+
//# sourceMappingURL=choose.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"choose.d.ts","sourceRoot":"","sources":["../../../src/lib/chat/choose.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,YAAY,EAAE,CAAC;CACzB;AAED,oEAAoE;AACpE,eAAO,MAAM,6BAA6B,ydAa6J,CAAC;AAIxM;;;;;GAKG;AACH,MAAM,MAAM,aAAa,GACrB;IAAE,IAAI,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,WAAW,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GACjE;IAAE,IAAI,EAAE,aAAa,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GACxF,IAAI,CAAC;AAET,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,CA+B9D;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,CAsDzD;AAED,0DAA0D;AAC1D,wBAAgB,eAAe,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM,CAG5D"}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Multi-choice protocol — gnosys-choose fenced YAML.
|
|
3
|
+
*
|
|
4
|
+
* The LLM is taught (via system prompt) to emit a fenced block when it wants
|
|
5
|
+
* the user to pick from a small set of options:
|
|
6
|
+
*
|
|
7
|
+
* ```gnosys-choose
|
|
8
|
+
* prompt: Which approach should we take?
|
|
9
|
+
* options:
|
|
10
|
+
* - id: a
|
|
11
|
+
* label: Refactor in place — keep the same module
|
|
12
|
+
* detail: Lower risk, but the existing API stays awkward
|
|
13
|
+
* - id: b
|
|
14
|
+
* label: Extract to a new module
|
|
15
|
+
* detail: Cleaner separation; one-time migration cost
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* The TUI parses the fence after the assistant turn completes, renders an
|
|
19
|
+
* arrow-key selectable list, and on selection injects a synthetic user turn
|
|
20
|
+
* "[picked: <id> — <label>]" before running the next LLM call.
|
|
21
|
+
*
|
|
22
|
+
* The protocol works in reverse too — TUI helpers can pose multiple-choice
|
|
23
|
+
* questions to the user using the same parser/renderer pieces.
|
|
24
|
+
*
|
|
25
|
+
* Failures are soft: a malformed fence renders as plain text in the
|
|
26
|
+
* conversation buffer. We log a `chat_choose_parse_error` style notice so
|
|
27
|
+
* agents can debug without blocking the chat.
|
|
28
|
+
*/
|
|
29
|
+
/** System prompt addendum that teaches the LLM the fence syntax. */
|
|
30
|
+
export const CHOOSE_SYSTEM_PROMPT_ADDENDUM = `
|
|
31
|
+
When you want the user to pick from a SHORT set of options (2–6), emit a fenced block:
|
|
32
|
+
|
|
33
|
+
\`\`\`gnosys-choose
|
|
34
|
+
prompt: <one-line question>
|
|
35
|
+
options:
|
|
36
|
+
- id: a
|
|
37
|
+
label: <short>
|
|
38
|
+
detail: <one-line context, optional>
|
|
39
|
+
- id: b
|
|
40
|
+
label: <short>
|
|
41
|
+
\`\`\`
|
|
42
|
+
|
|
43
|
+
Use this only when a discrete choice will materially change what you do next. Don't use it for yes/no — just ask in prose. Don't use it to summarize options that the user has already chosen between.`;
|
|
44
|
+
const FENCE_OPEN = /```\s*gnosys-choose\s*\n([\s\S]*?)```/;
|
|
45
|
+
export function extractChooseFence(text) {
|
|
46
|
+
const match = text.match(FENCE_OPEN);
|
|
47
|
+
if (!match)
|
|
48
|
+
return null;
|
|
49
|
+
const fenceContent = match[1].trim();
|
|
50
|
+
const start = match.index ?? 0;
|
|
51
|
+
const end = start + match[0].length;
|
|
52
|
+
const before = text.slice(0, start).trimEnd();
|
|
53
|
+
const after = text.slice(end).trimStart();
|
|
54
|
+
try {
|
|
55
|
+
const block = parseChooseYaml(fenceContent);
|
|
56
|
+
if (!block.prompt || block.options.length === 0) {
|
|
57
|
+
return {
|
|
58
|
+
kind: "parse-error",
|
|
59
|
+
before,
|
|
60
|
+
rawFence: match[0],
|
|
61
|
+
after,
|
|
62
|
+
reason: "missing prompt or empty options",
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
return { kind: "ok", block, before, after };
|
|
66
|
+
}
|
|
67
|
+
catch (err) {
|
|
68
|
+
return {
|
|
69
|
+
kind: "parse-error",
|
|
70
|
+
before,
|
|
71
|
+
rawFence: match[0],
|
|
72
|
+
after,
|
|
73
|
+
reason: err instanceof Error ? err.message : String(err),
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Hand-rolled YAML parser for the minimal gnosys-choose schema.
|
|
79
|
+
* No external dependency. Tolerates Windows line endings and trailing whitespace.
|
|
80
|
+
*
|
|
81
|
+
* Accepts:
|
|
82
|
+
* prompt: <text> # one-line scalar
|
|
83
|
+
* options: # list literal follows
|
|
84
|
+
* - id: <token>
|
|
85
|
+
* label: <text>
|
|
86
|
+
* detail: <text> # optional
|
|
87
|
+
* - id: <token>
|
|
88
|
+
* label: <text>
|
|
89
|
+
*/
|
|
90
|
+
export function parseChooseYaml(yaml) {
|
|
91
|
+
const lines = yaml.replace(/\r\n/g, "\n").split("\n");
|
|
92
|
+
let prompt = "";
|
|
93
|
+
const options = [];
|
|
94
|
+
let inOptions = false;
|
|
95
|
+
let current = null;
|
|
96
|
+
for (let i = 0; i < lines.length; i++) {
|
|
97
|
+
const line = lines[i];
|
|
98
|
+
if (!line.trim())
|
|
99
|
+
continue;
|
|
100
|
+
// Top-level "prompt:" line
|
|
101
|
+
if (!inOptions) {
|
|
102
|
+
const m = line.match(/^prompt:\s*(.+?)\s*$/);
|
|
103
|
+
if (m) {
|
|
104
|
+
prompt = m[1];
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
107
|
+
if (/^options:\s*$/.test(line)) {
|
|
108
|
+
inOptions = true;
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
111
|
+
// Unknown top-level field — skip (forward-compat)
|
|
112
|
+
continue;
|
|
113
|
+
}
|
|
114
|
+
// Inside options:
|
|
115
|
+
const itemStart = line.match(/^\s*-\s*id:\s*(.+?)\s*$/);
|
|
116
|
+
if (itemStart) {
|
|
117
|
+
// Push previous item if any
|
|
118
|
+
if (current && current.label)
|
|
119
|
+
options.push(current);
|
|
120
|
+
current = { id: itemStart[1], label: "" };
|
|
121
|
+
continue;
|
|
122
|
+
}
|
|
123
|
+
if (!current)
|
|
124
|
+
continue;
|
|
125
|
+
const labelMatch = line.match(/^\s*label:\s*(.+?)\s*$/);
|
|
126
|
+
if (labelMatch) {
|
|
127
|
+
current.label = labelMatch[1];
|
|
128
|
+
continue;
|
|
129
|
+
}
|
|
130
|
+
const detailMatch = line.match(/^\s*detail:\s*(.+?)\s*$/);
|
|
131
|
+
if (detailMatch) {
|
|
132
|
+
current.detail = detailMatch[1];
|
|
133
|
+
continue;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
// Flush the last option
|
|
137
|
+
if (current && current.label)
|
|
138
|
+
options.push(current);
|
|
139
|
+
return { prompt, options };
|
|
140
|
+
}
|
|
141
|
+
/** Format a user's selection as a synthetic user turn. */
|
|
142
|
+
export function formatSelection(option) {
|
|
143
|
+
const detail = option.detail ? ` (${option.detail})` : "";
|
|
144
|
+
return `[picked: ${option.id} — ${option.label}${detail}]`;
|
|
145
|
+
}
|
|
146
|
+
//# sourceMappingURL=choose.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"choose.js","sourceRoot":"","sources":["../../../src/lib/chat/choose.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAaH,oEAAoE;AACpE,MAAM,CAAC,MAAM,6BAA6B,GAAG;;;;;;;;;;;;;uMAa0J,CAAC;AAExM,MAAM,UAAU,GAAG,uCAAuC,CAAC;AAa3D,MAAM,UAAU,kBAAkB,CAAC,IAAY;IAC7C,MAAM,KAAK,GAAG,IAA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AM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,wBAAwB,CAAC,CAAC;QACxD,IAAI,UAAU,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC;YAC9B,SAAS;QACX,CAAC;QAED,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,yBAAyB,CAAC,CAAC;QAC1D,IAAI,WAAW,EAAE,CAAC;YAChB,OAAO,CAAC,MAAM,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC;YAChC,SAAS;QACX,CAAC;IACH,CAAC;IAED,wBAAwB;IACxB,IAAI,OAAO,IAAI,OAAO,CAAC,KAAK;QAAE,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAEpD,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;AAC7B,CAAC;AAED,0DAA0D;AAC1D,MAAM,UAAU,eAAe,CAAC,MAAoB;IAClD,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;IAC1D,OAAO,YAAY,MAAM,CAAC,EAAE,MAAM,MAAM,CAAC,KAAK,GAAG,MAAM,GAAG,CAAC;AAC7D,CAAC"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Slash command dispatcher for the chat TUI.
|
|
3
|
+
*
|
|
4
|
+
* Each command receives the chat state and returns a result describing what
|
|
5
|
+
* happened. The TUI translates the result into UI updates (system messages,
|
|
6
|
+
* exit, conversation buffer changes, etc.). Commands run synchronously when
|
|
7
|
+
* possible; async ones return a Promise.
|
|
8
|
+
*
|
|
9
|
+
* Phase 2 commands: /help, /clear, /history, /read, /list, /tags, /dashboard,
|
|
10
|
+
* /quit, /provider. Phases 3–7 add /pin, /scope, /recall, /threshold,
|
|
11
|
+
* /reinforce, /remember, /save-turn, /attach, /focus, /branch, /resume-focus,
|
|
12
|
+
* /dream-here, /search-chats, /export.
|
|
13
|
+
*/
|
|
14
|
+
import { Turn } from "./types.js";
|
|
15
|
+
export interface CommandContext {
|
|
16
|
+
/** Current session ID. */
|
|
17
|
+
sessionId: string;
|
|
18
|
+
/** Conversation buffer as the LLM sees it. Commands may read or mutate (via the result's nextBuffer). */
|
|
19
|
+
buffer: Turn[];
|
|
20
|
+
/** Current provider name. */
|
|
21
|
+
provider: string;
|
|
22
|
+
/** Current model. */
|
|
23
|
+
model: string;
|
|
24
|
+
}
|
|
25
|
+
export type CommandResult = {
|
|
26
|
+
kind: "ok";
|
|
27
|
+
message?: string;
|
|
28
|
+
} | {
|
|
29
|
+
kind: "clear-buffer";
|
|
30
|
+
} | {
|
|
31
|
+
kind: "exit";
|
|
32
|
+
} | {
|
|
33
|
+
kind: "switch-provider";
|
|
34
|
+
provider: string;
|
|
35
|
+
model?: string;
|
|
36
|
+
} | {
|
|
37
|
+
kind: "show";
|
|
38
|
+
lines: string[];
|
|
39
|
+
} | {
|
|
40
|
+
kind: "pin";
|
|
41
|
+
memoryId: string;
|
|
42
|
+
} | {
|
|
43
|
+
kind: "unpin";
|
|
44
|
+
memoryId: string;
|
|
45
|
+
} | {
|
|
46
|
+
kind: "scope";
|
|
47
|
+
scope: "project" | "user" | "global" | "federated";
|
|
48
|
+
} | {
|
|
49
|
+
kind: "threshold";
|
|
50
|
+
value: number;
|
|
51
|
+
} | {
|
|
52
|
+
kind: "preview-recall";
|
|
53
|
+
query: string;
|
|
54
|
+
} | {
|
|
55
|
+
kind: "reinforce";
|
|
56
|
+
memoryId: string;
|
|
57
|
+
} | {
|
|
58
|
+
kind: "remember";
|
|
59
|
+
text: string;
|
|
60
|
+
} | {
|
|
61
|
+
kind: "save-turn";
|
|
62
|
+
} | {
|
|
63
|
+
kind: "attach";
|
|
64
|
+
filePath: string;
|
|
65
|
+
} | {
|
|
66
|
+
kind: "focus";
|
|
67
|
+
topic: string;
|
|
68
|
+
} | {
|
|
69
|
+
kind: "branch";
|
|
70
|
+
} | {
|
|
71
|
+
kind: "resume-focus";
|
|
72
|
+
topic?: string;
|
|
73
|
+
} | {
|
|
74
|
+
kind: "export-session";
|
|
75
|
+
filePath: string;
|
|
76
|
+
} | {
|
|
77
|
+
kind: "search-chats";
|
|
78
|
+
query: string;
|
|
79
|
+
} | {
|
|
80
|
+
kind: "dream-here";
|
|
81
|
+
} | {
|
|
82
|
+
kind: "error";
|
|
83
|
+
message: string;
|
|
84
|
+
};
|
|
85
|
+
export interface CommandSpec {
|
|
86
|
+
name: string;
|
|
87
|
+
aliases?: string[];
|
|
88
|
+
summary: string;
|
|
89
|
+
usage?: string;
|
|
90
|
+
handler: (ctx: CommandContext, args: string[]) => CommandResult | Promise<CommandResult>;
|
|
91
|
+
}
|
|
92
|
+
export declare function listCommands(): CommandSpec[];
|
|
93
|
+
export declare function findCommand(name: string): CommandSpec | undefined;
|
|
94
|
+
/** Parse a raw input line and dispatch if it's a slash command. Returns null if it's not a command. */
|
|
95
|
+
export declare function dispatchCommand(raw: string, ctx: CommandContext): Promise<CommandResult | null>;
|
|
96
|
+
//# sourceMappingURL=commands.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../../../src/lib/chat/commands.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAElC,MAAM,WAAW,cAAc;IAC7B,0BAA0B;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,yGAAyG;IACzG,MAAM,EAAE,IAAI,EAAE,CAAC;IACf,6BAA6B;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,qBAAqB;IACrB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,MAAM,aAAa,GACrB;IAAE,IAAI,EAAE,IAAI,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,GAChC;IAAE,IAAI,EAAE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