opencode-sat 0.0.12

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 (79) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +180 -0
  3. package/dist/sat.d.ts +4 -0
  4. package/dist/sat.d.ts.map +1 -0
  5. package/dist/sat.js +62 -0
  6. package/dist/sat.js.map +1 -0
  7. package/dist/src/append.d.ts +23 -0
  8. package/dist/src/append.d.ts.map +1 -0
  9. package/dist/src/append.js +57 -0
  10. package/dist/src/append.js.map +1 -0
  11. package/dist/src/discover.d.ts +11 -0
  12. package/dist/src/discover.d.ts.map +1 -0
  13. package/dist/src/discover.js +98 -0
  14. package/dist/src/discover.js.map +1 -0
  15. package/dist/src/format-prompt.d.ts +3 -0
  16. package/dist/src/format-prompt.d.ts.map +1 -0
  17. package/dist/src/format-prompt.js +92 -0
  18. package/dist/src/format-prompt.js.map +1 -0
  19. package/dist/src/opencode/notify.d.ts +10 -0
  20. package/dist/src/opencode/notify.d.ts.map +1 -0
  21. package/dist/src/opencode/notify.js +14 -0
  22. package/dist/src/opencode/notify.js.map +1 -0
  23. package/dist/src/process-prompt.d.ts +21 -0
  24. package/dist/src/process-prompt.d.ts.map +1 -0
  25. package/dist/src/process-prompt.js +20 -0
  26. package/dist/src/process-prompt.js.map +1 -0
  27. package/dist/src/process.d.ts +26 -0
  28. package/dist/src/process.d.ts.map +1 -0
  29. package/dist/src/process.js +56 -0
  30. package/dist/src/process.js.map +1 -0
  31. package/dist/src/prompt-prompt.d.ts +3 -0
  32. package/dist/src/prompt-prompt.d.ts.map +1 -0
  33. package/dist/src/prompt-prompt.js +47 -0
  34. package/dist/src/prompt-prompt.js.map +1 -0
  35. package/dist/src/prompt-schema.d.ts +22 -0
  36. package/dist/src/prompt-schema.d.ts.map +1 -0
  37. package/dist/src/prompt-schema.js +33 -0
  38. package/dist/src/prompt-schema.js.map +1 -0
  39. package/dist/src/prompt.d.ts +7 -0
  40. package/dist/src/prompt.d.ts.map +1 -0
  41. package/dist/src/prompt.js +84 -0
  42. package/dist/src/prompt.js.map +1 -0
  43. package/dist/src/resolve.d.ts +4 -0
  44. package/dist/src/resolve.d.ts.map +1 -0
  45. package/dist/src/resolve.js +19 -0
  46. package/dist/src/resolve.js.map +1 -0
  47. package/dist/src/rule-schema.d.ts +69 -0
  48. package/dist/src/rule-schema.d.ts.map +1 -0
  49. package/dist/src/rule-schema.js +47 -0
  50. package/dist/src/rule-schema.js.map +1 -0
  51. package/dist/src/session.d.ts +23 -0
  52. package/dist/src/session.d.ts.map +1 -0
  53. package/dist/src/session.js +112 -0
  54. package/dist/src/session.js.map +1 -0
  55. package/dist/src/tools.d.ts +59 -0
  56. package/dist/src/tools.d.ts.map +1 -0
  57. package/dist/src/tools.js +221 -0
  58. package/dist/src/tools.js.map +1 -0
  59. package/dist/src/utils/compare.d.ts +23 -0
  60. package/dist/src/utils/compare.d.ts.map +1 -0
  61. package/dist/src/utils/compare.js +116 -0
  62. package/dist/src/utils/compare.js.map +1 -0
  63. package/dist/src/utils/extractLlmError.d.ts +13 -0
  64. package/dist/src/utils/extractLlmError.d.ts.map +1 -0
  65. package/dist/src/utils/extractLlmError.js +12 -0
  66. package/dist/src/utils/extractLlmError.js.map +1 -0
  67. package/dist/src/utils/safe.d.ts +14 -0
  68. package/dist/src/utils/safe.d.ts.map +1 -0
  69. package/dist/src/utils/safe.js +31 -0
  70. package/dist/src/utils/safe.js.map +1 -0
  71. package/dist/src/utils/stripCodeFences.d.ts +2 -0
  72. package/dist/src/utils/stripCodeFences.d.ts.map +1 -0
  73. package/dist/src/utils/stripCodeFences.js +9 -0
  74. package/dist/src/utils/stripCodeFences.js.map +1 -0
  75. package/dist/src/utils/validate.d.ts +19 -0
  76. package/dist/src/utils/validate.d.ts.map +1 -0
  77. package/dist/src/utils/validate.js +30 -0
  78. package/dist/src/utils/validate.js.map +1 -0
  79. package/package.json +59 -0
@@ -0,0 +1,21 @@
1
+ import type { z } from 'zod';
2
+ import type { Result } from './utils/safe';
3
+ import type { ParsedPrompt } from './prompt-schema';
4
+ type PromptFn = <T>(prompt: string, schema: z.ZodType<T>) => Promise<Result<T>>;
5
+ type ProcessPromptOptions = {
6
+ input: string;
7
+ prompt: PromptFn;
8
+ };
9
+ type PromptSuccess = {
10
+ status: 'success';
11
+ formatted: string;
12
+ parsed: ParsedPrompt;
13
+ };
14
+ type PromptParseError = {
15
+ status: 'parseError';
16
+ error: string;
17
+ };
18
+ type PromptResult = PromptSuccess | PromptParseError;
19
+ export declare const processPrompt: (options: ProcessPromptOptions) => Promise<PromptResult>;
20
+ export {};
21
+ //# sourceMappingURL=process-prompt.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"process-prompt.d.ts","sourceRoot":"","sources":["../../src/process-prompt.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAC5B,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAC1C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAKnD,KAAK,QAAQ,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAA;AAE/E,KAAK,oBAAoB,GAAG;IAC1B,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,QAAQ,CAAA;CACjB,CAAA;AAED,KAAK,aAAa,GAAG;IACnB,MAAM,EAAE,SAAS,CAAA;IACjB,SAAS,EAAE,MAAM,CAAA;IACjB,MAAM,EAAE,YAAY,CAAA;CACrB,CAAA;AAED,KAAK,gBAAgB,GAAG;IACtB,MAAM,EAAE,YAAY,CAAA;IACpB,KAAK,EAAE,MAAM,CAAA;CACd,CAAA;AAED,KAAK,YAAY,GAAG,aAAa,GAAG,gBAAgB,CAAA;AAEpD,eAAO,MAAM,aAAa,GAAU,SAAS,oBAAoB,KAAG,OAAO,CAAC,YAAY,CAiBvF,CAAA"}
@@ -0,0 +1,20 @@
1
+ import { ParsedPromptSchema } from './prompt-schema';
2
+ import { buildPromptParsePrompt } from './prompt-prompt';
3
+ import { formatPrompt } from './format-prompt';
4
+ export const processPrompt = async (options) => {
5
+ const parsePrompt = buildPromptParsePrompt(options.input);
6
+ const parseResult = await options.prompt(parsePrompt, ParsedPromptSchema);
7
+ if (!parseResult.data) {
8
+ return {
9
+ status: 'parseError',
10
+ error: parseResult.error,
11
+ };
12
+ }
13
+ const formatted = formatPrompt(parseResult.data);
14
+ return {
15
+ status: 'success',
16
+ formatted,
17
+ parsed: parseResult.data,
18
+ };
19
+ };
20
+ //# sourceMappingURL=process-prompt.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"process-prompt.js","sourceRoot":"","sources":["../../src/process-prompt.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AACpD,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAA;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAsB9C,MAAM,CAAC,MAAM,aAAa,GAAG,KAAK,EAAE,OAA6B,EAAyB,EAAE;IAC1F,MAAM,WAAW,GAAG,sBAAsB,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;IACzD,MAAM,WAAW,GAAG,MAAM,OAAO,CAAC,MAAM,CAAC,WAAW,EAAE,kBAAkB,CAAC,CAAA;IACzE,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC;QACtB,OAAO;YACL,MAAM,EAAE,YAAY;YACpB,KAAK,EAAE,WAAW,CAAC,KAAK;SACzB,CAAA;IACH,CAAC;IAED,MAAM,SAAS,GAAG,YAAY,CAAC,WAAW,CAAC,IAAI,CAAC,CAAA;IAEhD,OAAO;QACL,MAAM,EAAE,SAAS;QACjB,SAAS;QACT,MAAM,EAAE,WAAW,CAAC,IAAI;KACzB,CAAA;AACH,CAAC,CAAA"}
@@ -0,0 +1,26 @@
1
+ import type { z } from 'zod';
2
+ import type { InstructionFile } from './discover';
3
+ import { type FormatMode } from './prompt';
4
+ import { type ComparisonResult } from './utils/compare';
5
+ import type { Result } from './utils/safe';
6
+ type FileResultSuccess = {
7
+ status: 'success';
8
+ path: string;
9
+ rulesCount: number;
10
+ comparison: ComparisonResult;
11
+ };
12
+ type FileResultError = {
13
+ status: 'readError' | 'parseError' | 'formatError' | 'writeError';
14
+ path: string;
15
+ error: string;
16
+ };
17
+ export type FileResult = FileResultSuccess | FileResultError;
18
+ export type PromptFn = <T>(prompt: string, schema: z.ZodType<T>) => Promise<Result<T>>;
19
+ type ProcessFileOptions = {
20
+ file: InstructionFile;
21
+ prompt: PromptFn;
22
+ mode?: FormatMode;
23
+ };
24
+ export declare const processFile: (options: ProcessFileOptions) => Promise<FileResult>;
25
+ export {};
26
+ //# sourceMappingURL=process.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"process.d.ts","sourceRoot":"","sources":["../../src/process.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAC5B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AACjD,OAAO,EAAuC,KAAK,UAAU,EAAE,MAAM,UAAU,CAAA;AAE/E,OAAO,EAAgB,KAAK,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AACrE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAG1C,KAAK,iBAAiB,GAAG;IACvB,MAAM,EAAE,SAAS,CAAA;IACjB,IAAI,EAAE,MAAM,CAAA;IACZ,UAAU,EAAE,MAAM,CAAA;IAClB,UAAU,EAAE,gBAAgB,CAAA;CAC7B,CAAA;AAED,KAAK,eAAe,GAAG;IACrB,MAAM,EAAE,WAAW,GAAG,YAAY,GAAG,aAAa,GAAG,YAAY,CAAA;IACjE,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;CACd,CAAA;AAED,MAAM,MAAM,UAAU,GAAG,iBAAiB,GAAG,eAAe,CAAA;AAG5D,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAA;AAEtF,KAAK,kBAAkB,GAAG;IACxB,IAAI,EAAE,eAAe,CAAA;IACrB,MAAM,EAAE,QAAQ,CAAA;IAChB,IAAI,CAAC,EAAE,UAAU,CAAA;CAClB,CAAA;AAGD,eAAO,MAAM,WAAW,GAAU,SAAS,kBAAkB,KAAG,OAAO,CAAC,UAAU,CAsDjF,CAAA"}
@@ -0,0 +1,56 @@
1
+ import { writeFile } from 'node:fs/promises';
2
+ import { basename } from 'node:path';
3
+ import { buildFormatPrompt, buildParsePrompt } from './prompt';
4
+ import { FormatResponseSchema, ParseResponseSchema } from './rule-schema';
5
+ import { compareBytes } from './utils/compare';
6
+ import { safeAsync } from './utils/safe';
7
+ // process a single instruction file through the parse -> format -> write pipeline
8
+ export const processFile = async (options) => {
9
+ const mode = options.mode ?? 'balanced';
10
+ // skip files that failed to read
11
+ if (options.file.error) {
12
+ return {
13
+ status: 'readError',
14
+ path: options.file.path,
15
+ error: options.file.error,
16
+ };
17
+ }
18
+ // step 1: parse instruction text -> structured rules
19
+ const parseResult = await options.prompt(buildParsePrompt(options.file.content), ParseResponseSchema);
20
+ if (parseResult.error !== null) {
21
+ return {
22
+ status: 'parseError',
23
+ path: options.file.path,
24
+ error: String(parseResult.error),
25
+ };
26
+ }
27
+ // step 2: format structured rules -> human-readable rules
28
+ const formatResult = await options.prompt(buildFormatPrompt(JSON.stringify(parseResult.data), mode), FormatResponseSchema);
29
+ if (formatResult.error !== null) {
30
+ return {
31
+ status: 'formatError',
32
+ path: options.file.path,
33
+ error: String(formatResult.error),
34
+ };
35
+ }
36
+ // step 3: write formatted rules back to original file
37
+ const formattedRules = formatResult.data.rules;
38
+ const joiner = mode === 'concise' ? '\n' : '\n\n';
39
+ const content = formattedRules.join(joiner) + '\n';
40
+ const writeResult = await safeAsync(() => writeFile(options.file.path, content, 'utf-8'));
41
+ if (writeResult.error) {
42
+ return {
43
+ status: 'writeError',
44
+ path: options.file.path,
45
+ error: writeResult.error.message,
46
+ };
47
+ }
48
+ const comparison = compareBytes(basename(options.file.path), options.file.content, content);
49
+ return {
50
+ status: 'success',
51
+ path: options.file.path,
52
+ rulesCount: formattedRules.length,
53
+ comparison,
54
+ };
55
+ };
56
+ //# sourceMappingURL=process.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"process.js","sourceRoot":"","sources":["../../src/process.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AAGpC,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAmB,MAAM,UAAU,CAAA;AAC/E,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAA;AACzE,OAAO,EAAE,YAAY,EAAyB,MAAM,iBAAiB,CAAA;AAErE,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AA0BxC,kFAAkF;AAClF,MAAM,CAAC,MAAM,WAAW,GAAG,KAAK,EAAE,OAA2B,EAAuB,EAAE;IACpF,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,IAAI,UAAU,CAAA;IAEvC,iCAAiC;IACjC,IAAI,OAAO,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;QACvB,OAAO;YACL,MAAM,EAAE,WAAW;YACnB,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,IAAI;YACvB,KAAK,EAAE,OAAO,CAAC,IAAI,CAAC,KAAK;SAC1B,CAAA;IACH,CAAC;IAED,qDAAqD;IACrD,MAAM,WAAW,GAAG,MAAM,OAAO,CAAC,MAAM,CAAC,gBAAgB,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,mBAAmB,CAAC,CAAA;IAErG,IAAI,WAAW,CAAC,KAAK,KAAK,IAAI,EAAE,CAAC;QAC/B,OAAO;YACL,MAAM,EAAE,YAAY;YACpB,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,IAAI;YACvB,KAAK,EAAE,MAAM,CAAC,WAAW,CAAC,KAAK,CAAC;SACjC,CAAA;IACH,CAAC;IAED,0DAA0D;IAC1D,MAAM,YAAY,GAAG,MAAM,OAAO,CAAC,MAAM,CAAC,iBAAiB,CAAC,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,EAAE,oBAAoB,CAAC,CAAA;IAE1H,IAAI,YAAY,CAAC,KAAK,KAAK,IAAI,EAAE,CAAC;QAChC,OAAO;YACL,MAAM,EAAE,aAAa;YACrB,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,IAAI;YACvB,KAAK,EAAE,MAAM,CAAC,YAAY,CAAC,KAAK,CAAC;SAClC,CAAA;IACH,CAAC;IAED,sDAAsD;IACtD,MAAM,cAAc,GAAG,YAAY,CAAC,IAAI,CAAC,KAAK,CAAA;IAC9C,MAAM,MAAM,GAAG,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAA;IACjD,MAAM,OAAO,GAAG,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,IAAI,CAAA;IAClD,MAAM,WAAW,GAAG,MAAM,SAAS,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAA;IACzF,IAAI,WAAW,CAAC,KAAK,EAAE,CAAC;QACtB,OAAO;YACL,MAAM,EAAE,YAAY;YACpB,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,IAAI;YACvB,KAAK,EAAE,WAAW,CAAC,KAAK,CAAC,OAAO;SACjC,CAAA;IACH,CAAC;IAED,MAAM,UAAU,GAAG,YAAY,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;IAC3F,OAAO;QACL,MAAM,EAAE,SAAS;QACjB,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,IAAI;QACvB,UAAU,EAAE,cAAc,CAAC,MAAM;QACjC,UAAU;KACX,CAAA;AACH,CAAC,CAAA"}
@@ -0,0 +1,3 @@
1
+ export declare const buildPromptParsePrompt: (input: string) => string;
2
+ export declare const buildPromptRetryPrompt: (errorMessage: string) => string;
3
+ //# sourceMappingURL=prompt-prompt.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompt-prompt.d.ts","sourceRoot":"","sources":["../../src/prompt-prompt.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,sBAAsB,GAAI,OAAO,MAAM,KAAG,MAoCtD,CAAA;AAED,eAAO,MAAM,sBAAsB,GAAI,cAAc,MAAM,KAAG,MAQ7D,CAAA"}
@@ -0,0 +1,47 @@
1
+ import { promptSchemaExample } from './prompt-schema';
2
+ export const buildPromptParsePrompt = (input) => {
3
+ const instructions = [
4
+ 'You are a prompt structuring system.',
5
+ 'Your job is to take raw, unstructured user input and decompose it into a structured task hierarchy.',
6
+ 'The input may be messy, from voice transcription, contain filler words, or have multiple requests mixed together.',
7
+ '',
8
+ 'Decompose the input into tasks. Each task has:',
9
+ '- intent: a clear, concise directive (what to do)',
10
+ '- targets: files, systems, or things involved (array, can be empty)',
11
+ '- constraints: conditions, preferences, or requirements (array, can be empty)',
12
+ '- context: optional background info or rationale',
13
+ '- subtasks: recursive array of child tasks (empty if the task is a leaf)',
14
+ '',
15
+ 'Guidelines:',
16
+ '- Extract the actual intent behind the words, not the words themselves.',
17
+ '- Separate compound requests into multiple top-level tasks.',
18
+ '- When a task has clear sub-steps, decompose into subtasks.',
19
+ '- Preserve specific file names, variable names, and technical terms exactly as stated.',
20
+ '- Drop filler words, false starts, and verbal noise.',
21
+ '- If the user mentions constraints or preferences, attach them to the relevant task.',
22
+ '- If context or rationale is provided, capture it in the context field.',
23
+ '- Keep intents as imperative directives (start with a verb).',
24
+ '',
25
+ 'Return JSON matching this schema:',
26
+ promptSchemaExample,
27
+ '',
28
+ 'Return ONLY valid JSON.',
29
+ 'Do not wrap the response in markdown code fences.',
30
+ ];
31
+ return [
32
+ instructions.join('\n'),
33
+ '---',
34
+ 'User input:',
35
+ input,
36
+ ].join('\n');
37
+ };
38
+ export const buildPromptRetryPrompt = (errorMessage) => {
39
+ return [
40
+ 'The previous response failed validation:',
41
+ errorMessage,
42
+ '',
43
+ 'Return ONLY valid JSON matching the schema.',
44
+ 'Do not wrap the response in markdown code fences.',
45
+ ].join('\n');
46
+ };
47
+ //# sourceMappingURL=prompt-prompt.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompt-prompt.js","sourceRoot":"","sources":["../../src/prompt-prompt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AAErD,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,KAAa,EAAU,EAAE;IAC9D,MAAM,YAAY,GAAG;QACnB,sCAAsC;QACtC,qGAAqG;QACrG,mHAAmH;QACnH,EAAE;QACF,gDAAgD;QAChD,mDAAmD;QACnD,qEAAqE;QACrE,+EAA+E;QAC/E,kDAAkD;QAClD,0EAA0E;QAC1E,EAAE;QACF,aAAa;QACb,yEAAyE;QACzE,6DAA6D;QAC7D,6DAA6D;QAC7D,wFAAwF;QACxF,sDAAsD;QACtD,sFAAsF;QACtF,yEAAyE;QACzE,8DAA8D;QAC9D,EAAE;QACF,mCAAmC;QACnC,mBAAmB;QACnB,EAAE;QACF,yBAAyB;QACzB,mDAAmD;KACpD,CAAA;IAED,OAAO;QACL,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC;QACvB,KAAK;QACL,aAAa;QACb,KAAK;KACN,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AACd,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,YAAoB,EAAU,EAAE;IACrE,OAAO;QACL,0CAA0C;QAC1C,YAAY;QACZ,EAAE;QACF,6CAA6C;QAC7C,mDAAmD;KACpD,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AACd,CAAC,CAAA"}
@@ -0,0 +1,22 @@
1
+ import { z } from 'zod';
2
+ export declare const IntentSchema: z.ZodString;
3
+ export declare const TaskTargetsSchema: z.ZodArray<z.ZodString>;
4
+ export declare const ConstraintsSchema: z.ZodArray<z.ZodString>;
5
+ export declare const TaskContextSchema: z.ZodString;
6
+ export declare const ParsedTaskSchema: z.ZodType<ParsedTask>;
7
+ export declare const ParsedPromptSchema: z.ZodObject<{
8
+ tasks: z.ZodArray<z.ZodType<ParsedTask, unknown, z.core.$ZodTypeInternals<ParsedTask, unknown>>>;
9
+ }, z.core.$strip>;
10
+ export declare const FormattedPromptSchema: z.ZodObject<{
11
+ prompt: z.ZodString;
12
+ }, z.core.$strip>;
13
+ export type ParsedTask = {
14
+ intent: string;
15
+ targets: Array<string>;
16
+ constraints: Array<string>;
17
+ context?: string;
18
+ subtasks: Array<ParsedTask>;
19
+ };
20
+ export type ParsedPrompt = z.infer<typeof ParsedPromptSchema>;
21
+ export declare const promptSchemaExample: string;
22
+ //# sourceMappingURL=prompt-schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompt-schema.d.ts","sourceRoot":"","sources":["../../src/prompt-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,eAAO,MAAM,YAAY,aACgC,CAAA;AAEzD,eAAO,MAAM,iBAAiB,yBACmB,CAAA;AAEjD,eAAO,MAAM,iBAAiB,yBACyB,CAAA;AAEvD,eAAO,MAAM,iBAAiB,aAC0B,CAAA;AAExD,eAAO,MAAM,gBAAgB,EAAE,CAAC,CAAC,OAAO,CAAC,UAAU,CAOkB,CAAA;AAErE,eAAO,MAAM,kBAAkB;;iBAE7B,CAAA;AAEF,eAAO,MAAM,qBAAqB;;iBAEhC,CAAA;AAEF,MAAM,MAAM,UAAU,GAAG;IACvB,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,CAAA;IACtB,WAAW,EAAE,KAAK,CAAC,MAAM,CAAC,CAAA;IAC1B,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,QAAQ,EAAE,KAAK,CAAC,UAAU,CAAC,CAAA;CAC5B,CAAA;AAED,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAA;AAE7D,eAAO,MAAM,mBAAmB,QAQ9B,CAAA"}
@@ -0,0 +1,33 @@
1
+ import { z } from 'zod';
2
+ export const IntentSchema = z.string()
3
+ .describe('What to do, expressed as a clear directive');
4
+ export const TaskTargetsSchema = z.array(z.string())
5
+ .describe('Files, systems, or things involved');
6
+ export const ConstraintsSchema = z.array(z.string())
7
+ .describe('Conditions, preferences, or requirements');
8
+ export const TaskContextSchema = z.string()
9
+ .describe('Background info or rationale for the task');
10
+ export const ParsedTaskSchema = z.object({
11
+ intent: IntentSchema,
12
+ targets: TaskTargetsSchema.default([]),
13
+ constraints: ConstraintsSchema.default([]),
14
+ context: TaskContextSchema.optional(),
15
+ subtasks: z.lazy(() => z.array(ParsedTaskSchema)).default([]),
16
+ })
17
+ .describe('Single task decomposed into action/planning components');
18
+ export const ParsedPromptSchema = z.object({
19
+ tasks: z.array(ParsedTaskSchema),
20
+ });
21
+ export const FormattedPromptSchema = z.object({
22
+ prompt: z.string().describe('Human-readable restructured prompt'),
23
+ });
24
+ export const promptSchemaExample = JSON.stringify({
25
+ tasks: [{
26
+ intent: IntentSchema.description || 'directive',
27
+ targets: [TaskTargetsSchema.element.description || 'file or system'],
28
+ constraints: [ConstraintsSchema.element.description || 'requirement'],
29
+ context: TaskContextSchema.description || 'optional background',
30
+ subtasks: [],
31
+ }],
32
+ });
33
+ //# sourceMappingURL=prompt-schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompt-schema.js","sourceRoot":"","sources":["../../src/prompt-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,CAAC,MAAM,EAAE;KACnC,QAAQ,CAAC,4CAA4C,CAAC,CAAA;AAEzD,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;KACjD,QAAQ,CAAC,oCAAoC,CAAC,CAAA;AAEjD,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;KACjD,QAAQ,CAAC,0CAA0C,CAAC,CAAA;AAEvD,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAC,MAAM,EAAE;KACxC,QAAQ,CAAC,2CAA2C,CAAC,CAAA;AAExD,MAAM,CAAC,MAAM,gBAAgB,GAA0B,CAAC,CAAC,MAAM,CAAC;IAC9D,MAAM,EAAE,YAAY;IACpB,OAAO,EAAE,iBAAiB,CAAC,OAAO,CAAC,EAAE,CAAC;IACtC,WAAW,EAAE,iBAAiB,CAAC,OAAO,CAAC,EAAE,CAAC;IAC1C,OAAO,EAAE,iBAAiB,CAAC,QAAQ,EAAE;IACrC,QAAQ,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC;CAC9D,CAAC;KACC,QAAQ,CAAC,wDAAwD,CAAC,CAAA;AAErE,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAAC;IACzC,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,gBAAgB,CAAC;CACjC,CAAC,CAAA;AAEF,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC5C,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,oCAAoC,CAAC;CAClE,CAAC,CAAA;AAYF,MAAM,CAAC,MAAM,mBAAmB,GAAG,IAAI,CAAC,SAAS,CAAC;IAChD,KAAK,EAAE,CAAC;YACN,MAAM,EAAE,YAAY,CAAC,WAAW,IAAI,WAAW;YAC/C,OAAO,EAAE,CAAC,iBAAiB,CAAC,OAAO,CAAC,WAAW,IAAI,gBAAgB,CAAC;YACpE,WAAW,EAAE,CAAC,iBAAiB,CAAC,OAAO,CAAC,WAAW,IAAI,aAAa,CAAC;YACrE,OAAO,EAAE,iBAAiB,CAAC,WAAW,IAAI,qBAAqB;YAC/D,QAAQ,EAAE,EAAE;SACb,CAAC;CACH,CAAC,CAAA"}
@@ -0,0 +1,7 @@
1
+ export type FormatMode = 'verbose' | 'balanced' | 'concise';
2
+ export declare const FORMAT_MODES: FormatMode[];
3
+ export declare const isFormatMode: (v: unknown) => v is FormatMode;
4
+ export declare const buildParsePrompt: (input: string) => string;
5
+ export declare const buildFormatPrompt: (parsedRulesJson: string, mode?: FormatMode) => string;
6
+ export declare const buildRetryPrompt: (errorMessage: string) => string;
7
+ //# sourceMappingURL=prompt.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompt.d.ts","sourceRoot":"","sources":["../../src/prompt.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,UAAU,GAAG,SAAS,CAAA;AAE3D,eAAO,MAAM,YAAY,EAAE,UAAU,EAAuC,CAAA;AAE5E,eAAO,MAAM,YAAY,GAAI,GAAG,OAAO,KAAG,CAAC,IAAI,UACkB,CAAA;AAEjE,eAAO,MAAM,gBAAgB,GAAI,OAAO,MAAM,KAAG,MAchD,CAAA;AAgED,eAAO,MAAM,iBAAiB,GAAI,iBAAiB,MAAM,EAAE,OAAM,UAAuB,KAAG,MAG1F,CAAA;AAED,eAAO,MAAM,gBAAgB,GAAI,cAAc,MAAM,KAAG,MAGvD,CAAA"}
@@ -0,0 +1,84 @@
1
+ import { parseSchemaExample } from './rule-schema';
2
+ export const FORMAT_MODES = ['verbose', 'balanced', 'concise'];
3
+ export const isFormatMode = (v) => typeof v === 'string' && FORMAT_MODES.includes(v);
4
+ export const buildParsePrompt = (input) => {
5
+ const instructions = [
6
+ 'You are a rule parser that converts raw instructions into structured parsed rules.',
7
+ 'Take the provided instructions and break them down into structured components.',
8
+ 'Each rule should have: strength, action (verb), target (object), context (optional condition/scope), and reason (justification).',
9
+ 'Focus on extracting the core components without adding extra details.',
10
+ '',
11
+ 'Return ONLY valid JSON matching this exact schema:',
12
+ parseSchemaExample,
13
+ '',
14
+ 'Do not include any text outside the JSON object. Do not wrap it in markdown code fences.',
15
+ ].join('\n');
16
+ return [instructions, 'Instructions to parse:', input].join('\n\n');
17
+ };
18
+ const verboseInstructions = [
19
+ 'You are a rule formatter that converts structured parsed rules into human-readable rules.',
20
+ 'Take the provided parsed rule components and create natural language versions.',
21
+ 'Every rule must include both a Rule line and a Reason line.',
22
+ 'Each rule must follow this exact format:',
23
+ '',
24
+ 'Rule: <clear, concise, actionable statement>',
25
+ 'Reason: <justification from the parsed rule>',
26
+ '',
27
+ 'Each human-readable rule should directly correspond to the parsed components without adding extra details.',
28
+ 'Make the rules clear, concise, and actionable.',
29
+ '',
30
+ 'Return ONLY valid JSON matching this exact schema:',
31
+ '{"rules": ["Rule: ...\\nReason: ...", "Rule: ...\\nReason: ..."]}',
32
+ '',
33
+ 'Do not include any text outside the JSON object. Do not wrap it in markdown code fences.',
34
+ ];
35
+ const balancedInstructions = [
36
+ 'You are a rule formatter that converts structured parsed rules into human-readable rules.',
37
+ 'Take the provided parsed rule components and create natural language versions.',
38
+ 'Use your judgment for each rule:',
39
+ '- If the rule is non-obvious or counterintuitive, include both the Rule and Reason lines.',
40
+ '- If the rule is self-explanatory, include only the Rule line and omit the Reason.',
41
+ '',
42
+ 'Format rules that include a reason:',
43
+ 'Rule: <clear, concise, actionable statement>',
44
+ 'Reason: <justification from the parsed rule>',
45
+ '',
46
+ 'Format rules that are self-explanatory:',
47
+ 'Rule: <clear, concise, actionable statement>',
48
+ '',
49
+ 'Each human-readable rule should directly correspond to the parsed components without adding extra details.',
50
+ 'Make the rules clear, concise, and actionable.',
51
+ '',
52
+ 'Return ONLY valid JSON matching this exact schema:',
53
+ '{"rules": ["Rule: ...\\nReason: ...", "Rule: ..."]}',
54
+ '',
55
+ 'Do not include any text outside the JSON object. Do not wrap it in markdown code fences.',
56
+ ];
57
+ const conciseInstructions = [
58
+ 'You are a rule formatter that converts structured parsed rules into concise directives.',
59
+ 'Take the provided parsed rule components and create a bullet list of clear directives.',
60
+ 'Do not include reasons or justifications. Output only the actionable statement.',
61
+ 'Each rule must be a single line starting with "- " (dash space).',
62
+ '',
63
+ 'Each directive should directly correspond to the parsed components without adding extra details.',
64
+ 'Make the directives clear, concise, and actionable.',
65
+ '',
66
+ 'Return ONLY valid JSON matching this exact schema:',
67
+ '{"rules": ["- ...", "- ..."]}',
68
+ '',
69
+ 'Do not include any text outside the JSON object. Do not wrap it in markdown code fences.',
70
+ ];
71
+ const formatInstructions = {
72
+ verbose: verboseInstructions,
73
+ balanced: balancedInstructions,
74
+ concise: conciseInstructions,
75
+ };
76
+ export const buildFormatPrompt = (parsedRulesJson, mode = 'balanced') => {
77
+ const instructions = formatInstructions[mode].join('\n');
78
+ return [instructions, 'Parsed rules to convert:', parsedRulesJson].join('\n\n');
79
+ };
80
+ export const buildRetryPrompt = (errorMessage) => {
81
+ return 'Your previous response was invalid. ' + errorMessage
82
+ + '\n\nReturn ONLY valid JSON. Do not include any text outside the JSON object.';
83
+ };
84
+ //# sourceMappingURL=prompt.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompt.js","sourceRoot":"","sources":["../../src/prompt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAA;AAIlD,MAAM,CAAC,MAAM,YAAY,GAAiB,CAAC,SAAS,EAAE,UAAU,EAAE,SAAS,CAAC,CAAA;AAE5E,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,CAAU,EAAmB,EAAE,CAC1D,OAAO,CAAC,KAAK,QAAQ,IAAI,YAAY,CAAC,QAAQ,CAAC,CAAe,CAAC,CAAA;AAEjE,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,KAAa,EAAU,EAAE;IACxD,MAAM,YAAY,GAAG;QACnB,oFAAoF;QACpF,gFAAgF;QAChF,kIAAkI;QAClI,uEAAuE;QACvE,EAAE;QACF,oDAAoD;QACpD,kBAAkB;QAClB,EAAE;QACF,0FAA0F;KAC3F,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IAEZ,OAAO,CAAC,YAAY,EAAE,wBAAwB,EAAE,KAAK,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;AACrE,CAAC,CAAA;AAED,MAAM,mBAAmB,GAAG;IAC1B,2FAA2F;IAC3F,gFAAgF;IAChF,6DAA6D;IAC7D,0CAA0C;IAC1C,EAAE;IACF,8CAA8C;IAC9C,8CAA8C;IAC9C,EAAE;IACF,4GAA4G;IAC5G,gDAAgD;IAChD,EAAE;IACF,oDAAoD;IACpD,mEAAmE;IACnE,EAAE;IACF,0FAA0F;CAC3F,CAAA;AAED,MAAM,oBAAoB,GAAG;IAC3B,2FAA2F;IAC3F,gFAAgF;IAChF,kCAAkC;IAClC,2FAA2F;IAC3F,oFAAoF;IACpF,EAAE;IACF,qCAAqC;IACrC,8CAA8C;IAC9C,8CAA8C;IAC9C,EAAE;IACF,yCAAyC;IACzC,8CAA8C;IAC9C,EAAE;IACF,4GAA4G;IAC5G,gDAAgD;IAChD,EAAE;IACF,oDAAoD;IACpD,qDAAqD;IACrD,EAAE;IACF,0FAA0F;CAC3F,CAAA;AAED,MAAM,mBAAmB,GAAG;IAC1B,yFAAyF;IACzF,wFAAwF;IACxF,iFAAiF;IACjF,kEAAkE;IAClE,EAAE;IACF,kGAAkG;IAClG,qDAAqD;IACrD,EAAE;IACF,oDAAoD;IACpD,+BAA+B;IAC/B,EAAE;IACF,0FAA0F;CAC3F,CAAA;AAED,MAAM,kBAAkB,GAAiC;IACvD,OAAO,EAAE,mBAAmB;IAC5B,QAAQ,EAAE,oBAAoB;IAC9B,OAAO,EAAE,mBAAmB;CAC7B,CAAA;AAED,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,eAAuB,EAAE,OAAmB,UAAU,EAAU,EAAE;IAClG,MAAM,YAAY,GAAG,kBAAkB,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IACxD,OAAO,CAAC,YAAY,EAAE,0BAA0B,EAAE,eAAe,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;AACjF,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,YAAoB,EAAU,EAAE;IAC/D,OAAO,sCAAsC,GAAG,YAAY;UACxD,8EAA8E,CAAA;AACpF,CAAC,CAAA"}
@@ -0,0 +1,4 @@
1
+ import type { InstructionFile } from './discover.ts';
2
+ import type { Result } from './utils/safe.ts';
3
+ export declare const resolveFiles: (directory: string, filesArg?: string) => Promise<Result<InstructionFile[]>>;
4
+ //# sourceMappingURL=resolve.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../../src/resolve.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AACpD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AAG7C,eAAO,MAAM,YAAY,GAAU,WAAW,MAAM,EAAE,WAAW,MAAM,KAAG,OAAO,CAAC,MAAM,CAAC,eAAe,EAAE,CAAC,CAiB1G,CAAA"}
@@ -0,0 +1,19 @@
1
+ import { discover, readFilePaths } from "./discover.js";
2
+ // resolve instruction files from explicit paths or opencode.json discovery
3
+ export const resolveFiles = async (directory, filesArg) => {
4
+ if (filesArg) {
5
+ const paths = filesArg.split(',').map((p) => p.trim()).filter((p) => p.length > 0);
6
+ if (paths.length === 0) {
7
+ return {
8
+ data: null,
9
+ error: 'No valid file paths provided',
10
+ };
11
+ }
12
+ return {
13
+ data: await readFilePaths(directory, paths),
14
+ error: null,
15
+ };
16
+ }
17
+ return await discover(directory);
18
+ };
19
+ //# sourceMappingURL=resolve.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolve.js","sourceRoot":"","sources":["../../src/resolve.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAIvD,2EAA2E;AAC3E,MAAM,CAAC,MAAM,YAAY,GAAG,KAAK,EAAE,SAAiB,EAAE,QAAiB,EAAsC,EAAE;IAC7G,IAAI,QAAQ,EAAE,CAAC;QACb,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAA;QAClF,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACvB,OAAO;gBACL,IAAI,EAAE,IAAI;gBACV,KAAK,EAAE,8BAA8B;aACtC,CAAA;QACH,CAAC;QAED,OAAO;YACL,IAAI,EAAE,MAAM,aAAa,CAAC,SAAS,EAAE,KAAK,CAAC;YAC3C,KAAK,EAAE,IAAI;SACZ,CAAA;IACH,CAAC;IAED,OAAO,MAAM,QAAQ,CAAC,SAAS,CAAC,CAAA;AAClC,CAAC,CAAA"}
@@ -0,0 +1,69 @@
1
+ import { z } from 'zod';
2
+ export declare const StrengthSchema: z.ZodEnum<{
3
+ obligatory: "obligatory";
4
+ permissible: "permissible";
5
+ forbidden: "forbidden";
6
+ optional: "optional";
7
+ supererogatory: "supererogatory";
8
+ indifferent: "indifferent";
9
+ omissible: "omissible";
10
+ }>;
11
+ export declare const ActionSchema: z.ZodString;
12
+ export declare const TargetSchema: z.ZodString;
13
+ export declare const ContextSchema: z.ZodString;
14
+ export declare const ReasonSchema: z.ZodString;
15
+ export declare const ParsedRuleSchema: z.ZodObject<{
16
+ strength: z.ZodEnum<{
17
+ obligatory: "obligatory";
18
+ permissible: "permissible";
19
+ forbidden: "forbidden";
20
+ optional: "optional";
21
+ supererogatory: "supererogatory";
22
+ indifferent: "indifferent";
23
+ omissible: "omissible";
24
+ }>;
25
+ action: z.ZodString;
26
+ target: z.ZodString;
27
+ context: z.ZodOptional<z.ZodString>;
28
+ reason: z.ZodString;
29
+ }, z.core.$strip>;
30
+ export declare const RuleSchema: z.ZodString;
31
+ export declare const ParsedSchema: z.ZodArray<z.ZodObject<{
32
+ strength: z.ZodEnum<{
33
+ obligatory: "obligatory";
34
+ permissible: "permissible";
35
+ forbidden: "forbidden";
36
+ optional: "optional";
37
+ supererogatory: "supererogatory";
38
+ indifferent: "indifferent";
39
+ omissible: "omissible";
40
+ }>;
41
+ action: z.ZodString;
42
+ target: z.ZodString;
43
+ context: z.ZodOptional<z.ZodString>;
44
+ reason: z.ZodString;
45
+ }, z.core.$strip>>;
46
+ export declare const ParseResponseSchema: z.ZodObject<{
47
+ rules: z.ZodArray<z.ZodObject<{
48
+ strength: z.ZodEnum<{
49
+ obligatory: "obligatory";
50
+ permissible: "permissible";
51
+ forbidden: "forbidden";
52
+ optional: "optional";
53
+ supererogatory: "supererogatory";
54
+ indifferent: "indifferent";
55
+ omissible: "omissible";
56
+ }>;
57
+ action: z.ZodString;
58
+ target: z.ZodString;
59
+ context: z.ZodOptional<z.ZodString>;
60
+ reason: z.ZodString;
61
+ }, z.core.$strip>>;
62
+ }, z.core.$strip>;
63
+ export declare const FormatResponseSchema: z.ZodObject<{
64
+ rules: z.ZodArray<z.ZodString>;
65
+ }, z.core.$strip>;
66
+ export type Strength = z.infer<typeof StrengthSchema>;
67
+ export type ParsedRule = z.infer<typeof ParsedRuleSchema>;
68
+ export declare const parseSchemaExample: string;
69
+ //# sourceMappingURL=rule-schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rule-schema.d.ts","sourceRoot":"","sources":["../../src/rule-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,eAAO,MAAM,cAAc;;;;;;;;EASoC,CAAA;AAE/D,eAAO,MAAM,YAAY,aACmC,CAAA;AAE5D,eAAO,MAAM,YAAY,aAC6B,CAAA;AAEtD,eAAO,MAAM,aAAa,aAC4C,CAAA;AAEtE,eAAO,MAAM,YAAY,aAC2B,CAAA;AAEpD,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;iBAOuC,CAAA;AAEpE,eAAO,MAAM,UAAU,aAC0C,CAAA;AAEjE,eAAO,MAAM,YAAY;;;;;;;;;;;;;;kBACW,CAAA;AAEpC,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;iBAE9B,CAAA;AAEF,eAAO,MAAM,oBAAoB;;iBAE/B,CAAA;AAEF,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAA;AACrD,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAA;AAEzD,eAAO,MAAM,kBAAkB,QAQ7B,CAAA"}
@@ -0,0 +1,47 @@
1
+ import { z } from 'zod';
2
+ export const StrengthSchema = z.enum([
3
+ 'obligatory',
4
+ 'permissible',
5
+ 'forbidden',
6
+ 'optional',
7
+ 'supererogatory',
8
+ 'indifferent',
9
+ 'omissible',
10
+ ])
11
+ .describe('Deontic modality expressing enforcement strength');
12
+ export const ActionSchema = z.string()
13
+ .describe('Imperative verb describing the action to take');
14
+ export const TargetSchema = z.string()
15
+ .describe('Object or subject the action applies to');
16
+ export const ContextSchema = z.string()
17
+ .describe('Condition, scope, or circumstance when the rule applies');
18
+ export const ReasonSchema = z.string()
19
+ .describe('Justification for why the rule exists');
20
+ export const ParsedRuleSchema = z.object({
21
+ strength: StrengthSchema,
22
+ action: ActionSchema,
23
+ target: TargetSchema,
24
+ context: ContextSchema.optional(),
25
+ reason: ReasonSchema,
26
+ })
27
+ .describe('Single instruction decomposed into deontic components');
28
+ export const RuleSchema = z.string()
29
+ .describe('Human-readable rule derived from parsed components');
30
+ export const ParsedSchema = z.array(ParsedRuleSchema)
31
+ .describe('Array of parsed rules');
32
+ export const ParseResponseSchema = z.object({
33
+ rules: ParsedSchema,
34
+ });
35
+ export const FormatResponseSchema = z.object({
36
+ rules: z.array(RuleSchema),
37
+ });
38
+ export const parseSchemaExample = JSON.stringify({
39
+ rules: [{
40
+ strength: StrengthSchema.options.join('/'),
41
+ action: ActionSchema.description || 'verb',
42
+ target: TargetSchema.description || 'object',
43
+ context: ContextSchema.description || 'optional condition',
44
+ reason: ReasonSchema.description || 'justification',
45
+ }],
46
+ });
47
+ //# sourceMappingURL=rule-schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rule-schema.js","sourceRoot":"","sources":["../../src/rule-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAC,IAAI,CAAC;IACnC,YAAY;IACZ,aAAa;IACb,WAAW;IACX,UAAU;IACV,gBAAgB;IAChB,aAAa;IACb,WAAW;CACZ,CAAC;KACC,QAAQ,CAAC,kDAAkD,CAAC,CAAA;AAE/D,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,CAAC,MAAM,EAAE;KACnC,QAAQ,CAAC,+CAA+C,CAAC,CAAA;AAE5D,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,CAAC,MAAM,EAAE;KACnC,QAAQ,CAAC,yCAAyC,CAAC,CAAA;AAEtD,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAC,MAAM,EAAE;KACpC,QAAQ,CAAC,yDAAyD,CAAC,CAAA;AAEtE,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,CAAC,MAAM,EAAE;KACnC,QAAQ,CAAC,uCAAuC,CAAC,CAAA;AAEpD,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC;IACvC,QAAQ,EAAE,cAAc;IACxB,MAAM,EAAE,YAAY;IACpB,MAAM,EAAE,YAAY;IACpB,OAAO,EAAE,aAAa,CAAC,QAAQ,EAAE;IACjC,MAAM,EAAE,YAAY;CACrB,CAAC;KACC,QAAQ,CAAC,uDAAuD,CAAC,CAAA;AAEpE,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,CAAC,MAAM,EAAE;KACjC,QAAQ,CAAC,oDAAoD,CAAC,CAAA;AAEjE,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,gBAAgB,CAAC;KAClD,QAAQ,CAAC,uBAAuB,CAAC,CAAA;AAEpC,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC1C,KAAK,EAAE,YAAY;CACpB,CAAC,CAAA;AAEF,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC3C,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC;CAC3B,CAAC,CAAA;AAKF,MAAM,CAAC,MAAM,kBAAkB,GAAG,IAAI,CAAC,SAAS,CAAC;IAC/C,KAAK,EAAE,CAAC;YACN,QAAQ,EAAE,cAAc,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC;YAC1C,MAAM,EAAE,YAAY,CAAC,WAAW,IAAI,MAAM;YAC1C,MAAM,EAAE,YAAY,CAAC,WAAW,IAAI,QAAQ;YAC5C,OAAO,EAAE,aAAa,CAAC,WAAW,IAAI,oBAAoB;YAC1D,MAAM,EAAE,YAAY,CAAC,WAAW,IAAI,eAAe;SACpD,CAAC;CACH,CAAC,CAAA"}
@@ -0,0 +1,23 @@
1
+ import type { PluginInput } from '@opencode-ai/plugin';
2
+ import type { z } from 'zod';
3
+ import type { Result } from './utils/safe';
4
+ export type PromptModel = {
5
+ providerID: string;
6
+ modelID: string;
7
+ };
8
+ type Part = {
9
+ type: string;
10
+ text?: string;
11
+ };
12
+ export declare const extractText: (parts: Part[]) => string;
13
+ export declare const detectModel: (client: PluginInput["client"], sessionId: string) => Promise<PromptModel | null>;
14
+ type PromptWithRetryOptions<T> = {
15
+ client: PluginInput['client'];
16
+ sessionId: string;
17
+ initialPrompt: string;
18
+ schema: z.ZodType<T>;
19
+ model: PromptModel;
20
+ };
21
+ export declare const promptWithRetry: <T>(options: PromptWithRetryOptions<T>) => Promise<Result<T>>;
22
+ export {};
23
+ //# sourceMappingURL=session.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../src/session.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AACtD,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAG5B,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAM1C,MAAM,MAAM,WAAW,GAAG;IACxB,UAAU,EAAE,MAAM,CAAA;IAClB,OAAO,EAAE,MAAM,CAAA;CAChB,CAAA;AAGD,KAAK,IAAI,GAAG;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,CAAC,EAAE,MAAM,CAAA;CACd,CAAA;AAgBD,eAAO,MAAM,WAAW,GAAI,OAAO,IAAI,EAAE,KAAG,MAK3C,CAAA;AAGD,eAAO,MAAM,WAAW,GAAU,QAAQ,WAAW,CAAC,QAAQ,CAAC,EAAE,WAAW,MAAM,KAAG,OAAO,CAAC,WAAW,GAAG,IAAI,CA2B9G,CAAA;AAED,KAAK,sBAAsB,CAAC,CAAC,IAAI;IAC/B,MAAM,EAAE,WAAW,CAAC,QAAQ,CAAC,CAAA;IAC7B,SAAS,EAAE,MAAM,CAAA;IACjB,aAAa,EAAE,MAAM,CAAA;IACrB,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAA;IACpB,KAAK,EAAE,WAAW,CAAA;CACnB,CAAA;AAGD,eAAO,MAAM,eAAe,GAAU,CAAC,EAAE,SAAS,sBAAsB,CAAC,CAAC,CAAC,KAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CA0E9F,CAAA"}