jorgex-stack 1.0.4 → 1.0.6
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/dist/cli.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
// src/cli.ts
|
|
4
4
|
import * as p6 from "@clack/prompts";
|
|
5
|
+
import { pathToFileURL as pathToFileURL2 } from "url";
|
|
5
6
|
|
|
6
7
|
// src/install.ts
|
|
7
8
|
import fs11 from "fs";
|
|
@@ -1246,12 +1247,20 @@ function planCommands(adapter, ctx) {
|
|
|
1246
1247
|
const { commandsDir } = adapter.paths(ctx.configDir);
|
|
1247
1248
|
const source = path15.join(ctx.stackDir, "commands");
|
|
1248
1249
|
if (!fs9.existsSync(source)) return [];
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1250
|
+
const commandFiles = [
|
|
1251
|
+
...listMarkdownFiles(source),
|
|
1252
|
+
...listMarkdownFiles(path15.join(source, adapter.id))
|
|
1253
|
+
];
|
|
1254
|
+
return commandFiles.map(({ file, fullPath }) => {
|
|
1255
|
+
const raw = fs9.readFileSync(fullPath, "utf8").replace(/\r\n/g, "\n");
|
|
1256
|
+
const rendered = adapter.renderCommand(file, raw);
|
|
1252
1257
|
return { kind: "write", target: path15.join(commandsDir, rendered.file), content: rendered.content };
|
|
1253
1258
|
});
|
|
1254
1259
|
}
|
|
1260
|
+
function listMarkdownFiles(dir) {
|
|
1261
|
+
if (!fs9.existsSync(dir)) return [];
|
|
1262
|
+
return fs9.readdirSync(dir, { withFileTypes: true }).filter((entry) => entry.isFile() && entry.name.endsWith(".md")).map((entry) => ({ file: entry.name, fullPath: path15.join(dir, entry.name) }));
|
|
1263
|
+
}
|
|
1255
1264
|
|
|
1256
1265
|
// src/components/hooks.ts
|
|
1257
1266
|
function planHooks(adapter, ctx) {
|
|
@@ -2744,6 +2753,8 @@ function parseFlags(args) {
|
|
|
2744
2753
|
agents: [],
|
|
2745
2754
|
dryRun: false,
|
|
2746
2755
|
yes: false,
|
|
2756
|
+
help: false,
|
|
2757
|
+
version: false,
|
|
2747
2758
|
list: false,
|
|
2748
2759
|
check: false,
|
|
2749
2760
|
removeEngram: false,
|
|
@@ -2757,6 +2768,8 @@ function parseFlags(args) {
|
|
|
2757
2768
|
else if (arg.startsWith("--target-dir=")) flags.targetDir = arg.slice(13);
|
|
2758
2769
|
else if (arg === "--dry-run") flags.dryRun = true;
|
|
2759
2770
|
else if (arg === "--yes" || arg === "-y") flags.yes = true;
|
|
2771
|
+
else if (arg === "--help" || arg === "-h") flags.help = true;
|
|
2772
|
+
else if (arg === "--version" || arg === "-v") flags.version = true;
|
|
2760
2773
|
else if (arg === "--list") flags.list = true;
|
|
2761
2774
|
else if (arg === "--check") flags.check = true;
|
|
2762
2775
|
else if (arg === "--remove-engram") flags.removeEngram = true;
|
|
@@ -2764,6 +2777,23 @@ function parseFlags(args) {
|
|
|
2764
2777
|
}
|
|
2765
2778
|
return flags;
|
|
2766
2779
|
}
|
|
2780
|
+
function parseCliArgs(argv) {
|
|
2781
|
+
const [first, ...rest] = argv;
|
|
2782
|
+
const isCommand = COMMANDS.includes(first ?? "install");
|
|
2783
|
+
if (first !== void 0 && !isCommand && !first.startsWith("-")) {
|
|
2784
|
+
return {
|
|
2785
|
+
action: "unknown",
|
|
2786
|
+
command: "install",
|
|
2787
|
+
flags: parseFlags(rest),
|
|
2788
|
+
unknownCommand: first
|
|
2789
|
+
};
|
|
2790
|
+
}
|
|
2791
|
+
const command = isCommand ? first ?? "install" : "install";
|
|
2792
|
+
const flags = parseFlags(isCommand ? rest : argv);
|
|
2793
|
+
if (first === "--help" || first === "-h" || flags.help) return { action: "help", command, flags };
|
|
2794
|
+
if (first === "--version" || first === "-v" || flags.version) return { action: "version", command, flags };
|
|
2795
|
+
return { action: "run", command, flags };
|
|
2796
|
+
}
|
|
2767
2797
|
async function resolveRuntimes(flags) {
|
|
2768
2798
|
if (flags.agents.length > 0) return flags.agents;
|
|
2769
2799
|
const detected = Object.values(ADAPTERS).filter((a) => a.detect().installed);
|
|
@@ -2804,18 +2834,16 @@ Opciones:
|
|
|
2804
2834
|
Ver PRD.md para el dise\xF1o completo.`);
|
|
2805
2835
|
}
|
|
2806
2836
|
async function main() {
|
|
2807
|
-
const
|
|
2808
|
-
if (
|
|
2809
|
-
if (
|
|
2810
|
-
|
|
2811
|
-
|
|
2812
|
-
console.error(`Comando desconocido: ${first}`);
|
|
2837
|
+
const parsed = parseCliArgs(process.argv.slice(2));
|
|
2838
|
+
if (parsed.action === "help") return printHelp();
|
|
2839
|
+
if (parsed.action === "version") return console.log(VERSION);
|
|
2840
|
+
if (parsed.action === "unknown") {
|
|
2841
|
+
console.error(`Comando desconocido: ${parsed.unknownCommand}`);
|
|
2813
2842
|
printHelp();
|
|
2814
2843
|
process.exitCode = 1;
|
|
2815
2844
|
return;
|
|
2816
2845
|
}
|
|
2817
|
-
const command
|
|
2818
|
-
const flags = parseFlags(isCommand ? rest : process.argv.slice(2));
|
|
2846
|
+
const { command, flags } = parsed;
|
|
2819
2847
|
if (flags.targetDir !== void 0 && flags.agents.length !== 1) {
|
|
2820
2848
|
console.error("--target-dir requiere exactamente un runtime en --agents.");
|
|
2821
2849
|
process.exitCode = 1;
|
|
@@ -2921,7 +2949,13 @@ async function main() {
|
|
|
2921
2949
|
}
|
|
2922
2950
|
}
|
|
2923
2951
|
}
|
|
2924
|
-
|
|
2925
|
-
|
|
2926
|
-
|
|
2927
|
-
|
|
2952
|
+
if (process.argv[1] !== void 0 && import.meta.url === pathToFileURL2(process.argv[1]).href) {
|
|
2953
|
+
main().catch((err) => {
|
|
2954
|
+
console.error(err instanceof Error ? err.message : String(err));
|
|
2955
|
+
process.exitCode = 1;
|
|
2956
|
+
});
|
|
2957
|
+
}
|
|
2958
|
+
export {
|
|
2959
|
+
parseCliArgs,
|
|
2960
|
+
parseFlags
|
|
2961
|
+
};
|
package/package.json
CHANGED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Goal Mode — manage persistent long-running objectives
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
The Goal Mode plugin should handle `/goal $ARGUMENTS` before this prompt runs.
|
|
6
|
+
|
|
7
|
+
If you are seeing this message as a normal assistant prompt, report that Goal Mode did not intercept the slash command. Do not start work, edit files, run tools, create branches, open PRs, or change repository state.
|
|
@@ -50,7 +50,7 @@ export function createOpenCodeGoalHooks(deps: OpenCodeGoalHooksDeps): OpenCodeGo
|
|
|
50
50
|
if (command !== "goal") return;
|
|
51
51
|
|
|
52
52
|
const response = commands.handleGoalCommand(extractCommandArguments(input));
|
|
53
|
-
|
|
53
|
+
replaceGoalCommandPrompt(input, output, response.message);
|
|
54
54
|
},
|
|
55
55
|
|
|
56
56
|
"experimental.chat.system.transform": async (_input, output) => {
|
|
@@ -169,33 +169,51 @@ function extractCommandArguments(input: unknown): string {
|
|
|
169
169
|
return typeof nested === "string" ? nested : "";
|
|
170
170
|
}
|
|
171
171
|
|
|
172
|
-
function
|
|
172
|
+
function replaceGoalCommandPrompt(input: unknown, output: HookOutput, text: string): void {
|
|
173
|
+
const prompt = renderGoalCommandPrompt(input, text);
|
|
174
|
+
|
|
173
175
|
if (Array.isArray(output.parts)) {
|
|
174
|
-
output.parts.
|
|
176
|
+
output.parts.splice(0, output.parts.length, {
|
|
175
177
|
id: `part_${randomUUID()}`,
|
|
176
178
|
sessionID: extractHookSessionID(input, output),
|
|
177
179
|
messageID: extractHookMessageID(input, output),
|
|
178
180
|
type: "text",
|
|
179
|
-
text,
|
|
181
|
+
text: prompt,
|
|
180
182
|
synthetic: true,
|
|
181
183
|
});
|
|
182
184
|
return;
|
|
183
185
|
}
|
|
184
186
|
if (typeof output.message === "string") {
|
|
185
|
-
output.message = output.message ? `${output.message}\n\n${
|
|
187
|
+
output.message = output.message ? `${output.message}\n\n${prompt}` : prompt;
|
|
186
188
|
return;
|
|
187
189
|
}
|
|
188
190
|
if (typeof output.output === "string") {
|
|
189
|
-
output.output = output.output ? `${output.output}\n\n${
|
|
191
|
+
output.output = output.output ? `${output.output}\n\n${prompt}` : prompt;
|
|
190
192
|
return;
|
|
191
193
|
}
|
|
192
194
|
if (Array.isArray(output.content)) {
|
|
193
|
-
output.content.push({ type: "text", text });
|
|
195
|
+
output.content.push({ type: "text", text: prompt });
|
|
194
196
|
return;
|
|
195
197
|
}
|
|
196
198
|
throw new Error("Unsupported OpenCode command output contract for Goal Mode.");
|
|
197
199
|
}
|
|
198
200
|
|
|
201
|
+
function renderGoalCommandPrompt(input: unknown, commandResult: string): string {
|
|
202
|
+
const args = extractCommandArguments(input).trim();
|
|
203
|
+
const firstToken = args.split(/\s+/, 1)[0]?.toLowerCase() ?? "";
|
|
204
|
+
const isControlCommand = new Set(["status", "plan", "history", "pause", "resume", "cancel", "merged"]).has(firstToken);
|
|
205
|
+
|
|
206
|
+
return [
|
|
207
|
+
"Goal Mode command result (authoritative):",
|
|
208
|
+
commandResult,
|
|
209
|
+
"",
|
|
210
|
+
"Instructions:",
|
|
211
|
+
isControlCommand
|
|
212
|
+
? "Reply with the Goal Mode command result only. Do not inspect files, run tools, continue implementation, create branches, open PRs, or change repository state."
|
|
213
|
+
: "A persistent Goal Mode objective has been created. Acknowledge the created goal, then continue only according to the injected Goal Mode context and the project work-lifecycle rules.",
|
|
214
|
+
].join("\n");
|
|
215
|
+
}
|
|
216
|
+
|
|
199
217
|
function extractHookSessionID(input: unknown, output: HookOutput): string {
|
|
200
218
|
const inputRecord = isRecord(input) ? input : undefined;
|
|
201
219
|
const outputRecord = output;
|