@tduyng/pi-prewalk 0.0.1 → 0.0.2
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/package.json +1 -1
- package/src/bash-writes.ts +0 -3
- package/src/config.ts +5 -2
- package/src/index.ts +14 -5
package/package.json
CHANGED
package/src/bash-writes.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { tmpdir } from 'node:os'
|
|
2
|
-
import { resolve } from 'node:path'
|
|
3
1
|
import { isScratchPath } from './logic.js'
|
|
4
2
|
|
|
5
3
|
const HEREDOC = /(?<!<)<<(?!<)-?\s*(['"]?)(\w+)\1/
|
|
@@ -39,7 +37,6 @@ function redirectsToWorkspace(command: string, cwd: string): boolean {
|
|
|
39
37
|
|
|
40
38
|
export function bashWritesFiles(command: string, cwd: string): boolean {
|
|
41
39
|
if (redirectsToWorkspace(command, cwd)) return true
|
|
42
|
-
if (command.includes(resolve(tmpdir()))) return false
|
|
43
40
|
const text = withoutInertText(command)
|
|
44
41
|
return WRITER_VERB.test(text) || (INTERPRETER.test(text) && SCRIPT_WRITE.test(command))
|
|
45
42
|
}
|
package/src/config.ts
CHANGED
|
@@ -95,11 +95,14 @@ export function readEffectivePrewalkConfig(
|
|
|
95
95
|
return prewalkConfigFrom({ ...readSettingsFile(agentPath), ...readSettingsFile(projectPath) })
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
-
export function writePrewalkConfig(config: PrewalkConfig, path: string = prewalkWritePath()):
|
|
98
|
+
export function writePrewalkConfig(config: PrewalkConfig, path: string = prewalkWritePath()): boolean {
|
|
99
99
|
try {
|
|
100
100
|
const target = existsSync(path) ? realpathSync(path) : path
|
|
101
101
|
const temporary = `${target}.${process.pid}.tmp`
|
|
102
102
|
writeFileSync(temporary, `${JSON.stringify(config, null, 2)}\n`)
|
|
103
103
|
renameSync(temporary, target)
|
|
104
|
-
|
|
104
|
+
return true
|
|
105
|
+
} catch {
|
|
106
|
+
return false
|
|
107
|
+
}
|
|
105
108
|
}
|
package/src/index.ts
CHANGED
|
@@ -165,6 +165,14 @@ type PlanToolDefinition = ToolDefinition<typeof PLAN_PARAMETERS> & { defaultActi
|
|
|
165
165
|
export default function prewalkExtension(pi: ExtensionAPI): void {
|
|
166
166
|
let state: PrewalkState | null = null
|
|
167
167
|
let config: PrewalkConfig = readEffectivePrewalkConfig()
|
|
168
|
+
|
|
169
|
+
const saveConfig = (ctx: ExtensionContext): void => {
|
|
170
|
+
if (writePrewalkConfig(config)) return
|
|
171
|
+
ctx.ui.notify(
|
|
172
|
+
'prewalk: the config change applies to this session only; the file could not be written.',
|
|
173
|
+
'warning'
|
|
174
|
+
)
|
|
175
|
+
}
|
|
168
176
|
let stallNudged = false
|
|
169
177
|
let completionNudged = false
|
|
170
178
|
let reviewSpent = false
|
|
@@ -423,7 +431,7 @@ export default function prewalkExtension(pi: ExtensionAPI): void {
|
|
|
423
431
|
planner: args.planner === null ? config.planner : [plannerRef],
|
|
424
432
|
executor: args.executor === null ? config.executor : [executorRef]
|
|
425
433
|
}
|
|
426
|
-
|
|
434
|
+
saveConfig(ctx)
|
|
427
435
|
}
|
|
428
436
|
persist()
|
|
429
437
|
updateStatus(ctx)
|
|
@@ -681,10 +689,11 @@ export default function prewalkExtension(pi: ExtensionAPI): void {
|
|
|
681
689
|
pi.on('input', async (event) => {
|
|
682
690
|
const text = event.text.trimStart()
|
|
683
691
|
if (text.startsWith('/') || text.startsWith(SKILL_BLOCK_PREFIX) || text.startsWith(NUDGE_PREFIX)) return
|
|
692
|
+
if (event.source === 'extension') return
|
|
684
693
|
stallNudged = false
|
|
685
694
|
// A steer joins the task in flight and a follow-up waits for that turn to settle, so the
|
|
686
|
-
// steer never opens a task here and the follow-up routes as one when it arrives.
|
|
687
|
-
//
|
|
695
|
+
// steer never opens a task here and the follow-up routes as one when it arrives. Extension
|
|
696
|
+
// messages are continuations or injected context, not a new task, so they leave the task alone.
|
|
688
697
|
if (event.streamingBehavior === 'steer') {
|
|
689
698
|
steer = event.text
|
|
690
699
|
return
|
|
@@ -874,7 +883,7 @@ export default function prewalkExtension(pi: ExtensionAPI): void {
|
|
|
874
883
|
|
|
875
884
|
if (parsed.kind === 'mode') {
|
|
876
885
|
config = { ...config, mode: parsed.mode }
|
|
877
|
-
|
|
886
|
+
saveConfig(ctx)
|
|
878
887
|
ctx.ui.notify(`prewalk: ${MODE_LABEL[parsed.mode]}`, 'info')
|
|
879
888
|
return
|
|
880
889
|
}
|
|
@@ -894,7 +903,7 @@ export default function prewalkExtension(pi: ExtensionAPI): void {
|
|
|
894
903
|
parsed.chain.push(choice.ref)
|
|
895
904
|
}
|
|
896
905
|
config = { ...config, [parsed.role]: parsed.chain }
|
|
897
|
-
|
|
906
|
+
saveConfig(ctx)
|
|
898
907
|
// The badge reads the armed pair, so a chain that moves under a live session moves it too.
|
|
899
908
|
if (state !== null) {
|
|
900
909
|
const head = chainModel(ctx, parsed.chain)
|