algomath-extract 1.0.13 → 1.0.15

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/bin/install.js CHANGED
@@ -73,7 +73,7 @@ console.log(GREEN + `
73
73
  ██╔══██║██║ ██║ ██║██║ ██║██║╚██╔╝██║██╔══██║ ██║ ██╔══██║
74
74
  ██║ ██║███████╗╚██████╔╝╚██████╔╝██║ ╚═╝ ██║██║ ██║ ██║ ██║ ██║
75
75
  ╚═╝ ╚═╝╚══════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝
76
- Framework Installer v1.0.11
76
+ Framework Installer v1.0.15
77
77
  Mathematical Algorithm Extraction & Code
78
78
  ` + RESET + '\n');
79
79
 
@@ -13,10 +13,23 @@ Supports automatic extraction or step-by-step with review points.
13
13
  </objective>
14
14
 
15
15
  <execution>
16
- Execute the extraction by running the Node.js wrapper:
16
+ Execute the extraction by running:
17
+
18
+ **Option 1 - Using npx (no install required):**
17
19
  ```bash
18
- npx algoextract "$@"
20
+ npx -p algomath-extract algoextract "$@"
19
21
  ```
22
+
23
+ **Option 2 - If installed globally:**
24
+ ```bash
25
+ algoextract "$@"
26
+ ```
27
+
28
+ **Option 3 - If installed locally in project:**
29
+ ```bash
30
+ ./node_modules/.bin/algoextract "$@"
31
+ ```
32
+
20
33
  This will:
21
34
  1. Parse the provided file or arguments
22
35
  2. Extract algorithm steps using LLM
@@ -27,49 +40,50 @@ This will:
27
40
  <process>
28
41
  Execute extraction workflow:
29
42
 
43
+
30
44
  1. **Parse Arguments**
31
- - Check if file path provided
32
- - Determine mode: auto, step-by-step, or interactive
45
+ - Check if file path provided
46
+ - Determine mode: auto, step-by-step, or interactive
33
47
 
34
48
  2. **Extract Text from File**
35
- - Auto-detect file type (PDF, .txt, .md)
36
- - Use pdfplumber for PDFs
37
- - Handle encoding issues
38
- - Validate extraction success
49
+ - Auto-detect file type (PDF, .txt, .md)
50
+ - Use pdfplumber for PDFs
51
+ - Handle encoding issues
52
+ - Validate extraction success
39
53
 
40
54
  3. **Parse Algorithm Structure**
41
- - Use opencode LLM to parse text
42
- - Identify algorithm name
43
- - Extract inputs and outputs
44
- - Parse step-by-step procedure
45
- - Handle mathematical notation
55
+ - Use opencode LLM to parse text
56
+ - Identify algorithm name
57
+ - Extract inputs and outputs
58
+ - Parse step-by-step procedure
59
+ - Handle mathematical notation
46
60
 
47
61
  4. **Review Point (if step-by-step)**
48
- - Display extracted text
49
- - Ask user to confirm or edit
50
- - Apply user corrections
62
+ - Display extracted text
63
+ - Ask user to confirm or edit
64
+ - Apply user corrections
51
65
 
52
66
  5. **Generate Structured Steps**
53
- - Convert parsed text to Algorithm object
54
- - Validate step structure
55
- - Check for completeness
67
+ - Convert parsed text to Algorithm object
68
+ - Validate step structure
69
+ - Check for completeness
56
70
 
57
71
  6. **Review Point (if step-by-step)**
58
- - Display structured steps
59
- - Show inputs, outputs, step list
60
- - Allow editing
72
+ - Display structured steps
73
+ - Show inputs, outputs, step list
74
+ - Allow editing
61
75
 
62
76
  7. **Save Algorithm**
63
- - Create directory: .algomath/algorithms/{name}/
64
- - Save source.txt (original text)
65
- - Save steps.json (structured)
66
- - Save metadata.json (info)
77
+ - Create directory: .algomath/algorithms/{name}/
78
+ - Save source.txt (original text)
79
+ - Save steps.json (structured)
80
+ - Save metadata.json (info)
67
81
 
68
82
  8. **Display Summary**
69
- - Show algorithm name
70
- - Show step count
71
- - Display next steps
72
- - Suggest: /algo-generate
83
+ - Show algorithm name
84
+ - Show step count
85
+ - Display next steps
86
+ - Suggest: /algo-generate
73
87
  </process>
74
88
 
75
89
  <examples>
@@ -4,6 +4,7 @@ argument-hint: "[--review] [--template-only] [--llm-only]"
4
4
  tools:
5
5
  read: true
6
6
  write: true
7
+ Bash: true
7
8
  ---
8
9
 
9
10
  <objective>
@@ -11,83 +12,111 @@ Generate executable Python code from structured algorithm steps.
11
12
  Supports template-based generation (fast, reliable) or LLM-enhanced (for complex expressions).
12
13
  </objective>
13
14
 
15
+ <execution>
16
+ Execute the code generation by running:
17
+
18
+ **Option 1 - Using npx (no install required):**
19
+ ```bash
20
+ npx -p algomath-extract algogenerate "$@"
21
+ ```
22
+
23
+ **Option 2 - If installed globally:**
24
+ ```bash
25
+ algogenerate "$@"
26
+ ```
27
+
28
+ **Option 3 - If installed locally in project:**
29
+ ```bash
30
+ ./node_modules/.bin/algogenerate "$@"
31
+ ```
32
+
33
+ This will:
34
+ 1. Load the extracted algorithm from .algomath/algorithms/
35
+ 2. Generate Python code using template or LLM
36
+ 3. Save generated code to .algomath/generated/
37
+ 4. Display generation summary
38
+ </execution>
14
39
 
15
40
  <process>
16
41
  Execute code generation workflow:
17
42
 
43
+
18
44
  1. **Load Algorithm**
19
- - Read steps.json from current algorithm
20
- - Validate step structure
21
- - Check for completeness
45
+ - Read steps.json from current algorithm
46
+ - Validate step structure
47
+ - Check for completeness
22
48
 
23
49
  2. **Select Generation Mode**
24
- - Default: Hybrid (template + LLM for complex parts)
25
- - --template-only: Rule-based only (faster)
26
- - --llm-only: Full LLM generation (slower, more accurate)
50
+ - Default: Hybrid (template + LLM for complex parts)
51
+ - --template-only: Rule-based only (faster)
52
+ - --llm-only: Full LLM generation (slower, more accurate)
27
53
 
28
54
  3. **Generate Function Signature**
29
- - Extract inputs and outputs
30
- - Add type hints
31
- - Generate docstring
32
-
33
- 4. **Generate Step Code**
34
- - Convert each step to Python
35
- - Handle loops, conditionals, assignments
36
- - Preserve variable names
37
- - Add comments explaining logic
38
-
39
- 5. **Review Point (if --review)**
40
- - Display generated code
41
- - Syntax highlighting
42
- - Ask for approval
43
- - Allow editing
44
-
45
- 6. **Validate Code**
46
- - Syntax check with Python parser
47
- - Check for common errors
48
- - Ensure all variables defined
49
-
50
- 7. **Save Code**
51
- - Write to .algomath/algorithms/{name}/generated.py
52
- - Update metadata.json
55
+ - Extract inputs and outputs
56
+ - Add type hints
57
+ - Create docstring
58
+
59
+ 4. **Generate Step Implementation**
60
+ - Convert each step to Python code
61
+ - Handle mathematical operations
62
+ - Manage variable scope
63
+ - Add error handling
64
+
65
+ 5. **Add Helper Functions**
66
+ - Generate necessary imports
67
+ - Create utility functions
68
+ - Add validation
69
+
70
+ 6. **Review Point (if --review)**
71
+ - Display generated code
72
+ - Ask for approval
73
+ - Allow regeneration with feedback
74
+
75
+ 7. **Save Generated Code**
76
+ - Save to .algomath/generated/{name}.py
77
+ - Create __init__.py for imports
78
+ - Add requirements.txt if needed
53
79
 
54
80
  8. **Display Summary**
55
- - Show generated file path
56
- - Line count
57
- - Next steps: /algo-run
81
+ - Show file path
82
+ - Display code preview
83
+ - Suggest: /algo-run
58
84
  </process>
59
85
 
60
86
  <examples>
61
87
 
62
- **Generate with default hybrid mode:**
88
+ **Generate with review:**
63
89
  /algo-generate
64
90
 
65
- **Generate with review:**
66
- /algo-generate --review
91
+ **Auto-generate:**
92
+ /algo-generate --auto
67
93
 
68
- **Template-based only (faster):**
94
+ **Template-only (faster):**
69
95
  /algo-generate --template-only
70
96
 
71
- **LLM-enhanced only (better for complex):**
97
+ **LLM-enhanced (better for complex math):**
72
98
  /algo-generate --llm-only
73
99
 
74
100
  </examples>
75
101
 
76
102
  <options>
77
103
 
78
- --review
79
- Show generated code for review before saving
104
+ --auto
105
+ Skip review, generate automatically
80
106
 
81
107
  --template-only
82
- Use rule-based generation only (no LLM)
108
+ Use only template-based generation (faster, no LLM)
83
109
 
84
110
  --llm-only
85
- Use LLM for all generation (slower but more accurate)
111
+ Use only LLM generation (slower, handles complex expressions)
112
+
113
+ --review
114
+ Force review mode even in auto mode
86
115
 
87
116
  </options>
88
117
 
89
118
  <next_steps>
90
119
  /algo-run - Execute the generated code
91
- /algo-verify - Verify execution results
92
- /algo-status - Check algorithm state
120
+ /algo-verify - Verify the generated code
121
+ /algo-status - Check current state
93
122
  </next_steps>
@@ -10,6 +10,22 @@ tools:
10
10
  Display help information, available commands, and usage examples.
11
11
  </objective>
12
12
 
13
+ <execution>
14
+ Show help by running:
15
+ ```bash
16
+ npx algomath-extract algohelp "$@"
17
+ ```
18
+
19
+ Or if algomath-extract is installed globally:
20
+ ```bash
21
+ algohelp "$@"
22
+ ```
23
+
24
+ This will display:
25
+ 1. Available commands and their descriptions
26
+ 2. Usage examples
27
+ 3. Workflow information
28
+ </execution>
13
29
 
14
30
  <process>
15
31
  Display help:
@@ -10,6 +10,22 @@ tools:
10
10
  Display list of all saved algorithms with their status and basic info.
11
11
  </objective>
12
12
 
13
+ <execution>
14
+ List algorithms by running:
15
+ ```bash
16
+ npx algomath-extract algolist "$@"
17
+ ```
18
+
19
+ Or if algomath-extract is installed globally:
20
+ ```bash
21
+ algolist "$@"
22
+ ```
23
+
24
+ This will:
25
+ 1. Scan .algomath/algorithms/ directory
26
+ 2. List all saved algorithms
27
+ 3. Display status and basic info for each
28
+ </execution>
13
29
 
14
30
  <process>
15
31
  List algorithms:
@@ -4,6 +4,7 @@ argument-hint: "[--skip] [--timeout <seconds>]"
4
4
  tools:
5
5
  read: true
6
6
  write: true
7
+ Bash: true
7
8
  ---
8
9
 
9
10
  <objective>
@@ -11,68 +12,89 @@ Execute generated Python code in a safe sandboxed environment.
11
12
  Captures stdout, stderr, and execution results.
12
13
  </objective>
13
14
 
15
+ <execution>
16
+ Execute the generated code by running:
17
+
18
+ **Option 1 - Using npx (no install required):**
19
+ ```bash
20
+ npx -p algomath-extract algorun "$@"
21
+ ```
22
+
23
+ **Option 2 - If installed globally:**
24
+ ```bash
25
+ algorun "$@"
26
+ ```
27
+
28
+ **Option 3 - If installed locally in project:**
29
+ ```bash
30
+ ./node_modules/.bin/algorun "$@"
31
+ ```
32
+
33
+ This will:
34
+ 1. Load the generated Python code
35
+ 2. Execute in a sandboxed environment
36
+ 3. Capture output and results
37
+ 4. Display execution summary
38
+ </execution>
14
39
 
15
40
  <process>
16
41
  Execute code in sandbox:
17
42
 
43
+
18
44
  1. **Load Generated Code**
19
- - Read generated.py from current algorithm
20
- - Validate code exists
21
- - Check syntax
45
+ - Read generated.py from current algorithm
46
+ - Validate code exists
47
+ - Check for syntax errors
22
48
 
23
- 2. **Create Sandbox**
24
- - Create isolated temp directory
25
- - Copy code to sandbox
26
- - Set resource limits
49
+ 2. **Prepare Execution**
50
+ - Create isolated sandbox
51
+ - Set resource limits
52
+ - Prepare input data
53
+ - Set timeout (default: 30s)
27
54
 
28
55
  3. **Execute Code**
29
- - Run in subprocess with timeout (default 30s)
30
- - Capture stdout and stderr
31
- - Monitor resource usage
32
- - Handle exceptions
33
-
34
- 4. **Process Results**
35
- - Capture output
36
- - Record execution time
37
- - Check for errors
38
- - Format results
39
-
40
- 5. **Save Results**
41
- - Write to execution.log
42
- - Update metadata.json
43
- - Update state to EXECUTION_COMPLETE
44
-
45
- 6. **Display Results**
46
- - Show output
47
- - Show execution time
48
- - Show status (success/error)
49
- - Suggest next steps
56
+ - Run in subprocess
57
+ - Capture stdout/stderr
58
+ - Monitor execution
59
+ - Handle timeouts
60
+
61
+ 4. **Capture Results**
62
+ - Save output to execution.log
63
+ - Capture return code
64
+ - Record execution time
65
+ - Store any generated files
66
+
67
+ 5. **Display Results**
68
+ - Show stdout
69
+ - Show stderr (if any)
70
+ - Display execution time
71
+ - Show success/failure status
50
72
  </process>
51
73
 
52
74
  <examples>
53
75
 
54
- **Execute code:**
76
+ **Execute current algorithm:**
55
77
  /algo-run
56
78
 
57
- **Skip execution:**
58
- /algo-run --skip
59
-
60
- **Custom timeout:**
79
+ **Execute with custom timeout:**
61
80
  /algo-run --timeout 60
62
81
 
82
+ **Skip execution (for testing):**
83
+ /algo-run --skip
84
+
63
85
  </examples>
64
86
 
65
87
  <options>
66
88
 
67
89
  --skip
68
- Skip execution and proceed directly to verification
90
+ Skip execution, just validate
69
91
 
70
92
  --timeout <seconds>
71
- Maximum execution time (default: 30)
93
+ Set execution timeout (default: 30)
72
94
 
73
95
  </options>
74
96
 
75
97
  <next_steps>
76
98
  /algo-verify - Verify execution results
77
- /algo-status - Check algorithm state
99
+ /algo-status - Check current state
78
100
  </next_steps>
@@ -11,6 +11,22 @@ Display current algorithm state, progress, and available next steps.
11
11
  Shows workflow state, completion status, and suggestions.
12
12
  </objective>
13
13
 
14
+ <execution>
15
+ Check status by running:
16
+ ```bash
17
+ npx algomath-extract algostatus "$@"
18
+ ```
19
+
20
+ Or if algomath-extract is installed globally:
21
+ ```bash
22
+ algostatus "$@"
23
+ ```
24
+
25
+ This will:
26
+ 1. Load current algorithm state
27
+ 2. Display progress and completion status
28
+ 3. Show available next steps
29
+ </execution>
14
30
 
15
31
  <process>
16
32
  Display status:
@@ -4,6 +4,7 @@ argument-hint: "[--step <N>] [--detailed] [--diagnostic] [--expected <value>]"
4
4
  tools:
5
5
  read: true
6
6
  write: true
7
+ Bash: true
7
8
  ---
8
9
 
9
10
  <objective>
@@ -11,89 +12,107 @@ Verify execution results, compare to expected values, explain algorithm behavior
11
12
  and identify potential edge cases.
12
13
  </objective>
13
14
 
15
+ <execution>
16
+ Execute verification by running:
17
+
18
+ **Option 1 - Using npx (no install required):**
19
+ ```bash
20
+ npx -p algomath-extract algoverify "$@"
21
+ ```
22
+
23
+ **Option 2 - If installed globally:**
24
+ ```bash
25
+ algoverify "$@"
26
+ ```
27
+
28
+ **Option 3 - If installed locally in project:**
29
+ ```bash
30
+ ./node_modules/.bin/algoverify "$@"
31
+ ```
32
+
33
+ This will:
34
+ 1. Load execution results and algorithm steps
35
+ 2. Verify correctness against expected values
36
+ 3. Generate explanation of algorithm behavior
37
+ 4. Identify edge cases and potential issues
38
+ </execution>
14
39
 
15
40
  <process>
16
41
  Execute verification workflow:
17
42
 
43
+
18
44
  1. **Load Execution Results**
19
- - Read execution.log
20
- - Load algorithm steps
21
- - Get generated code
22
-
23
- 2. **Verify Execution**
24
- - Check if execution succeeded
25
- - Verify no errors
26
- - Validate output present
27
-
28
- 3. **Compare Results (if --expected)**
29
- - Compare actual vs expected output
30
- - Support numeric tolerance for floats
31
- - Show differences
32
-
33
- 4. **Generate Explanation**
34
- - Brief mode: 1-2 sentence summary
35
- - Detailed mode: Step-by-step walkthrough
36
- - Step mode: Explain specific step N
37
-
38
- 5. **Detect Edge Cases**
39
- - Empty inputs
40
- - Boundary values
41
- - Division by zero
42
- - Array bounds
43
- - Infinite loops
44
-
45
- 6. **Diagnostic Mode (if failed)**
46
- - Analyze error
47
- - Suggest fixes
48
- - Explain failure point
49
-
50
- 7. **Save Report**
51
- - Write to verification.log
52
- - Update state to VERIFIED
53
-
54
- 8. **Display Summary**
55
- - Execution status
56
- - Explanation
57
- - Edge cases found
58
- - Next steps
45
+ - Read execution.log
46
+ - Load algorithm steps
47
+ - Check execution status
48
+
49
+ 2. **Check Results**
50
+ - Compare output to expected
51
+ - Validate return codes
52
+ - Check for errors
53
+ - Verify output format
54
+
55
+ 3. **Generate Explanation**
56
+ - Explain what the algorithm does
57
+ - Describe each step
58
+ - Show data flow
59
+ - Explain mathematical concepts
60
+
61
+ 4. **Identify Edge Cases**
62
+ - Empty inputs
63
+ - Single element
64
+ - Maximum values
65
+ - Boundary conditions
66
+ - Error conditions
67
+
68
+ 5. **Suggest Tests**
69
+ - Propose test cases
70
+ - Suggest inputs to try
71
+ - Recommend validations
72
+
73
+ 6. **Display Summary**
74
+ - Show verification status
75
+ - Display explanation
76
+ - List edge cases
77
+ - Suggest improvements
59
78
  </process>
60
79
 
61
80
  <examples>
62
81
 
63
- **Verify results:**
82
+ **Verify current algorithm:**
64
83
  /algo-verify
65
84
 
66
- **Explain specific step:**
67
- /algo-verify --step 3
85
+ **Verify specific step:**
86
+ /algo-verify --step 5
68
87
 
69
- **Detailed explanation:**
88
+ **Detailed verification:**
70
89
  /algo-verify --detailed
71
90
 
72
- **Compare with expected:**
73
- /algo-verify --expected "42"
74
-
75
- **Diagnostic for failed runs:**
91
+ **Diagnostic mode:**
76
92
  /algo-verify --diagnostic
77
93
 
94
+ **Compare to expected:**
95
+ /algo-verify --expected "[1, 2, 3]"
96
+
78
97
  </examples>
79
98
 
80
99
  <options>
81
100
 
82
101
  --step <N>
83
- Explain step number N in detail
102
+ Explain specific step number
84
103
 
85
104
  --detailed
86
- Show detailed step-by-step explanation
105
+ Show detailed verification
87
106
 
88
107
  --diagnostic
89
- Run diagnostic mode for failed executions
108
+ Run diagnostic checks
90
109
 
91
110
  --expected <value>
92
- Expected output for comparison
111
+ Compare to expected output
93
112
 
94
113
  </options>
95
114
 
96
115
  <next_steps>
97
- /algo-extract - Start with new algorithm
98
116
  /algo-status - Check current state
117
+ /algo-list - View all algorithms
99
118
  </next_steps>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "algomath-extract",
3
- "version": "1.0.13",
3
+ "version": "1.0.15",
4
4
  "description": "AlgoMath Framework - Transform AI assistants into reliable mathematical problem-solving environments",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -42,8 +42,8 @@
42
42
  "dependencies": {
43
43
  "commander": "^11.0.0",
44
44
  "inquirer": "^9.2.0",
45
- "chalk": "^5.3.0",
46
- "ora": "^7.0.0"
45
+ "chalk": "^4.1.2",
46
+ "ora": "^5.4.1"
47
47
  },
48
48
  "devDependencies": {
49
49
  "eslint": "^8.0.0"