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,31 @@
1
+ export const safe = (fn) => {
2
+ try {
3
+ const data = fn();
4
+ return {
5
+ data,
6
+ error: null,
7
+ };
8
+ }
9
+ catch (error) {
10
+ return {
11
+ data: null,
12
+ error: error instanceof Error ? error : new Error(String(error)),
13
+ };
14
+ }
15
+ };
16
+ export const safeAsync = async (fn) => {
17
+ try {
18
+ const data = await fn();
19
+ return {
20
+ data,
21
+ error: null,
22
+ };
23
+ }
24
+ catch (error) {
25
+ return {
26
+ data: null,
27
+ error: error instanceof Error ? error : new Error(String(error)),
28
+ };
29
+ }
30
+ };
31
+ //# sourceMappingURL=safe.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"safe.js","sourceRoot":"","sources":["../../../src/utils/safe.ts"],"names":[],"mappings":"AAcA,MAAM,CAAC,MAAM,IAAI,GAAG,CAAI,EAAW,EAAiB,EAAE;IACpD,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,EAAE,EAAE,CAAA;QACjB,OAAO;YACL,IAAI;YACJ,KAAK,EAAE,IAAI;SACZ,CAAA;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO;YACL,IAAI,EAAE,IAAI;YACV,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;SACjE,CAAA;IACH,CAAC;AACH,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,SAAS,GAAG,KAAK,EAAK,EAAoB,EAA0B,EAAE;IACjF,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,MAAM,EAAE,EAAE,CAAA;QACvB,OAAO;YACL,IAAI;YACJ,KAAK,EAAE,IAAI;SACZ,CAAA;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO;YACL,IAAI,EAAE,IAAI;YACV,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;SACjE,CAAA;IACH,CAAC;AACH,CAAC,CAAA"}
@@ -0,0 +1,2 @@
1
+ export declare const stripCodeFences: (text: string) => string;
2
+ //# sourceMappingURL=stripCodeFences.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stripCodeFences.d.ts","sourceRoot":"","sources":["../../../src/utils/stripCodeFences.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,eAAe,GAAI,MAAM,MAAM,KAAG,MAK9C,CAAA"}
@@ -0,0 +1,9 @@
1
+ // strip markdown code fences from LLM response text
2
+ // handles fences at line start or preceded by text on the same line
3
+ export const stripCodeFences = (text) => {
4
+ return text
5
+ .replace(/^.*```(?:json)?\s*\n?/m, '')
6
+ .replace(/\n?```\s*$/m, '')
7
+ .trim();
8
+ };
9
+ //# sourceMappingURL=stripCodeFences.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stripCodeFences.js","sourceRoot":"","sources":["../../../src/utils/stripCodeFences.ts"],"names":[],"mappings":"AAAA,oDAAoD;AACpD,oEAAoE;AACpE,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,IAAY,EAAU,EAAE;IACtD,OAAO,IAAI;SACR,OAAO,CAAC,wBAAwB,EAAE,EAAE,CAAC;SACrC,OAAO,CAAC,aAAa,EAAE,EAAE,CAAC;SAC1B,IAAI,EAAE,CAAA;AACX,CAAC,CAAA"}
@@ -0,0 +1,19 @@
1
+ import type { z } from 'zod';
2
+ type ValidateJsonSuccess<T> = {
3
+ data: T;
4
+ error: null;
5
+ };
6
+ type ValidateJsonParseError = {
7
+ data: null;
8
+ error: 'parse';
9
+ };
10
+ type ValidateJsonSchemaError = {
11
+ data: null;
12
+ error: 'schema';
13
+ issues: z.core.$ZodIssue[];
14
+ };
15
+ type ValidateJsonResult<T> = ValidateJsonSuccess<T> | ValidateJsonParseError | ValidateJsonSchemaError;
16
+ export declare const validateJson: <T>(json: string, schema: z.ZodType<T>) => ValidateJsonResult<T>;
17
+ export declare const formatValidationError: (result: ValidateJsonParseError | ValidateJsonSchemaError) => string;
18
+ export {};
19
+ //# sourceMappingURL=validate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../../src/utils/validate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAG5B,KAAK,mBAAmB,CAAC,CAAC,IAAI;IAC5B,IAAI,EAAE,CAAC,CAAA;IACP,KAAK,EAAE,IAAI,CAAA;CACZ,CAAA;AAED,KAAK,sBAAsB,GAAG;IAC5B,IAAI,EAAE,IAAI,CAAA;IACV,KAAK,EAAE,OAAO,CAAA;CACf,CAAA;AAED,KAAK,uBAAuB,GAAG;IAC7B,IAAI,EAAE,IAAI,CAAA;IACV,KAAK,EAAE,QAAQ,CAAA;IACf,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,SAAS,EAAE,CAAA;CAC3B,CAAA;AAED,KAAK,kBAAkB,CAAC,CAAC,IAAI,mBAAmB,CAAC,CAAC,CAAC,GAAG,sBAAsB,GAAG,uBAAuB,CAAA;AAEtG,eAAO,MAAM,YAAY,GAAI,CAAC,EAAE,MAAM,MAAM,EAAE,QAAQ,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAG,kBAAkB,CAAC,CAAC,CAsBxF,CAAA;AAED,eAAO,MAAM,qBAAqB,GAAI,QAAQ,sBAAsB,GAAG,uBAAuB,KAAG,MAQhG,CAAA"}
@@ -0,0 +1,30 @@
1
+ import { safe } from './safe';
2
+ export const validateJson = (json, schema) => {
3
+ const parseResult = safe(() => JSON.parse(json));
4
+ if (parseResult.error) {
5
+ return {
6
+ data: null,
7
+ error: 'parse',
8
+ };
9
+ }
10
+ const result = schema.safeParse(parseResult.data);
11
+ if (!result.success) {
12
+ return {
13
+ data: null,
14
+ error: 'schema',
15
+ issues: result.error.issues,
16
+ };
17
+ }
18
+ return {
19
+ data: result.data,
20
+ error: null,
21
+ };
22
+ };
23
+ export const formatValidationError = (result) => {
24
+ if (result.error === 'parse') {
25
+ return 'Invalid JSON. Return valid JSON.';
26
+ }
27
+ const issues = result.issues.map((i) => ' - ' + i.path.join('.') + ': ' + i.message).join('\n');
28
+ return 'Schema validation failed:\n' + issues + '\n\nFix the issues and try again.';
29
+ };
30
+ //# sourceMappingURL=validate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate.js","sourceRoot":"","sources":["../../../src/utils/validate.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAoB7B,MAAM,CAAC,MAAM,YAAY,GAAG,CAAI,IAAY,EAAE,MAAoB,EAAyB,EAAE;IAC3F,MAAM,WAAW,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAA;IAChD,IAAI,WAAW,CAAC,KAAK,EAAE,CAAC;QACtB,OAAO;YACL,IAAI,EAAE,IAAI;YACV,KAAK,EAAE,OAAO;SACf,CAAA;IACH,CAAC;IAED,MAAM,MAAM,GAAG,MAAM,CAAC,SAAS,CAAC,WAAW,CAAC,IAAI,CAAC,CAAA;IACjD,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACpB,OAAO;YACL,IAAI,EAAE,IAAI;YACV,KAAK,EAAE,QAAQ;YACf,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM;SAC5B,CAAA;IACH,CAAC;IAED,OAAO;QACL,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,KAAK,EAAE,IAAI;KACZ,CAAA;AACH,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,MAAwD,EAAU,EAAE;IACxG,IAAI,MAAM,CAAC,KAAK,KAAK,OAAO,EAAE,CAAC;QAC7B,OAAO,kCAAkC,CAAA;IAC3C,CAAC;IAED,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IAEhG,OAAO,6BAA6B,GAAG,MAAM,GAAG,mCAAmC,CAAA;AACrF,CAAC,CAAA"}
package/package.json ADDED
@@ -0,0 +1,59 @@
1
+ {
2
+ "name": "opencode-sat",
3
+ "version": "0.0.12",
4
+ "description": "OpenCode plugin that converts unstructured instructions into structured rules using speech act theory and deontic logic.",
5
+ "keywords": [
6
+ "opencode",
7
+ "opencode-plugin",
8
+ "plugin",
9
+ "instructions",
10
+ "rules",
11
+ "formatting",
12
+ "speech-act-theory",
13
+ "deontic-logic"
14
+ ],
15
+ "homepage": "https://github.com/whaaaley/opencode-sat#readme",
16
+ "bugs": {
17
+ "url": "https://github.com/whaaaley/opencode-sat/issues"
18
+ },
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "git+https://github.com/whaaaley/opencode-sat.git"
22
+ },
23
+ "license": "MIT",
24
+ "author": "Dustin Dowell",
25
+ "type": "module",
26
+ "exports": {
27
+ ".": {
28
+ "import": "./dist/sat.js",
29
+ "types": "./dist/sat.d.ts"
30
+ }
31
+ },
32
+ "main": "./dist/sat.js",
33
+ "types": "./dist/sat.d.ts",
34
+ "files": [
35
+ "dist/",
36
+ "README.md",
37
+ "LICENSE"
38
+ ],
39
+ "scripts": {
40
+ "build": "npm run clean && tsc",
41
+ "clean": "rm -rf dist",
42
+ "test": "bun test",
43
+ "fmt": "bun run dprint fmt",
44
+ "prepublishOnly": "npm run build"
45
+ },
46
+ "dependencies": {
47
+ "cli-table3": "^0.6.5",
48
+ "zod": "4.1.8"
49
+ },
50
+ "devDependencies": {
51
+ "@opencode-ai/plugin": "1.1.12",
52
+ "@types/bun": "latest",
53
+ "dprint": "^0.49.1",
54
+ "typescript": "5.9.3"
55
+ },
56
+ "peerDependencies": {
57
+ "@opencode-ai/plugin": ">=0.13.7"
58
+ }
59
+ }