Skip to content

Commit

Permalink
+++
Browse files Browse the repository at this point in the history
  • Loading branch information
Offirmo committed Sep 28, 2024
1 parent 88977f7 commit aae4a5d
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 26 deletions.
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import to_prettified_str from '@offirmo-private/prettify-any'

import { create as create_chat } from '@offirmo-private/view--chat'

import { create as create_tty_chat_ui } from '../src'
import { create as create_tty_chat_ui } from '../src/index.js'
import { to_prettified_str } from '../src/libs.js'

import { get_next_step1 } from '../../view--chat/doc/demo'
import { get_next_step1 } from '../../view--chat/doc/demo.js'

/////////////////////////////////////////////////

const DEBUG = false
const DEBUG = true

const no_ui = {
setup: async () => {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
"ora": "^8",
"p-progress": "^1",
"strip-ansi": "^7",
"term-size": "^4"
"term-size": "^4",
"indent-string": "^5"
},

"scripts": {
Expand Down
30 changes: 15 additions & 15 deletions stack--current/5-incubator/active/view--chat--terminal/src/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import readline from 'node:readline'
const term_size = require('term-size')
const strip_ansi = require('strip-ansi')
const create_ora_spinner = require('ora')
const Gauge = require('gauge')
import term_size from 'term-size'
import strip_ansi from 'strip-ansi'
import create_ora_spinner from 'ora'
import Gauge from 'gauge'

const { to_prettified_str, stylize_string, indent_string, wrap_string } = require('./libs')
import { get_shared_start } from './utils'
import { to_prettified_str, stylize_string, indent_string, wrap_string } from './libs.js'
import { get_shared_start } from './utils.js'


const MANY_BOX_HORIZ = '────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────'
Expand Down Expand Up @@ -332,16 +332,16 @@ function create({DEBUG, shouldCenter}) {
function read_string(step) {
if (DEBUG) console.log(`↘ read_string(\n${to_prettified_str(step, { outline: true })}\n)`)
return new Promise(resolve => {
//rli.clearLine(process.stdout, 0)
rli.prompt()

rli.question('', answer => {
rli.clearLine(process.stdout, 0)
answer = String(answer).trim()
if (DEBUG) console.log(`[You entered: "${answer}"]`)
resolve(answer)
//rli.clearLine(process.stdout, 0)
rli.prompt()

rli.question('', answer => {
rli.clearLine(process.stdout, 0)
answer = String(answer).trim()
if (DEBUG) console.log(`[You entered: "${answer}"]`)
resolve(answer)
})
})
})
.then(answer => {
if (step.msgg_as_user)
return display_message({
Expand Down
14 changes: 10 additions & 4 deletions stack--current/5-incubator/active/view--chat--terminal/src/libs.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
const to_prettified_str = require('@offirmo-private/prettify-any')
import {
injectꓽlibꓽchalk,
prettifyꓽany as to_prettified_str,
} from '@offirmo-private/prettify-any'

const stylize_string = require('chalk')
import indent_string from 'indent-string'

import stylize_string from 'chalk'
injectꓽlibꓽchalk(stylize_string)

// https://github.com/AnAppAMonth/linewrap
const linewrap = require('linewrap')
import linewrap from 'linewrap'
function wrap_string(s, size) {
return linewrap(size, {skipScheme: 'ansi-color'})(s)
}

////////////

module.exports = {
export {
to_prettified_str,
stylize_string,
indent_string,
wrap_string,
}
2 changes: 1 addition & 1 deletion stack--current/5-incubator/active/view--chat/src/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import PromiseWithProgress from 'p-progress'
import { PProgress as PromiseWithProgress } from 'p-progress'
import is_promise from 'is-promise'

/////////////////////////////////////////////////
Expand Down

0 comments on commit aae4a5d

Please sign in to comment.