@naiv/api-agent 0.0.2 → 0.0.4

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.
@@ -2,16 +2,14 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const child_process_manager_1 = require("./child_process_manager");
4
4
  const journal_log_1 = require("./journal_log");
5
- process.on('SIGINT', () => {
6
- console.log('Received SIGINT signal. Performing graceful shutdown...');
7
- journal_log_1.JournalLog.instance.persistLog();
8
- child_process_manager_1.ChildProcessManager.instance.cleanUpChildProcess();
9
- process.exit(0); // Exit after cleanup
10
- });
11
- process.on('SIGTERM', () => {
5
+ function handleError() {
12
6
  console.log('Received SIGTERM signal. Performing graceful shutdown...');
13
7
  journal_log_1.JournalLog.instance.persistLog();
14
8
  child_process_manager_1.ChildProcessManager.instance.cleanUpChildProcess();
15
9
  process.exit(0);
16
- });
10
+ }
11
+ process.on('SIGINT', handleError);
12
+ process.on('SIGTERM', handleError);
13
+ process.on("unhandledRejection", handleError);
14
+ process.on("uncaughtException", handleError);
17
15
  //# sourceMappingURL=cleanup-safely.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"cleanup-safely.js","sourceRoot":"","sources":["../cleanup-safely.ts"],"names":[],"mappings":";;AAAA,mEAA8D;AAC9D,+CAA2C;AAE3C,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE;IACxB,OAAO,CAAC,GAAG,CAAC,yDAAyD,CAAC,CAAC;IACvE,wBAAU,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAC;IACjC,2CAAmB,CAAC,QAAQ,CAAC,mBAAmB,EAAE,CAAC;IACnD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,qBAAqB;AACxC,CAAC,CAAC,CAAC;AAEH,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,GAAG,EAAE;IACzB,OAAO,CAAC,GAAG,CAAC,0DAA0D,CAAC,CAAC;IACxE,wBAAU,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAC;IACjC,2CAAmB,CAAC,QAAQ,CAAC,mBAAmB,EAAE,CAAC;IACnD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
1
+ {"version":3,"file":"cleanup-safely.js","sourceRoot":"","sources":["../cleanup-safely.ts"],"names":[],"mappings":";;AAAA,mEAA8D;AAC9D,+CAA2C;AAE3C,SAAS,WAAW;IAClB,OAAO,CAAC,GAAG,CAAC,0DAA0D,CAAC,CAAC;IACxE,wBAAU,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAC;IACjC,2CAAmB,CAAC,QAAQ,CAAC,mBAAmB,EAAE,CAAC;IACnD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;AAClC,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;AACnC,OAAO,CAAC,EAAE,CAAC,oBAAoB,EAAE,WAAW,CAAC,CAAC;AAC9C,OAAO,CAAC,EAAE,CAAC,mBAAmB,EAAE,WAAW,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@naiv/api-agent",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "publishConfig": {
@@ -17,7 +17,7 @@
17
17
  },
18
18
  "files": [
19
19
  "dist",
20
- "api.zip",
20
+ "prompt",
21
21
  "package.json"
22
22
  ],
23
23
  "keywords": [],
@@ -0,0 +1,9 @@
1
+ give your planning step by step here for scope of work above in JSON with template array of object {title: string, description: string} dont include free text, only clean json response. Make it as least as possible plans.
2
+
3
+ Your main plan must not include review, but includes check if the code running well by checking building the project.
4
+
5
+ Before you start the main process you should check if file `journal.md` exists, it contains user journal that was created during working on this project, you should continue the existing working and not start from scratch. If it didnt exist then it must be an empty project, you know what to do then (and you dont need to initialize journal.md) since `journal.md` will be automatically created by system.
6
+
7
+ Check .env before replace the content.
8
+
9
+ Do not forget to remove NAIV example design `design/*-example.naiv`.
@@ -0,0 +1,176 @@
1
+ ## Guide: How Write Sub-Plans
2
+
3
+ Every sub-plan has structure (typescript syntax) `SubPlan`, response with only single instruction one by one, after user response, give another instruction, until "Finished" instruction.
4
+
5
+ ```typescript
6
+ export enum INSTRUCTION {
7
+ ListDir = 'ListDir',
8
+ ReadFile = 'ReadFile',
9
+ CreateFile = 'CreateFile',
10
+ OverwriteFile = 'OverwriteFile',
11
+ DeleteFile = 'DeleteFile',
12
+ MoveFile = 'MoveFile',
13
+ CreateDir = 'CreateDir',
14
+ RemoveDir = 'RemoveDir',
15
+ MoveDir = 'MoveDir',
16
+ InstallDependency = 'InstallDependency',
17
+ Build = 'Build',
18
+ CustomCLIRun = 'CustomCLIRun',
19
+ RunServer = 'RunServer',
20
+ StopServer = 'StopServer',
21
+ Finished = 'Finished',
22
+ }
23
+
24
+ type SubPlan = SubPlanListDir
25
+ | SubPlanReadFile
26
+ | SubPlanCreateOverwriteFile
27
+ | SubPlanDeleteFile
28
+ | SubPlanMoveFile
29
+ | SubPlanCreateDir
30
+ | SubPlanRemoveDir
31
+ | SubPlanMoveDir
32
+ | SubPlanInstallDependency
33
+ | SubPlanBuild
34
+ | SubPlanCustomCLIRun
35
+ | SubPlanRunServer
36
+ | SubPlanStopServer
37
+ | SubPlanFinished;
38
+
39
+ interface SubPlanListDir {
40
+ instruction: INSTRUCTION.ListDir
41
+ dirpath: string
42
+ description: string
43
+ }
44
+
45
+ interface SubPlanReadFile {
46
+ instruction: INSTRUCTION.ReadFile
47
+ filepath: string
48
+ description: string
49
+ }
50
+
51
+ interface SubPlanCreateOverwriteFile {
52
+ instruction: INSTRUCTION.CreateFile | INSTRUCTION.OverwriteFile
53
+ filepath: string
54
+ content: string
55
+ description: string
56
+ }
57
+
58
+ interface SubPlanDeleteFile {
59
+ instruction: INSTRUCTION.DeleteFile
60
+ filepath: string
61
+ description: string
62
+ }
63
+
64
+ interface SubPlanMoveFile {
65
+ instruction: INSTRUCTION.MoveFile
66
+ filepath_source: string
67
+ filepath_target: string
68
+ description: string
69
+ }
70
+
71
+ interface SubPlanCreateDir {
72
+ instruction: INSTRUCTION.CreateDir
73
+ dirpath: string
74
+ description: string
75
+ }
76
+
77
+ interface SubPlanRemoveDir {
78
+ instruction: INSTRUCTION.RemoveDir
79
+ dirpath: string
80
+ description: string
81
+ }
82
+
83
+ interface SubPlanMoveDir {
84
+ instruction: INSTRUCTION.MoveDir
85
+ dirpath_source: string
86
+ dirpath_target: string
87
+ description: string
88
+ }
89
+
90
+ interface SubPlanInstallDependency {
91
+ instruction: INSTRUCTION.InstallDependency
92
+ dependency_list_package_name: string[]
93
+ description: string
94
+ }
95
+
96
+ interface SubPlanBuild {
97
+ instruction: INSTRUCTION.Build
98
+ description: string
99
+ }
100
+
101
+ interface SubPlanCustomCLIRun {
102
+ instruction: INSTRUCTION.CustomCLIRun
103
+ command: string
104
+ description: string
105
+ }
106
+
107
+ interface SubPlanRunServer {
108
+ instruction: INSTRUCTION.RunServer
109
+ description: string
110
+ }
111
+
112
+ interface SubPlanStopServer {
113
+ instruction: INSTRUCTION.StopServer
114
+ description: string
115
+ }
116
+
117
+ interface SubPlanFinished {
118
+ instruction: INSTRUCTION.Finished
119
+ description: string
120
+ }
121
+ ```
122
+
123
+ ### Example
124
+
125
+ example #1
126
+
127
+ ```
128
+ {
129
+ "instruction": "ListDir",
130
+ "dirpath": ".",
131
+ "description": "show list directory project and I will decide next instruction based on list dir result"
132
+ }
133
+ ```
134
+
135
+ example #2
136
+
137
+ ```
138
+ {
139
+ "instruction": "CreateFile",
140
+ "filepath": "design/db.naiv",
141
+ "content": "sample file content",
142
+ "description": "create file db.naiv with content of database structure for an online shop website"
143
+ }
144
+ ```
145
+
146
+ response only json with `SubPlan` structure above without free text, only json format.
147
+
148
+ ### Initial Instruction, Next Instruction, and End of Instruction
149
+
150
+ On every main plan, user will ask for list of instructions to execute the main plan, you have to response it one by one without explicitly expose all your plan, just one by one you give instruction system will execute it, and then next instruction and execute, and so on. In the end of instruction you shoud response with type "Finished" it will indicate that the main plan is finished and no more instruction to be executed.
151
+
152
+ Remember, when you finished all instruction dont forget to response with type: "Finished", do not ever give a blank response use type "Finished" instead.
153
+
154
+ Always run "npm run build" before you finish implementation phase on typescript file.
155
+
156
+ ### How to Run/Start Server
157
+
158
+ - Correct: Give instruction RunServer
159
+ - Incorrect: CustomCLIRun "npm run dev" or "npm start"
160
+ - Incorrect: read package.json and run it by yourself
161
+
162
+ use the correct one.
163
+
164
+ ### How to Stop Server
165
+
166
+ - Correct: Give instruction StopServer
167
+ - Incorrect: kill program
168
+
169
+ use the correct one.
170
+
171
+ ### How to Check if Server Running or Not
172
+
173
+ - Correct: try hit a program with port on .env if it has response then server is running.
174
+ - Incorrect: look up context on chat history, do not trust your memory or history
175
+
176
+ use the correct one.